mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Phil Auld <pauld@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Jon Kohler <jon@nutanix.com>, Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched: hoist ASSERT_EXCLUSIVE_WRITER(p->on_rq) above WRITE_ONCE
Date: Fri, 15 Nov 2024 09:26:58 -0500	[thread overview]
Message-ID: <20241115142658.GA837020@pauld.westford.csb> (raw)
In-Reply-To: <20241115095847.GV22801@noisy.programming.kicks-ass.net>

On Fri, Nov 15, 2024 at 10:58:47AM +0100 Peter Zijlstra wrote:
> On Thu, Nov 14, 2024 at 02:20:56PM -0500, Phil Auld wrote:
> 
> > I don't know. I don't think it matters much since the assert is really
> > independent of the actual write. Like I said it makes sense to have it
> > first to me but others may see it as just moving code around for no strong
> > reason.  Peter may or may not decide to pick this one up. Other "mis-ordered"
> > uses are in code maintained by different folks.
> > 
> > You can see if anyone else weighs in...
> 
> So I'm not entirely about this patch... :-)
>

I'm not entirely either :)


> Per commit b55945c500c5 ("sched: Fix pick_next_task_fair() vs try_to_wake_up() race")
> we can see that this placement is not equivalent.
>

Subtle. That kind of thing (someone else acting on the write) was my
hesitation but I couldn't quite wrap my head around it.

That's why we have other people weigh in ...

Thanks!

> Placing it before the store means that nobody else will store to it
> until you've done your store.
> 
> Placing it after means that nobody else will attempt the store,
> irrespective of the store you just did.

Presumably until some barrier or release at least, right?

I've got to dig into the kcsan stuff a bit more. It looks really
interesting.


Cheers,
Phil

> 
> That is, the ASSERT after the store is a stronger assert.
> 
> In case of activate_task(), we mark the task as on_rq, and this state is
> protected by rq->lock (which we hold), so there must not be any stores
> for as long as we hold that lock. So after is the right place.
> 
> In case of deactivate_task(), this is a hand-off, but the handoff
> doesn't happen until after dequeue_task() and set_task_cpu(). So at this
> point, again, nobody should be modifying it.
> 
> 

-- 


  reply	other threads:[~2024-11-15 14:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14 16:53 Jon Kohler
2024-11-14 18:57 ` Phil Auld
2024-11-14 19:01   ` Jon Kohler
2024-11-14 19:20     ` Phil Auld
2024-11-15  9:58       ` Peter Zijlstra
2024-11-15 14:26         ` Phil Auld [this message]
2024-11-15 17:28           ` Peter Zijlstra

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=20241115142658.GA837020@pauld.westford.csb \
    --to=pauld@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jon@nutanix.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®