All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vernet <void@manifault.com>
To: Tejun Heo <tj@kernel.org>
Cc: sched-ext@meta.com, kernel-team@meta.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] scx: Fix raciness in scx_ops_bypass()
Date: Fri, 25 Oct 2024 15:48:02 -0500	[thread overview]
Message-ID: <20241025204802.GA24112@maniforge> (raw)
In-Reply-To: <ZxwDCUcyTABN8Exj@slm.duckdns.org>

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2024-10-25 20:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 20:39 [PATCH v2] scx: Fix raciness in scx_ops_bypass() David Vernet
2024-10-25 20:43 ` Tejun Heo
2024-10-25 20:48   ` David Vernet [this message]
2024-10-25 20:54   ` [PATCH v3] " David Vernet
2024-10-25 21:12     ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241025204802.GA24112@maniforge \
    --to=void@manifault.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@meta.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.