[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251208092744.32737-2-kprateek.nayak@amd.com>
Date: Mon, 8 Dec 2025 09:26:48 +0000
From: K Prateek Nayak <kprateek.nayak@....com>
To: Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>, Vincent Guittot
<vincent.guittot@...aro.org>, Anna-Maria Behnsen <anna-maria@...utronix.de>,
Frederic Weisbecker <frederic@...nel.org>, Thomas Gleixner
<tglx@...utronix.de>
CC: <linux-kernel@...r.kernel.org>, Dietmar Eggemann
<dietmar.eggemann@....com>, Steven Rostedt <rostedt@...dmis.org>, Ben Segall
<bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>, Valentin Schneider
<vschneid@...hat.com>, K Prateek Nayak <kprateek.nayak@....com>, "Gautham R.
Shenoy" <gautham.shenoy@....com>, Swapnil Sapkal <swapnil.sapkal@....com>,
Shrikanth Hegde <sshegde@...ux.ibm.com>, Chen Yu <yu.c.chen@...el.com>
Subject: [RESEND RFC PATCH v2 02/29] sched/fair: Use rq->nohz_tick_stopped in update_nohz_stats()
"rq->nohz_tick_stopped" always follows the state of CPU on
"nohz.idle_cpus_mask". Use the local rq indicator instead of checking
for the CPU on the "idle_cpus_mask".
Use READ_ONCE() and WRITE_ONCE() for "rq->nohz_tick_stopped" to ensure
update_nohz_stats() always sees the latest value.
This cleanup is necessary to avoid the number of references to the
global "nohz.idle_cpus_mask" to ease the transition to a distributed
nohz idle tracking strategy.
No functional changes intended.
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@....com>
Signed-off-by: K Prateek Nayak <kprateek.nayak@....com>
---
kernel/sched/fair.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8a5168284eaf..b135c9ce21fe 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12557,10 +12557,10 @@ void nohz_balance_exit_idle(struct rq *rq)
{
WARN_ON_ONCE(rq != this_rq());
- if (likely(!rq->nohz_tick_stopped))
+ if (likely(!READ_ONCE(rq->nohz_tick_stopped)))
return;
- rq->nohz_tick_stopped = 0;
+ WRITE_ONCE(rq->nohz_tick_stopped, 0);
cpumask_clear_cpu(rq->cpu, nohz.idle_cpus_mask);
atomic_dec(&nohz.nr_cpus);
@@ -12608,14 +12608,14 @@ void nohz_balance_enter_idle(int cpu)
* *_avg. The CPU is already part of nohz.idle_cpus_mask so the clear
* of nohz.has_blocked can only happen after checking the new load
*/
- if (rq->nohz_tick_stopped)
+ if (READ_ONCE(rq->nohz_tick_stopped))
goto out;
/* If we're a completely isolated CPU, we don't play: */
if (on_null_domain(rq))
return;
- rq->nohz_tick_stopped = 1;
+ WRITE_ONCE(rq->nohz_tick_stopped, 1);
cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
atomic_inc(&nohz.nr_cpus);
@@ -12645,7 +12645,7 @@ static bool update_nohz_stats(struct rq *rq)
if (!rq->has_blocked_load)
return false;
- if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
+ if (!READ_ONCE(rq->nohz_tick_stopped))
return false;
if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
--
2.43.0
Powered by blists - more mailing lists