public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: mingo@kernel.org, peterz@infradead.org,
	vincent.guittot@linaro.org, linux-kernel@vger.kernel.org,
	kprateek.nayak@amd.com
Cc: sshegde@linux.ibm.com, dietmar.eggemann@arm.com,
	vschneid@redhat.com, rostedt@goodmis.org, tglx@linutronix.de,
	tim.c.chen@linux.intel.com
Subject: [PATCH 2/4] sched/fair: Change likelyhood of nohz nr_cpus check
Date: Tue,  2 Dec 2025 00:01:44 +0530	[thread overview]
Message-ID: <20251201183146.74443-3-sshegde@linux.ibm.com> (raw)
In-Reply-To: <20251201183146.74443-1-sshegde@linux.ibm.com>

These days most of the system have multi cores. The likelyhood of
at least one or more CPUs in nohz (idle state) is higher.
So move likely to unlikely.

Allow stats balancing to complete when there are no nr_cpus as the check
happens later. Current code might race and may not set
nohz.has_blocked = 0 even when nohz.nr_cpus == 0

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 kernel/sched/fair.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 61cc3fdfa45b..55746274af06 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12448,10 +12448,10 @@ static void nohz_balancer_kick(struct rq *rq)
 		goto out;
 	/*
 	 * None are in tickless mode and hence no need for NOHZ idle load
-	 * balancing:
+	 * balancing, do stats update if its due
 	 */
-	if (likely(!atomic_read(&nohz.nr_cpus)))
-		return;
+	if (unlikely(!atomic_read(&nohz.nr_cpus)))
+		goto out;
 
 	if (rq->nr_running >= 2) {
 		flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK;
-- 
2.43.0


  parent reply	other threads:[~2025-12-01 18:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01 18:31 [PATCH 0/4] sched/fair: improve nohz fields for large systems Shrikanth Hegde
2025-12-01 18:31 ` [PATCH 1/4] sched/fair: Move checking for nohz cpus after time check Shrikanth Hegde
2025-12-01 18:31 ` Shrikanth Hegde [this message]
2025-12-01 18:31 ` [PATCH 3/4] sched/fair: Check for blocked task " Shrikanth Hegde
2025-12-02  6:26   ` Ingo Molnar
2025-12-02  6:55     ` Shrikanth Hegde
2025-12-01 18:31 ` [PATCH 4/4] sched/fair: Remove atomic nr_cpus and use cpumask instead Shrikanth Hegde
2025-12-01 19:58   ` Ingo Molnar
2025-12-02  5:29     ` Shrikanth Hegde
2025-12-02  7:54       ` Ingo Molnar
2025-12-02 14:35         ` Shrikanth Hegde
2025-12-02 16:14           ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251201183146.74443-3-sshegde@linux.ibm.com \
    --to=sshegde@linux.ibm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox