[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250716130652.GB3429938@noisy.programming.kicks-ass.net>
Date: Wed, 16 Jul 2025 15:06:52 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Breno Leitao <leitao@...ian.org>, 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>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Valentin Schneider <vschneid@...hat.com>, sched-ext@...ts.linux.dev,
linux-kernel@...r.kernel.org, kernel-team@...a.com,
jake@...lion.co.uk
Subject: Re: [PATCH] sched/ext: Suppress warning in __this_cpu_write() by
disabling preemption
On Wed, Jul 16, 2025 at 08:54:47AM -0400, Steven Rostedt wrote:
> On Wed, 16 Jul 2025 05:46:15 -0700
> Breno Leitao <leitao@...ian.org> wrote:
>
> > __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);
>
> <blink>
>
> If an rq lock is expected to be held, there had better be no preemption
> enabled. How is this OK?
The rq=NULL case; but from the usage I've seen that also happens with
rq lock held.
Specifically I think the check ought to be:
if (rq)
lockdep_assert_rq_held(rq)
else
lockdep_assert_rq_held(__this_cpu_read(locked_rq));
Powered by blists - more mailing lists