lkml.org 
[lkml]   [2014]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] sched: clean up select_task_rq_fair conditionals and indentation
This cleanup goes on top of the previous patch. We could also skip the
whole domain iteration if !want_affine, but that doesn't fit nicely in
80 columns and may have to be done in yet another patch (breaking that
bit of the code out into its own function?)

---8<---

Subject: sched: clean up select_task_rq_fair conditionals and indentation

The whole top half of select_task_rq_fair is only run if
sd_flag & SD_BALANCE_WAKE. The code should probably reflect
that.

Also remove the useless new_cpu = prev_cpu assignment, as the
value of new_cpu is not actually used.

Signed-off-by: Rik van Riel <riel@redhat.com>
---
kernel/sched/fair.c | 47 ++++++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5d33fb1b..844807b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4424,37 +4424,38 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
if (p->nr_cpus_allowed == 1)
return prev_cpu;

+ rcu_read_lock();
if (sd_flag & SD_BALANCE_WAKE) {
if (cpumask_test_cpu(cpu, tsk_cpus_allowed(p)))
want_affine = 1;
- new_cpu = prev_cpu;
- }

- rcu_read_lock();
- for_each_domain(cpu, tmp) {
- if (!(tmp->flags & SD_LOAD_BALANCE))
- continue;
+ for_each_domain(cpu, tmp) {
+ if (!cpumask_test_cpu(cpu, tsk_cpus_allowed(p)))
+ break;

- /*
- * If both cpu and prev_cpu are part of this domain,
- * cpu is a valid SD_WAKE_AFFINE target.
- */
- if (want_affine && (tmp->flags & SD_WAKE_AFFINE) &&
- cpumask_test_cpu(prev_cpu, sched_domain_span(tmp))) {
- affine_sd = tmp;
- break;
- }
+ if (!(tmp->flags & SD_LOAD_BALANCE))
+ continue;

- if (tmp->flags & sd_flag)
- sd = tmp;
- }
+ /*
+ * If both cpu and prev_cpu are part of this domain,
+ * cpu is a valid SD_WAKE_AFFINE target.
+ */
+ if (want_affine && (tmp->flags & SD_WAKE_AFFINE) &&
+ cpumask_test_cpu(prev_cpu,
+ sched_domain_span(tmp))) {
+ affine_sd = tmp;
+ break;
+ }

- if (affine_sd) {
- if (cpu != prev_cpu && wake_affine(affine_sd, p, sync))
- prev_cpu = cpu;
- }
+ if (tmp->flags & sd_flag)
+ sd = tmp;
+ }
+
+ if (affine_sd) {
+ if (cpu != prev_cpu && wake_affine(affine_sd, p, sync))
+ prev_cpu = cpu;
+ }

- if (sd_flag & SD_BALANCE_WAKE) {
new_cpu = select_idle_sibling(p, prev_cpu);
goto unlock;
}


\
 
 \ /
  Last update: 2014-05-09 08:41    [W:0.089 / U:0.772 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site