From eb329acdbb63b25a4a566695f99cd4085f644bfd Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Wed, 16 Oct 2019 12:26:48 +0530 Subject: [PATCH] sched/fair: reduce no-hz idle balance for energy aware systems We are kicking no-hz idle balance when the CPU has two tasks. It should be done only when the CPU is overutilized on energy aware systems. This approach seems to be causing more number of wakeups on HZ=250 systems compared to HZ=100. Revisit the no-hz idle scheme and only send the IPI if and when it is necessary. Change-Id: I82e58a2aa3b6508c86d05c93c9fb7fe6dfbde500 Signed-off-by: Pavankumar Kondeti [satyap@codeaurora.org: fix trivial merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/fair.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 81a407729481..5ad74026f7a5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10615,7 +10615,7 @@ static inline int find_energy_aware_new_ilb(void) int ilb = nr_cpu_ids; struct sched_domain *sd; int cpu = raw_smp_processor_id(); - cpumask_t avail_cpus, tmp_cpus; + cpumask_t idle_cpus, tmp_cpus; struct sched_group *sg; unsigned long ref_cap = capacity_orig_of(cpu); unsigned long best_cap = 0, best_cap_cpu = -1; @@ -10625,16 +10625,16 @@ static inline int find_energy_aware_new_ilb(void) if (!sd) goto out; - cpumask_and(&avail_cpus, nohz.idle_cpus_mask, + cpumask_and(&idle_cpus, nohz.idle_cpus_mask, housekeeping_cpumask(HK_FLAG_MISC)); - cpumask_andnot(&avail_cpus, &avail_cpus, cpu_isolated_mask); + cpumask_andnot(&idle_cpus, &idle_cpus, cpu_isolated_mask); sg = sd->groups; do { int i; unsigned long cap; - cpumask_and(&tmp_cpus, &avail_cpus, sched_group_span(sg)); + cpumask_and(&tmp_cpus, &idle_cpus, sched_group_span(sg)); i = cpumask_first(&tmp_cpus); /* This sg did not have any idle CPUs */ @@ -10649,7 +10649,18 @@ static inline int find_energy_aware_new_ilb(void) break; } - /* The back up CPU is selected from the best capacity CPUs */ + /* + * When there are no idle CPUs in the same capacity group, + * we find the next best capacity CPU. + */ + if (best_cap > ref_cap) { + if (cap > ref_cap && cap < best_cap) { + best_cap = cap; + best_cap_cpu = i; + } + continue; + } + if (cap > best_cap) { best_cap = cap; best_cap_cpu = i;