From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A55A6606A31C for ; Sun, 29 Nov 2026 11:23:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DT1sciqU Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jclBW509Sz2y2T; Sun, 29 Nov 2026 22:22:59 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.105.4.254 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1795951379; cv=none; b=VV40rTrGkQ+SD5UTydZbHM9j9zbXOwbq7Eqku1SrjDTTm7S/Eogi/qKQEJbJ+M1VxQkTd2QpmzS73QbnbLAabZxPhJfUwoTBDzuG4g3tVCGgo4ZgdUU0Zd0e7rRV7hR9eog19fSy+5wM4fP59czL+sjBL6gitP3YqaQb3u4AOjRdONedLJ6aiLIOhocssEBnLQDnOIDwskKGPqy/0Mrg4q46+4PMozSVIWNPXq458TwDBJGRyAuQiRyr16ZL/6hoHl3r6uhCpodCqyFPK/YS7iDs6kG0ImhPMOFDJuJQx1ZkbbEBCWWxsX7Zv1vevIQ4DVcNr4ziRtT2K89xjPRQSQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1795951379; c=relaxed/relaxed; bh=6qT08H10VeDi7/qCk/+kj8I3OD0qOLCPfKashb/lo7Y=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jHXT85KzW5hFhwIxmbnYzPLftZ37I97OMpG1fK4gIE+dTBcCpCxCoEwxHP7yMRM3UPXSEIHv1WrYe2mTtEDr5iGicKJwGhDVrBQnhvLHH+yNpBK21xXrVa/K/GD66fIoiONhJb6F/wh1VwmxON45kvOnVBp+k/lf+2yZeEpE7oMAHcwb/8IsNaTNOtcn1DAZM5pfBidOPxO69XB7oPpW7a4shRLdlKY4T7qxkal9WaiO+GEYkQH46PQ8b3cvnPatUdznDavEHjx/sBfFhbXhCGZJew/dfsnLYyGT7qkPGKJ/nddxLrOLU1t54aL7VJoWDXMavd8NCp+TPNsmleXW5Q== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DT1sciqU; dkim-atps=neutral; spf=pass (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=chleroy@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DT1sciqU; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=chleroy@kernel.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jclBV5gd7z2xLt for ; Sun, 29 Nov 2026 22:22:58 +1100 (AEDT) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id F13FA611AA; Sun, 29 Nov 2026 11:22:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC3C21F000C1; Sun, 29 Nov 2026 11:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795951375; bh=6qT08H10VeDi7/qCk/+kj8I3OD0qOLCPfKashb/lo7Y=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=DT1sciqUcpxVyO6fafEH8Cc9sTAMw0AzB3j2H8RRsRF8MjkcucL+efqwesT0nRrNv OpC/9+Pk4FvAzNFyzPJswnYNy0Yh34+qvHJO/2xV50+XHnQVSlqg8TdTVk3PBEOZTH tS8niBJZGM2uKrPLmou7oRPS+4JlqerDbZHzSjtDe4sT8ZXMspVT0kyYABlgvK8l0s ehfJiybt9VilKg5j/FtdeJkUsf4MztB7f3prKbp+N+K2YWMJf4Qzu33Xxd4gokOepY x8VrN9YGf1y12CnY0GeSf47qLai7f70oEx/zuEGuLwPUYggXvGvDW7JBwMRQYJXuWg 8cihmli7gOgoQ== Message-ID: <937939b6-5762-4ec3-a650-6942e5cf61bf@kernel.org> Date: Sun, 29 Nov 2026 12:22:49 +0100 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv3 2/4] powerpc/watchdog: Disable preemption in arch_touch_nmi_watchdog() To: "Ritesh Harjani (IBM)" , Mukesh Kumar Chaurasiya Cc: linuxppc-dev@lists.ozlabs.org, Madhavan Srinivasan , Venkat Rao Bagalkote , linux-kernel@vger.kernel.org, Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , stable@vger.kernel.org References: <8a70fa42449a63a73b8340d3296974cc519b5826.1795441238.git.ritesh.list@gmail.com> <76a1d48f-7425-4cd9-a88b-dbb453c6f95c@kernel.org> <33slw1da.ritesh.list@gmail.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <33slw1da.ritesh.list@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Ritesh, Le 28/11/2026 à 14:07, Ritesh Harjani a écrit : > > Hi Christophe, > > Ritesh Harjani (IBM) writes: > >> "Christophe Leroy (CS GROUP)" writes: >> >>> Le 25/11/2026 à 10:58, Ritesh Harjani a écrit : >>>> Mukesh Kumar Chaurasiya 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://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2Fqzh06fxn.ritesh.list%40gmail.com%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7Ca7e4473668e84432906208df4d51244b%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639314683044236632%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=C0E9zD2jpQQUZaWl9COwKyiqLGupuxRB9XlvH0uWjVo%3D&reserved=0 >>> >> >> 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? Yes your response makes sense, i'm fine with it. Christophe