From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
Mukesh Kumar Chaurasiya <mkchauras@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Venkat Rao Bagalkote <venkat88@linux.ibm.com>,
linux-kernel@vger.kernel.org,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
stable@vger.kernel.org
Subject: Re: [PATCHv3 2/4] powerpc/watchdog: Disable preemption in arch_touch_nmi_watchdog()
Date: Sat, 28 Nov 2026 18:37:29 +0530 [thread overview]
Message-ID: <33slw1da.ritesh.list@gmail.com> (raw)
In-Reply-To: <jylzkbvr.ritesh.list@gmail.com>
Hi Christophe,
Ritesh Harjani (IBM) <ritesh.list@gmail.com> writes:
> "Christophe Leroy (CS GROUP)" <chleroy@kernel.org> writes:
>
>> Le 25/11/2026 à 10:58, Ritesh Harjani a écrit :
>>> Mukesh Kumar Chaurasiya <mkchauras@gmail.com> writes:
>>>
>>>> On Mon, Nov 23, 2026 at 07:21:51PM +0530, 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).
>>>> Do we need to also mark wd_smp_clear_cpu_pending as notrace?
>>>>
>>>
>>> aah yes, I didn't see that there is another function which is not
>>> inlined. Thanks for spotting that. The reason I added "notrace" was
>>> mainly to have consistency with kernel/watchdog.c which is due to this
>>> commit:
>>>
>>> cb9d7fd51d9f ("watchdog: Mark watchdog touch functions as notrace")
>>>
>>>
>>> However, after looking more closely now, I don't think we need notrace
>>> here at all. To simply put, on powerpc, we don't use stop_machine() from
>>> within arch_ftrace_update_code() like how arch/arm does and besides, I
>>> think it is even safe for one cpu to be executing the instruction on
>>> powerpc, while another cpu modifying that atomically.
>>
>> But haven't we identified in another discussion that it might be needed
>> to use stop_machine() ? See
>> https://lore.kernel.org/all/qzh06fxn.ritesh.list@gmail.com/
>>
>
> Yes, that is why I also quoted second reason too on why we don't need it
> on powerpc. But here is the detailed explaination of what I understood -
> while looking at the history of changes on why "notrace" was added to
> some arch (like arm or to the generic definition) in the first place.
>
> On ARM, ftrace call sites were patched under stop_machine() and the code
> used to rely on other CPUs not executing any call site meanwhile. (Note
> that this itself is not needed on PowerPC see commit ee456bb346e7).
> However, with a THUMB-2 instruction set on ARM, a 4byte instruction is
> only 2 byte aligned, so while patching the instruction it can result
> into a 2 x 16bit stores. Now after commit ce4f06dcbb5d ("stop_machine:
> Touch_nmi_watchdog() after MULTI_STOP_PREPARE"), stopped cpus started
> calling the watchdog touch functions (which were not marked notrace yet)
> from multi_cpu_stop(), so a stopped cpu could therefore execute the
> ftrace call site of those functions between the two stores. This
> resulted into kernel crashes as seen on ARM while enabling/disabling
> ftrace on ARM kernels built with THUMB-2 instruction set.
> Therefore commit cb9d7fd51d9f ("watchdog: Mark watchdog touch functions
> as notrace") was needed on ARM to fix these crashes.
>
> So I still think we don't need a "notrace" on arch_touch_nmi_watchdog()
> on powerpc, even if tomorrow, we extend the use of stop_machine() for
> patching usecase, as we discussed on that other thread.
>
Just wondering if this answer your concerns? I see that others have
provided their Tested-by on v4 of this patch series. If that looks ok to
you - I was hoping if we could get that series queued up in powerpc's
next. Thoughts?
-ritesh
next prev parent reply other threads:[~2026-11-28 13:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:51 [PATCHv3 0/4] powerpc: Misc fixes for debug kernel splats Ritesh Harjani (IBM)
2026-11-23 13:51 ` [PATCHv3 1/4] powerpc/64: Leave lockdep hardirq context around replayed interrupts Ritesh Harjani (IBM)
2026-11-25 5:19 ` Mukesh Kumar Chaurasiya
2026-11-23 13:51 ` [PATCHv3 2/4] powerpc/watchdog: Disable preemption in arch_touch_nmi_watchdog() Ritesh Harjani (IBM)
2026-11-25 5:50 ` Mukesh Kumar Chaurasiya
2026-11-25 9:58 ` Ritesh Harjani
2026-11-26 10:13 ` Christophe Leroy (CS GROUP)
2026-11-26 12:36 ` Ritesh Harjani
2026-11-28 13:07 ` Ritesh Harjani [this message]
2026-11-23 13:51 ` [PATCHv3 3/4] powerpc/kvm-hv-pmu: Don't allocate gsm/gsb GFP_KERNEL allocations under spinlock Ritesh Harjani (IBM)
2026-11-25 5:53 ` Mukesh Kumar Chaurasiya
2026-11-27 10:04 ` Gautam Menghani
2026-11-23 13:51 ` [PATCHv3 4/4] powerpc/kvm-hv-pmu: Free hostwide stats buffers if perf_pmu_register() fails Ritesh Harjani (IBM)
2026-11-25 5:58 ` Mukesh Kumar Chaurasiya
2026-11-25 9:48 ` Ritesh Harjani
2026-11-27 10:05 ` Gautam Menghani
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=33slw1da.ritesh.list@gmail.com \
--to=ritesh.list@gmail.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=sshegde@linux.ibm.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