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

From: zhidao su

Date: Fri Mar 06 2026 - 07:52:55 EST


From: Su Zhidao <suzhidao@xxxxxxxxxx>

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.

Signed-off-by: Su Zhidao <suzhidao@xxxxxxxxxx>
---
kernel/sched/ext.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 053d99c58802..c269e489902c 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -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;

--
2.43.0