[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250716-scx_warning-v1-1-0e814f78eb8c@debian.org>
Date: Wed, 16 Jul 2025 05:46:15 -0700
From: Breno Leitao <leitao@...ian.org>
To: Tejun Heo <tj@...nel.org>, David Vernet <void@...ifault.com>,
Andrea Righi <arighi@...dia.com>, Changwoo Min <changwoo@...lia.com>,
Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>,
Mel Gorman <mgorman@...e.de>, Valentin Schneider <vschneid@...hat.com>
Cc: sched-ext@...ts.linux.dev, linux-kernel@...r.kernel.org,
kernel-team@...a.com, jake@...lion.co.uk, Breno Leitao <leitao@...ian.org>
Subject: [PATCH] sched/ext: Suppress warning in __this_cpu_write() by
disabling preemption
__this_cpu_write() emits a warning if used with preemption enabled.
Function update_locked_rq() might be called with preemption enabled,
which causes the following warning:
BUG: using __this_cpu_write() in preemptible [00000000] code: scx_layered_6-9/68770
Disable preemption around the __this_cpu_write() call in
update_locked_rq() to suppress the warning, without affecting behavior.
If preemption triggers a jump to another CPU during the callback it's
fine, since we would track the rq state on the other CPU with its own
local variable.
Suggested-by: Andrea Righi <arighi@...dia.com>
Signed-off-by: Breno Leitao <leitao@...ian.org>
Fixes: 18853ba782bef ("sched_ext: Track currently locked rq")
Acked-by: Andrea Righi <arighi@...dia.com>
---
kernel/sched/ext.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index b498d867ba210..24fcbd7331f73 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1258,7 +1258,14 @@ static inline void update_locked_rq(struct rq *rq)
*/
if (rq)
lockdep_assert_rq_held(rq);
+ /*
+ * __this_cpu_write() emits a warning when used with preemption enabled.
+ * While there's no functional issue if the callback runs on another
+ * CPU, we disable preemption here solely to suppress that warning.
+ */
+ preempt_disable();
__this_cpu_write(locked_rq, rq);
+ preempt_enable();
}
/*
---
base-commit: 155a3c003e555a7300d156a5252c004c392ec6b0
change-id: 20250716-scx_warning-5143cf17f806
Best regards,
--
Breno Leitao <leitao@...ian.org>
Powered by blists - more mailing lists