Skip to content

Commit 786d6dc

Browse files
Suresh SiddhaIngo Molnar
authored andcommitted
sched, nohz: Clean up the find_new_ilb() using sched groups nr_busy_cpus
nr_busy_cpus in the sched_group_power indicates whether the group is semi idle or not. This helps remove the is_semi_idle_group() and simplify the find_new_ilb() in the context of finding an optimal cpu that can do idle load balancing. Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20111202010832.656983582@sbsiddha-desk.sc.intel.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 0b005cf commit 786d6dc

1 file changed

Lines changed: 12 additions & 36 deletions

File tree

‎kernel/sched/fair.c‎

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4733,7 +4733,6 @@ static int active_load_balance_cpu_stop(void *data)
47334733
*/
47344734
static struct {
47354735
cpumask_var_t idle_cpus_mask;
4736-
cpumask_var_t grp_idle_mask;
47374736
atomic_t nr_cpus;
47384737
unsigned long next_balance; /* in jiffy units */
47394738
} nohz ____cacheline_aligned;
@@ -4773,33 +4772,6 @@ static inline struct sched_domain *lowest_flag_domain(int cpu, int flag)
47734772
for (sd = lowest_flag_domain(cpu, flag); \
47744773
(sd && (sd->flags & flag)); sd = sd->parent)
47754774

4776-
/**
4777-
* is_semi_idle_group - Checks if the given sched_group is semi-idle.
4778-
* @ilb_group: group to be checked for semi-idleness
4779-
*
4780-
* Returns: 1 if the group is semi-idle. 0 otherwise.
4781-
*
4782-
* We define a sched_group to be semi idle if it has atleast one idle-CPU
4783-
* and atleast one non-idle CPU. This helper function checks if the given
4784-
* sched_group is semi-idle or not.
4785-
*/
4786-
static inline int is_semi_idle_group(struct sched_group *ilb_group)
4787-
{
4788-
cpumask_and(nohz.grp_idle_mask, nohz.idle_cpus_mask,
4789-
sched_group_cpus(ilb_group));
4790-
4791-
/*
4792-
* A sched_group is semi-idle when it has atleast one busy cpu
4793-
* and atleast one idle cpu.
4794-
*/
4795-
if (cpumask_empty(nohz.grp_idle_mask))
4796-
return 0;
4797-
4798-
if (cpumask_equal(nohz.grp_idle_mask, sched_group_cpus(ilb_group)))
4799-
return 0;
4800-
4801-
return 1;
4802-
}
48034775
/**
48044776
* find_new_ilb - Finds the optimum idle load balancer for nomination.
48054777
* @cpu: The cpu which is nominating a new idle_load_balancer.
@@ -4815,8 +4787,8 @@ static inline int is_semi_idle_group(struct sched_group *ilb_group)
48154787
static int find_new_ilb(int cpu)
48164788
{
48174789
int ilb = cpumask_first(nohz.idle_cpus_mask);
4790+
struct sched_group *ilbg;
48184791
struct sched_domain *sd;
4819-
struct sched_group *ilb_group;
48204792

48214793
/*
48224794
* Have idle load balancer selection from semi-idle packages only
@@ -4834,23 +4806,28 @@ static int find_new_ilb(int cpu)
48344806

48354807
rcu_read_lock();
48364808
for_each_flag_domain(cpu, sd, SD_POWERSAVINGS_BALANCE) {
4837-
ilb_group = sd->groups;
4809+
ilbg = sd->groups;
48384810

48394811
do {
4840-
if (is_semi_idle_group(ilb_group)) {
4841-
ilb = cpumask_first(nohz.grp_idle_mask);
4812+
if (ilbg->group_weight !=
4813+
atomic_read(&ilbg->sgp->nr_busy_cpus)) {
4814+
ilb = cpumask_first_and(nohz.idle_cpus_mask,
4815+
sched_group_cpus(ilbg));
48424816
goto unlock;
48434817
}
48444818

4845-
ilb_group = ilb_group->next;
4819+
ilbg = ilbg->next;
48464820

4847-
} while (ilb_group != sd->groups);
4821+
} while (ilbg != sd->groups);
48484822
}
48494823
unlock:
48504824
rcu_read_unlock();
48514825

48524826
out_done:
4853-
return ilb;
4827+
if (ilb < nr_cpu_ids && idle_cpu(ilb))
4828+
return ilb;
4829+
4830+
return nr_cpu_ids;
48544831
}
48554832
#else /* (CONFIG_SCHED_MC || CONFIG_SCHED_SMT) */
48564833
static inline int find_new_ilb(int call_cpu)
@@ -5588,7 +5565,6 @@ __init void init_sched_fair_class(void)
55885565

55895566
#ifdef CONFIG_NO_HZ
55905567
zalloc_cpumask_var(&nohz.idle_cpus_mask, GFP_NOWAIT);
5591-
alloc_cpumask_var(&nohz.grp_idle_mask, GFP_NOWAIT);
55925568
#endif
55935569
#endif /* SMP */
55945570

0 commit comments

Comments
 (0)