Skip to content

Commit 6268d5b

Browse files
Changwoo Minhtejun
authored andcommitted
sched_ext: Replace rq_lock() to raw_spin_rq_lock() in scx_ops_bypass()
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 <changwoo@igalia.com> Acked-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 30dd3b1 commit 6268d5b

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
@@ -4747,10 +4747,9 @@ static void scx_ops_bypass(bool bypass)
47474747
*/
47484748
for_each_possible_cpu(cpu) {
47494749
struct rq *rq = cpu_rq(cpu);
4750-
struct rq_flags rf;
47514750
struct task_struct *p, *n;
47524751

4753-
rq_lock(rq, &rf);
4752+
raw_spin_rq_lock(rq);
47544753

47554754
if (bypass) {
47564755
WARN_ON_ONCE(rq->scx.flags & SCX_RQ_BYPASSING);
@@ -4766,7 +4765,7 @@ static void scx_ops_bypass(bool bypass)
47664765
* sees scx_rq_bypassing() before moving tasks to SCX.
47674766
*/
47684767
if (!scx_enabled()) {
4769-
rq_unlock(rq, &rf);
4768+
raw_spin_rq_unlock(rq);
47704769
continue;
47714770
}
47724771

@@ -4786,10 +4785,11 @@ static void scx_ops_bypass(bool bypass)
47864785
sched_enq_and_set_task(&ctx);
47874786
}
47884787

4789-
rq_unlock(rq, &rf);
4790-
47914788
/* resched to restore ticks and idle state */
4792-
resched_cpu(cpu);
4789+
if (cpu_online(cpu) || cpu == smp_processor_id())
4790+
resched_curr(rq);
4791+
4792+
raw_spin_rq_unlock(rq);
47934793
}
47944794

47954795
atomic_dec(&scx_ops_breather_depth);

0 commit comments

Comments
 (0)