Skip to contentSkip to conversation

sched_ext: Use rcu_dereference_bh() in scx_bypass_lb_timerfn()

PATCH In review zhidao su 1 participant 1 message Mar 6

Subsystems (3)
lore
Share & tools
lore

zhidao su

author
#0 lore raw

PATCH 3/5 sched_ext: Use rcu_dereference_bh() in scx_bypass_lb_timerfn()

From: Su Zhidao <[email protected]>

scx_bypass_lb_timerfn() runs in softirq (BH) context, so rcu_dereference_bh() is the correct RCU accessor. The previous rcu_dereference_all() suppresses all sparse warnings and masks potential RCU context issues.

Add a comment noting this is a transitional state: when multi-scheduler support lands, the bypass LB timer will become per-scheduler and the global scx_root reference will be removed.

---
 kernel/sched/ext.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/sched/ext.c +7 -1
index 053d99c58802..c269e489902c 100644
@@ -4170,7 +4170,13 @@ static void scx_bypass_lb_timerfn(struct timer_list *timer)
 	int node;
 	u32 intv_us;
 
-	sch = rcu_dereference_all(scx_root);
+	/*
+	 * scx_bypass_lb_timer is a global timer that fires in softirq
+	 * context while bypass mode is active. Use rcu_dereference_bh()
+	 * matching the BH context. When multi-scheduler support lands,
+	 * this timer will become per-scheduler instance.
+	 */
+	sch = rcu_dereference_bh(scx_root);
 	if (unlikely(!sch) || !READ_ONCE(scx_bypass_depth))
 		return;
 
Signature · 1 line
2.43.0