The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: tip-bot2 for Niels Pressel <tip-bot2@linutronix.de>,
	linux-tip-commits@vger.kernel.org
Cc: Niels Pressel <npressel@ethz.ch>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [tip: core/urgent] entry/rseq: Fix hard lockup on granted time slice extension
Date: Fri, 07 Aug 2026 23:15:19 +0200	[thread overview]
Message-ID: <87y0ehmy3c.ffs@fw13> (raw)
In-Reply-To: <178602048581.708.11608729612787939146.tip-bot2@tip-bot2>

On Thu, Aug 06 2026 at 12:48, tip-bot wrote:
> In __exit_to_user_mode_loop(), TSE eligibility is checked while
> IRQs are enabled. Granting a TSE might involve rearming the
> hrtimers. However, hrtimer_rearm_deferred_tif() is expected to be
> called with IRQs disabled (see include/linux/hrtimer_rearm.h:17).

Groan. Can people please use proper words and not random made up
acronyms. This is not a SMS service. And this file reference is
more than pointless.

> Following the suggestion from Peter Zijlstra, fix this potential lockup
> by reflowing __exit_to_user_mode_loop() to only enable IRQs after the
> TSE check.

Which is broken.

> @@ -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.
  
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.

Thanks,

        tglx

  reply	other threads:[~2026-08-07 21:15 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 [this message]
2026-08-08  8:36     ` Peter Zijlstra
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=87y0ehmy3c.ffs@fw13 \
    --to=tglx@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=npressel@ethz.ch \
    --cc=peterz@infradead.org \
    --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