From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
linuxppc-dev@lists.ozlabs.org
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
Venkat Rao Bagalkote <venkat88@linux.ibm.com>,
linux-kernel@vger.kernel.org, chleroy@kernel.org,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Mukesh Kumar Chaurasiya <mkchauras@gmail.com>,
stable@vger.kernel.org
Subject: Re: [PATCHv2 2/4] powerpc/watchdog: Disable preemption in arch_touch_nmi_watchdog()
Date: Tue, 17 Nov 2026 21:13:38 +0530 [thread overview]
Message-ID: <4b5c9a61-5876-4508-87a2-5451d363a181@linux.ibm.com> (raw)
In-Reply-To: <3cb2893bf883be87ea1c3712344ac03f727937d0.1794924821.git.ritesh.list@gmail.com>
On 11/17/26 7:55 PM, Ritesh Harjani (IBM) wrote:
> touch_nmi_watchdog() can be called from preemptible context, e.g.
> sysrq-w via /proc/sysrq-trigger. The powerpc implementation uses
> smp_processor_id(), so with DEBUG_PREEMPT we get:
>
> root@buildroot:/# echo w > /proc/sysrq-trigger
> sysrq: Show Blocked State
> BUG: using smp_processor_id() in preemptible [00000000] code: bash/238
> caller is arch_touch_nmi_watchdog+0x3c/0xd4
> CPU: 0 UID: 0 PID: 238 Comm: bash Not tainted 7.4.0-rc2-00029-g7664547149ae-dirty #126 PREEMPT
> Call Trace:
> dump_stack_lvl+0x138/0x150 (unreliable)
> check_preemption_disabled+0x120/0x158
> arch_touch_nmi_watchdog+0x3c/0xd4
> show_state_filter+0xf0/0x338
> sysrq_handle_showstate_blocked+0x24/0x38
> __handle_sysrq+0x134/0x3a8
> write_sysrq_trigger+0x178/0x22c
> proc_reg_write+0xf4/0x150
> vfs_write+0xfc/0x71c
> ksys_write+0x8c/0x150
> system_call_exception+0x310/0x590
> system_call_vectored_common+0x15c/0x2ec
> ---- interrupt: 3000 at 0x7ffd01755b98
>
> Unlike the generic version, which only sets a flag, we update the CPU's
> timebase stamp and its SMP watchdog pending bit, so a migration in
> between touches the state of a CPU we are no longer on.
>
> Disable preemption across the update. While at it, let's also mark the
> function as notrace (since we might be within a tracer when this
> function gets called).
>
> Fixes: 2104180a5369 ("powerpc/64s: implement arch-specific hardlockup watchdog")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
> arch/powerpc/kernel/watchdog.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
> index 44f178e07531..32d4e716cb0a 100644
> --- a/arch/powerpc/kernel/watchdog.c
> +++ b/arch/powerpc/kernel/watchdog.c
> @@ -456,12 +456,16 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
> return HRTIMER_RESTART;
> }
>
> -void arch_touch_nmi_watchdog(void)
> +notrace void arch_touch_nmi_watchdog(void)
> {
> unsigned long ticks = tb_ticks_per_usec * wd_timer_period_ms * 1000;
> - int cpu = smp_processor_id();
> + int cpu;
> u64 tb;
>
> + /* Callers may be preemptible. Stay on this CPU for the update. */
> + guard(preempt_notrace)();
> + cpu = raw_smp_processor_id();
> +
> if (!cpumask_test_cpu(cpu, &watchdog_cpumask))
> return;
>
> --
> 2.39.5
>
next prev parent reply other threads:[~2026-11-17 15:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 14:25 [PATCHv2 0/4]: powerpc: Misc fixes for debug kernel splats Ritesh Harjani (IBM)
2026-11-17 14:25 ` [PATCHv2 1/4] powerpc/64: Leave lockdep hardirq context around replayed interrupts Ritesh Harjani (IBM)
2026-11-17 15:52 ` Christophe Leroy (CS GROUP)
2026-11-17 14:25 ` [PATCHv2 2/4] powerpc/watchdog: Disable preemption in arch_touch_nmi_watchdog() Ritesh Harjani (IBM)
2026-11-17 15:43 ` Shrikanth Hegde [this message]
2026-11-17 14:25 ` [PATCHv2 3/4] powerpc/kvm-hv-pmu: Don't allocate gsm/gsb GFP_KERNEL allocations under spinlock Ritesh Harjani (IBM)
2026-11-17 14:25 ` [PATCHv2 4/4] powerpc/kvm-hv-pmu: Free hostwide stats buffers if perf_pmu_register() fails Ritesh Harjani (IBM)
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=4b5c9a61-5876-4508-87a2-5451d363a181@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mkchauras@gmail.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=ritesh.list@gmail.com \
--cc=stable@vger.kernel.org \
--cc=venkat88@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®