[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240625114249.289014-4-npiggin@gmail.com>
Date: Tue, 25 Jun 2024 21:42:46 +1000
From: Nicholas Piggin <npiggin@...il.com>
To: Tejun Heo <tj@...nel.org>
Cc: Nicholas Piggin <npiggin@...il.com>,
"Paul E . McKenney" <paulmck@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Lai Jiangshan <jiangshanlai@...il.com>,
Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 3/4] stop_machine: Rearrange multi_cpu_stop state machine loop
More clearly separate the state-machine progress case from the
non-progress case.
Move stop_machine_yield() and rcu_momentary_dyntick_idle() calls
to the non-progress case like touch_nmi_watchdog(), rather than
always calling them, since there is no reason to yield or touch
watchdogs if the state machine progressed.
Signed-off-by: Nicholas Piggin <npiggin@...il.com>
---
kernel/stop_machine.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index cedb17ba158a..1e5c4702e36c 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -225,8 +225,6 @@ static int multi_cpu_stop(void *data)
/* Simple state machine */
do {
- /* Chill out and ensure we re-read multi_stop_state. */
- stop_machine_yield(cpumask);
newstate = READ_ONCE(msdata->state);
if (newstate != curstate) {
curstate = newstate;
@@ -243,15 +241,22 @@ static int multi_cpu_stop(void *data)
break;
}
ack_state(msdata);
- } else if (curstate > MULTI_STOP_PREPARE) {
- /*
- * At this stage all other CPUs we depend on must spin
- * in the same loop. Any reason for hard-lockup should
- * be detected and reported on their side.
- */
- touch_nmi_watchdog();
+
+ } else {
+ /* No state change, chill out */
+ stop_machine_yield(cpumask);
+ if (curstate > MULTI_STOP_PREPARE) {
+ /*
+ * At this stage all other CPUs we depend on
+ * must spin in the same loop. Any reason for
+ * hard-lockup should be detected and reported
+ * on their side.
+ */
+ touch_nmi_watchdog();
+ }
+ rcu_momentary_dyntick_idle();
}
- rcu_momentary_dyntick_idle();
+
} while (curstate != MULTI_STOP_EXIT);
local_irq_restore(flags);
--
2.45.1
Powered by blists - more mailing lists