From 56d4acf2c0ae90e8f96550137e1fd63b817f7260 Mon Sep 17 00:00:00 2001 From: David Vernet Date: Thu, 6 Jun 2024 14:04:10 -0500 Subject: [PATCH] scx: Flip order of scx_rq_{de}activate() Tejun pointed out that if we set or unset the hotplug online flag before we invoke the relevant hotplug callbacks, schedulers could get confused because they could begin receiving callbacks on a CPU before (or after) they're notified that a CPU is online (or offline). Let's reverse the order to fix that. Signed-off-by: David Vernet --- kernel/sched/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 33a7951df594..6161dd1928d4 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9777,6 +9777,8 @@ int sched_cpu_activate(unsigned int cpu) cpuset_cpu_active(); } + scx_rq_activate(rq); + /* * Put the rq online, if not already. This happens: * @@ -9792,7 +9794,6 @@ int sched_cpu_activate(unsigned int cpu) set_rq_online(rq); } rq_unlock_irqrestore(rq, &rf); - scx_rq_activate(rq); return 0; } @@ -9831,7 +9832,6 @@ int sched_cpu_deactivate(unsigned int cpu) */ synchronize_rcu(); - scx_rq_deactivate(rq); rq_lock_irqsave(rq, &rf); if (rq->rd) { BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); @@ -9839,6 +9839,8 @@ int sched_cpu_deactivate(unsigned int cpu) } rq_unlock_irqrestore(rq, &rf); + scx_rq_deactivate(rq); + #ifdef CONFIG_SCHED_SMT /* * When going down, decrement the number of cores with SMT present.