From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>,
pmladek@suse.com, john.ogness@linutronix.de, rostedt@goodmis.org,
senozhatsky@chromium.org, mingo@redhat.com, peterz@infradead.org,
juri.lelli@redhat.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, kprateek.nayak@amd.com,
akpm@linux-foundation.org, baoquan.he@linux.dev, rppt@kernel.org,
pasha.tatashin@soleen.com, pratyush@kernel.org,
ruirui.yang@linux.dev, david@kernel.org, ljs@kernel.org,
liam@infradead.org, vbabka@kernel.org, surenb@google.com,
mhocko@suse.com, kees@kernel.org, anna-maria@linutronix.de,
frederic@kernel.org, tglx@kernel.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, brendan.jackman@linux.dev,
hannes@cmpxchg.org, ziy@nvidia.com, bigeasy@linutronix.de,
clrkwllms@kernel.org
Cc: kexec@lists.infradead.org, linux-mm@kvack.org,
linux-trace-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 3/5] timers: Avoid blocking on hrtimer_cpu_base lock during Oops or panic
Date: Wed, 04 Nov 2026 02:49:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-196526@kernel.org> (raw)
In-Reply-To: <20261103024453.922373-4-atomlin@atomlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] timers: incomplete !CONFIG_SMP guard in print_active_timers()
--
commit 8e788faa0cf2d16ee117d7196f09432346eeda90
Author: Aaron Tomlin <atomlin@atomlin.com>
timers: Avoid blocking on hrtimer_cpu_base lock during Oops or panic
This commit switches sysrq_timer_list_show() to use ktime_get_mono_fast_ns()
and updates print_active_timers() to use raw_spin_trylock_irqsave() on
base->cpu_base->lock when in NMI, Oops, or panic contexts so that dumping
timer state does not deadlock if a CPU is holding a timekeeping or hrtimer
base lock.
> diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
> index 0406bf4488e9f..4973650c4ae5a 100644
> --- a/kernel/time/timer_list.c
> +++ 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);
> + }
[Severity: High]
In print_active_timers(), the outer check enters this branch when in_nmi(),
oops_in_progress, or panic_in_progress() is true, but the inner !CONFIG_SMP
check only tests in_nmi(). What happens on a !CONFIG_SMP build if an Oops or
panic occurs in non-NMI context while the CPU already holds
base->cpu_base->lock (for example, inside enqueue_hrtimer() or
__remove_hrtimer())?
When CONFIG_SMP=n and CONFIG_DEBUG_SPINLOCK=n, _raw_spin_trylock_irqsave()
unconditionally returns 1:
include/linux/spinlock_api_up.h:_raw_spin_trylock_irqsave() {
__LOCK_IRQSAVE(lock, *(flags));
return 1;
}
Wouldn't that allow print_active_timers() to re-enter the critical section
and walk base->active while the timerqueue is in a partially modified state?
And when CONFIG_SMP=n and CONFIG_DEBUG_SPINLOCK=y, since vpanic() invokes
sys_info() before debug_locks_off():
kernel/panic.c:vpanic() {
...
sys_info(panic_print);
kmsg_dump_desc(KMSG_DUMP_PANIC, buf);
if (_crash_kexec_post_notifiers)
__crash_kexec(NULL);
console_unblank();
debug_locks_off();
...
}
wouldn't do_raw_spin_trylock() hit SPIN_BUG_ON(!ret, lock, "trylock failure
on UP") when base->cpu_base->lock is already held?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103024453.922373-1-atomlin@atomlin.com?part=3
next prev parent reply other threads:[~2026-11-04 2:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 2:44 [RFC PATCH v2 0/5] panic, crash_core, sys_info: Introduce crash_kexec_in_memory_sys_info Aaron Tomlin
2026-11-03 2:44 ` [RFC PATCH v2 1/5] panic, sys_info: Fix duplicate and dropped all-CPU backtraces in panic Aaron Tomlin
2026-11-04 2:49 ` sashiko-bot
2026-11-03 2:44 ` [RFC PATCH v2 2/5] mm/show_mem: Avoid blocking on zone->lock during Oops or panic Aaron Tomlin
2026-11-04 2:49 ` sashiko-bot
2026-11-04 21:24 ` Aaron Tomlin
2026-11-03 2:44 ` [RFC PATCH v2 3/5] timers: Avoid blocking on hrtimer_cpu_base lock " Aaron Tomlin
2026-11-04 2:49 ` sashiko-bot [this message]
2026-11-03 2:44 ` [RFC PATCH v2 4/5] printk, tracing: Support console flush suppression and tail pinning Aaron Tomlin
2026-11-03 14:55 ` Steven Rostedt
2026-11-03 15:49 ` Aaron Tomlin
2026-11-04 2:49 ` sashiko-bot
2026-11-03 2:44 ` [RFC PATCH v2 5/5] panic, crash_core, sys_info: Introduce crash_kexec_in_memory_sys_info Aaron Tomlin
2026-11-04 2:49 ` sashiko-bot
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=sashiko-outbox-196526@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anna-maria@linutronix.de \
--cc=atomlin@atomlin.com \
--cc=baoquan.he@linux.dev \
--cc=bigeasy@linutronix.de \
--cc=brendan.jackman@linux.dev \
--cc=bsegall@google.com \
--cc=clrkwllms@kernel.org \
--cc=david@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=john.ogness@linutronix.de \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=kexec@lists.infradead.org \
--cc=kprateek.nayak@amd.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mgorman@suse.de \
--cc=mhiramat@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=pasha.tatashin@soleen.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=pratyush@kernel.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=ruirui.yang@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=senozhatsky@chromium.org \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=ziy@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.