[PATCH 07/17] sched/core: Set balance_callback only if CPU is dying

Srikar Dronamraju srikar at linux.ibm.com
Fri Dec 5 04:53:55 AEDT 2025


Scheduler is suppose to set balance_callback to push tasks out of a
dying CPU. However the current code, unilaterally sets the balance_cpu
and then checks if the CPU is indeed dying.

Remove this anomaly by setting balance_callback only after checking if
the CPU is about to die.

Signed-off-by: Srikar Dronamraju <srikar at linux.ibm.com>
---
 kernel/sched/core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f754a60de848..89efff1e1ead 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8173,11 +8173,6 @@ static void balance_push(struct rq *rq)
 
 	lockdep_assert_rq_held(rq);
 
-	/*
-	 * Ensure the thing is persistent until balance_push_set(.on = false);
-	 */
-	rq->balance_callback = &balance_push_callback;
-
 	/*
 	 * Only active while going offline and when invoked on the outgoing
 	 * CPU.
@@ -8185,6 +8180,11 @@ static void balance_push(struct rq *rq)
 	if (!cpu_dying(rq->cpu) || rq != this_rq())
 		return;
 
+	/*
+	 * Ensure the thing is persistent until balance_push_set(.on = false);
+	 */
+	rq->balance_callback = &balance_push_callback;
+
 	/*
 	 * Both the cpu-hotplug and stop task are in this case and are
 	 * required to complete the hotplug process.
-- 
2.43.7



More information about the Linuxppc-dev mailing list