Re: [PATCH] sched/ext: Suppress warning in __this_cpu_write() by disabling preemption

From: Andrea Righi
Date: Wed Jul 16 2025 - 12:14:58 EST


On Wed, Jul 16, 2025 at 09:08:36AM -0700, Breno Leitao wrote:
> On Wed, Jul 16, 2025 at 04:26:23PM +0200, Andrea Righi wrote:
> > On Wed, Jul 16, 2025 at 03:36:31PM +0200, Peter Zijlstra wrote:
> > > On Wed, Jul 16, 2025 at 03:15:12PM +0200, Andrea Righi wrote:
> > >
> > > > The idea is to track the scx callbacks that are invoked with a rq lock held
> > > > and, in those cases, store the locked rq. However, some callbacks may also
> > > > be invoked from an unlocked context, where no rq is locked and in this case
> > > > rq should be NULL.
> > > >
> > > > In the latter case, it's acceptable for preemption to remain enabled, but
> > > > we still want to explicitly set locked_rq = NULL. If during the execution
> > > > of the callback we jump on another CPU, it'd still be in an unlocked state,
> > > > so it's locked_rq is still NULL.
> > >
> > > Right; but doing superfluous NULL stores seems pointless. So better to
> > > avoid the store entirely, rather than making it more expensive and no
> > > less pointless, right?
> >
> > Right, we can definitely avoid rewriting NULL.
> > The following should do the trick.
> >
> > Breno, can you give it a try?
>
> Sure thing. I've tested it and I don't see the warning on my side.
>
> Would you like to me post the patch, probably removing the WARN_ONCE()
> as raised by peterz?

Sure, go ahead. Yes, let's remove the WARN_ON_ONCE().
And thanks Peter for all the suggestions!

-Andrea