The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: tip-bot2 for Niels Pressel <tip-bot2@linutronix.de>,
	linux-tip-commits@vger.kernel.org,
	Niels Pressel <npressel@ethz.ch>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [tip: core/urgent] entry/rseq: Fix hard lockup on granted time slice extension
Date: Sat, 8 Aug 2026 10:36:35 +0200	[thread overview]
Message-ID: <20260808083635.GR687043@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <87y0ehmy3c.ffs@fw13>

On Fri, Aug 07, 2026 at 11:15:19PM +0200, Thomas Gleixner wrote:
> > @@ -132,6 +132,8 @@ static __always_inline bool __rseq_grant_slice_extension(bool work_pending)
> >  	union rseq_slice_state state;
> >  	struct rseq __user *rseq;
> >  
> > +	lockdep_assert_irqs_disabled();
> > +
> >  	if (!rseq_slice_extension_enabled())
> >  		return false;
> 
> Care to look what the code there does?
> 
> 	rseq = curr->rseq.usrptr;
> 	scoped_user_rw_access(rseq, efault) {
> 
> That's user access which requires interrupts to be enabled.

Well, you can do user access with IRQs disabled just fine, you just get
more efault. But yes, this one really wants the fault handler to page in
stuff if it is so needed.. Moo :-(

> Niels' original patch was correct.
> 
> To answer Peter's question from the V1 submission:
> 
> >> Thomas, previously we would call hrtimer_rearm_deferred() before
> >> re-enabling IRQs, but here it slipped past. And while disabling it will
> >> cure the splat, I'm thinking it makes sense to reflow
> >> __exit_to_user_mode_loop() to instead delay enabling IRQs.
> 
> Yes, but then we consolidated all the schedule() hrtimer interaction and
> got a benefit when schedule() was invoked directly on the way
> out. That's why we ended up moving into into the success path
> of rseq_grant_slice_extension() because that obviously skips schedule().
> 
> That's why we have hrtimer_rearm_deferred_user_irq() in
> __exit_to_user_mode_prepare() _before_ invoking exit_to_user_mode_loop()
> to ensure that one of the TIF_NEED_RESCHED bits is set. If not and if
> TIF_HRTIMER_REARM is set, then the rearming happens right there with
> interrupts still disabled.
> 
> If one of the TIF_NEED_RESCHED bits is set, then enabling interrupts
> right on top of the loop is safe because any interrupt/exception entry
> needs to check the bit as well.
> 
> So the thing [wm]e f*cked up royally was to invoke
> hrtimer_rearm_deferred_tif() with interrupts enabled and that needs to
> be fixed.
> 
> Of course all of this can be figured out from the copious amount of
> comments which got added to explain all of this magic.

Bah, its spread out over too damn many functions is what :/ Anyway, I
see you've not yet pulled the patch, let me go do that now.

  reply	other threads:[~2026-08-08  8:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 11:34 [PATCH v2] rseq: fix hard lockup on granted time slice extension Niels Pressel
2026-08-06 12:48 ` [tip: core/urgent] entry/rseq: Fix " tip-bot2 for Niels Pressel
2026-08-07 21:15   ` Thomas Gleixner
2026-08-08  8:36     ` Peter Zijlstra [this message]
2026-08-08 11:23       ` Thomas Gleixner

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=20260808083635.GR687043@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=npressel@ethz.ch \
    --cc=tglx@linutronix.de \
    --cc=tip-bot2@linutronix.de \
    --cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox