]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sched/fair: Move checking for nohz cpus after time check
authorShrikanth Hegde <sshegde@linux.ibm.com>
Thu, 15 Jan 2026 07:35:22 +0000 (13:05 +0530)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 15 Jan 2026 21:41:26 +0000 (22:41 +0100)
commit6b67c8a72e56041f91f70ae5995bdb769761869a
tree81e640867dfbf9cd200eea05eca2cd486b084a3e
parent553255cc857c08d72658b57d01c04f76cde9a83a
sched/fair: Move checking for nohz cpus after time check

Current code does.
- Read nohz.nr_cpus
- Check if the time has passed to do NOHZ idle balance

Instead do this.
- Check if the time has passed to do NOHZ idle balance
- Read nohz.nr_cpus

This will skip the read most of the time in normal system usage.
i.e when there are nohz.nr_cpus (system is not 100% busy).

Note that when there are no idle CPUs(100% busy), even if the flag gets
set to NOHZ_STATS_KICK | NOHZ_NEXT_KICK, find_new_ilb will fail and
there will be no NOHZ idle balance. In such cases there will be a very
narrow window where, kick_ilb will be called un-necessarily.
However current functionality is still retained.

Note: This patch doesn't solve any cacheline overheads. No improvement
in performance apart from saving a few cycles of reading nohz.nr_cpus

Reviewed-and-tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://patch.msgid.link/20260115073524.376643-2-sshegde@linux.ibm.com
kernel/sched/fair.c