Skip to content

Commit

Permalink
[BACKPORT]sched/nohz: Run NOHZ idle load balancer on HK_FLAG_MISC CPUs
Browse files Browse the repository at this point in the history
The NOHZ idle balancer runs on the lowest idle CPU. This can
interfere with isolated CPUs, so confine it to HK_FLAG_MISC
housekeeping CPUs.

HK_FLAG_SCHED is not used for this because it is not set anywhere
at the moment. This could be folded into HK_FLAG_SCHED once that
option is fixed.

The problem was observed with increased jitter on an application
running on CPU0, caused by NOHZ idle load balancing being run on
CPU1 (an SMT sibling).

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190412042613.28930-1-npiggin@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

@THEBOSS619:- this kernel doesn't have HK_FLAG_MISC flag so backported it by removing the flag, it shouldn't posses any problems.
  • Loading branch information
npiggin authored and THEBOSS619 committed Aug 7, 2020
1 parent 3211499 commit b8b9c09
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions kernel/sched/fair.c
Expand Up @@ -11483,22 +11483,26 @@ static inline int on_null_domain(struct rq *rq)
* - When one of the busy CPUs notice that there may be an idle rebalancing
* needed, they will kick the idle load balancer, which then does idle
* load balancing for all the idle CPUs.
* - HK_FLAG_MISC CPUs are used for this task, because HK_FLAG_SCHED not set
* anywhere yet.
*/

static inline int find_new_ilb(void)
{
int ilb = cpumask_first(nohz.idle_cpus_mask);
int ilb;

if (ilb < nr_cpu_ids && idle_cpu(ilb))
return ilb;
for_each_cpu_and(ilb, nohz.idle_cpus_mask,
housekeeping_cpumask()) {
if (idle_cpu(ilb))
return ilb;
}

return nr_cpu_ids;
}

/*
* Kick a CPU to do the nohz balancing, if it is time for it. We pick the
* nohz_load_balancer CPU (if there is one) otherwise fallback to any idle
* CPU (if there is one).
* Kick a CPU to do the nohz balancing, if it is time for it. We pick any
* idle CPU in the HK_FLAG_MISC housekeeping set (if there is one).
*/
static void nohz_balancer_kick(bool only_update)
{
Expand Down

0 comments on commit b8b9c09

Please sign in to comment.