[RFC PATCH v2 3/5] timers: Avoid blocking on hrtimer_cpu_base lock during Oops or panic
Aaron Tomlin
atomlin at atomlin.com
Mon Nov 16 06:40:43 PST 2026
On Mon, Nov 09, 2026 at 11:28:01PM +0100, Thomas Gleixner wrote:
> > +++ b/kernel/time/timer_list.c
> > @@ -68,7 +68,15 @@ static void print_active_timers(struct seq_file *m, struct hrtimer_clock_base *b
> >
> > touch_nmi_watchdog();
> >
> > - raw_spin_lock_irqsave(&base->cpu_base->lock, flags);
> > + if (in_nmi() || oops_in_progress || panic_in_progress()) {
> > + if ((!IS_ENABLED(CONFIG_SMP) && in_nmi()) ||
> > + !raw_spin_trylock_irqsave(&base->cpu_base->lock, flags)) {
> > + SEQ_printf(m, " [cpu_base lock contended]\n");
> > + return;
> > + }
> > + } else {
> > + raw_spin_lock_irqsave(&base->cpu_base->lock, flags);
> > + }
>
> TBH, that's horrible and unreadable gunk.
>
> Clearly the approach of all of this is:
>
> 1) Pick some existing code
> 2) Invoke it
> 3) Hope that it works
> 4) If not add bandaids to make it "work"
>
> Seriously?
>
> Each of the callers of sys_info() knows the exact context in which it is
> invoked, right?
>
> So the obvious and clean solution is to hand exactly that context
> information into sys_info() and further down into the invoked
> functions so they can make informed decisions and eventually omit
> pointless information which is otherwise emitted in proc/sysrq-t.
>
> Something like the uncompiled mockup below should give you an idea.
Hi Thomas,
Fair point. Probing global state ad hoc inside individual helpers is much
uglier than passing the caller's execution context explicitly. There are
only a handful of sys_info() call sites in the tree, each of which already
knows its exact context.
For the next iteration, I will introduce enum sysinfo_context, plumb it
through sys_info() down to the consumers, and refactor
kernel/time/timer_list.c around struct tlctx and lock_hrtimer_base() along
the lines of your mockup.
Kind regards,
--
Aaron Tomlin
More information about the kexec
mailing list