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

From: Tejun Heo
Date: Fri Oct 25 2024 - 16:56:19 EST


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?

Thanks.

--
tejun