Skip to content

Commit d9e446d

Browse files
Changwoo Mingregkh
authored andcommitted
sched_ext: Replace rq_lock() to raw_spin_rq_lock() in scx_ops_bypass()
[ Upstream commit 6268d5b ] scx_ops_bypass() iterates all CPUs to re-enqueue all the scx tasks. For each CPU, it acquires a lock using rq_lock() regardless of whether a CPU is offline or the CPU is currently running a task in a higher scheduler class (e.g., deadline). The rq_lock() is supposed to be used for online CPUs, and the use of rq_lock() may trigger an unnecessary warning in rq_pin_lock(). Therefore, replace rq_lock() to raw_spin_rq_lock() in scx_ops_bypass(). Without this change, we observe the following warning: ===== START ===== [ 6.615205] rq->balance_callback && rq->balance_callback != &balance_push_callback [ 6.615208] WARNING: CPU: 2 PID: 0 at kernel/sched/sched.h:1730 __schedule+0x1130/0x1c90 ===== END ===== Fixes: 0e7ffff ("scx: Fix raciness in scx_ops_bypass()") Signed-off-by: Changwoo Min <[email protected]> Acked-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5b80f2f commit d9e446d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/sched/ext.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4348,10 +4348,9 @@ static void scx_ops_bypass(bool bypass)
43484348
*/
43494349
for_each_possible_cpu(cpu) {
43504350
struct rq *rq = cpu_rq(cpu);
4351-
struct rq_flags rf;
43524351
struct task_struct *p, *n;
43534352

4354-
rq_lock(rq, &rf);
4353+
raw_spin_rq_lock(rq);
43554354

43564355
if (bypass) {
43574356
WARN_ON_ONCE(rq->scx.flags & SCX_RQ_BYPASSING);
@@ -4367,7 +4366,7 @@ static void scx_ops_bypass(bool bypass)
43674366
* sees scx_rq_bypassing() before moving tasks to SCX.
43684367
*/
43694368
if (!scx_enabled()) {
4370-
rq_unlock(rq, &rf);
4369+
raw_spin_rq_unlock(rq);
43714370
continue;
43724371
}
43734372

@@ -4387,10 +4386,11 @@ static void scx_ops_bypass(bool bypass)
43874386
sched_enq_and_set_task(&ctx);
43884387
}
43894388

4390-
rq_unlock(rq, &rf);
4391-
43924389
/* resched to restore ticks and idle state */
4393-
resched_cpu(cpu);
4390+
if (cpu_online(cpu) || cpu == smp_processor_id())
4391+
resched_curr(rq);
4392+
4393+
raw_spin_rq_unlock(rq);
43944394
}
43954395
unlock:
43964396
raw_spin_unlock_irqrestore(&__scx_ops_bypass_lock, flags);

0 commit comments

Comments
 (0)