mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Gabriele Monaco <gmonaco@redhat.com>
Cc: Sechang Lim <rhkrqnwk98@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	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>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] sched: set TIF_NEED_RESCHED before calling __trace_set_need_resched()
Date: Tue, 29 Sep 2026 11:30:11 +0200	[thread overview]
Message-ID: <aruFI9rG45Xtmxeo@gpd4> (raw)
In-Reply-To: <96b3b5d5ec0eae499f1a98845720776b6fab84d4.camel@redhat.com>

Hi Gabriele,

On Tue, Sep 29, 2026 at 10:50:48AM +0200, Gabriele Monaco wrote:
> Hi Andrea,
> 
> On Mon, 2026-09-28 at 19:19 +0200, Andrea Righi wrote:
> > This leaves the race Prateek described in the v2 discussion: a remote CPU sets
> > TIF_NEED_RESCHED under rq->lock, but the target CPU can emit sched_entry_tp()
> > before acquiring that lock, ahead of the need-resched tracepoint.
> > 
> > I reproduced it with this applied to tip/master. With the RV nrp monitor
> > enabled, 300 runs of "perf bench sched messaging -g 20 -l 100" produced:
> > 
> >   rv: monitor nrp does not allow event schedule_entry_preempt on state
> > any_thread_running
> > 
> > Applying the following on top fixed the ordering, the same 300-run test then
> > completed without an RV violation. If it makes sense, could you fold this
> > change into v4?
> > 
> > Thanks,
> > -Andrea
> 
> thanks for looking into this. Is this change required for anything else besides
> fixing the nrp monitor after changing the order with need_resched?

No, I was mainly trying to help get this fix upstream: a sched_ext kselftest I'm
working on hits that issue and I'm holding off on submitting the test until the
fix lands. Moving sched_entry was only my attempt to address the nrp warning I
saw while testing the fix.

> 
> I believe this would break the sts monitor which expects sched_entry before
> disabling interrupts.
> 
> Both monitors could be adapted to either case, but if your change is just for
> the sake of nrp, I think it's easier to just allow this race, since nrp is
> already allowing the race with interrupts.
> I haven't tested yet, but something like allowing a sched_entry_preempt without
> need_resched set but provided it's going to be set before sched_exit would
> probably do (it'd allow also independent need_resched there, but those will then
> need their own preemption too).
> 
> I'd say if you don't need to move sched_entry for other reasons we can wait to
> apply this change until I see what's better for the models.

That makes sense, we can ignore the sched_entry change for now. With that,
Sechang's fix looks good to me.

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

      reply	other threads:[~2026-09-29  9:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30  8:47 Sechang Lim
2026-07-03 15:33 ` Gabriele Monaco
2026-09-28 17:19 ` Andrea Righi
2026-09-29  8:50   ` Gabriele Monaco
2026-09-29  9:30     ` Andrea Righi [this message]

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=aruFI9rG45Xtmxeo@gpd4 \
    --to=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gmonaco@redhat.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rhkrqnwk98@gmail.com \
    --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®