Re: [RFC][PATCH 7/8] entry,hrtimer: Push reprogramming timers into the interrupt return path
From: Peter Zijlstra
Date: Tue Sep 23 2025 - 04:19:07 EST
On Tue, Sep 23, 2025 at 09:52:40AM +0200, Peter Zijlstra wrote:
> > 2) I came up with the following scenario, which is broken with this
> > delayed rearm.
> >
> > Assume this happens on the timekeeping CPU.
> >
> > hrtimer_interrupt()
> > expire_timers();
> > set(TIF_REARM);
> >
> > exit_to_user_mode_prepare()
> > handle_tif_muck()
> > ...
> > to = jiffies + 2;
> > while (!cond() && time_before(jiffies, to))
> > relax();
> >
> > If cond() does not become true for whatever reason, then this won't
> > make progress ever because the tick hrtimer which increments
> > jiffies is not happening.
> >
> > It can also be a wait on a remote CPU preventing progress
> > indirectly or a subtle dependency on a timer (timer list or
> > hrtimer) to expire.
> >
> > I have no idea whether that's related to the reported 0-day fallout,
> > but it definitely is a real problem lurking in the dark.
>
> Argh... that exit_to_user_mode_loop() thing enables IRQs. Yes, buggered
> something mighty.
>
> Let me haz a poke.
Bah. So schedule() is first in the TIF loop. Delaying hrtimer_rearm()
until that first schedule() call might just be enough, but that also
means running all of sched_submit_work() without timers... it might just
work, but urgh.
Let me try that anyway. I'll push it out to the robot, we'll see what
happens.