Re: [PATCH v2] scx: Fix raciness in scx_ops_bypass()

From: David Vernet
Date: Fri Oct 25 2024 - 16:58:26 EST


On Fri, Oct 25, 2024 at 10:43:53AM -1000, Tejun Heo wrote:
> Hello,
>
> This looks great overall. One nit below.
>
> On Fri, Oct 25, 2024 at 03:39:29PM -0500, David Vernet wrote:
> ...
> > static void scx_ops_bypass(bool bypass)
> > {
> > - int depth, cpu;
> > + int cpu;
> > + unsigned long flags;
> >
> > + raw_spin_lock_irqsave(&__scx_ops_bypass_lock, flags);
> > if (bypass) {
> > - depth = atomic_inc_return(&scx_ops_bypass_depth);
> > - WARN_ON_ONCE(depth <= 0);
> > - if (depth != 1)
> > - return;
> > + scx_ops_bypass_depth++;
> > + WARN_ON_ONCE(scx_ops_bypass_depth <= 0);
> > + if (scx_ops_bypass_depth != 1)
> > + goto unlock;
> > } else {
> > - depth = atomic_dec_return(&scx_ops_bypass_depth);
> > - WARN_ON_ONCE(depth < 0);
> > - if (depth != 0)
> > - return;
> > + scx_ops_bypass_depth--;
> > + WARN_ON_ONCE(scx_ops_bypass_depth < 0);
> > + if (scx_ops_bypass_depth != 0)
> > + goto unlock;
>
> Now that we know irq is disabled in the body, can you also please change
> rq_lock_irqsave() to rq_lock?

Ah good point, will send v3 shortly.

>
> Thanks.
>
> --
> tejun

Attachment: signature.asc
Description: PGP signature