From: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
linuxppc-dev@lists.ozlabs.org
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
linux-kernel@vger.kernel.org, chleroy@kernel.org,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Mukesh Kumar Chaurasiya <mkchauras@gmail.com>,
stable@vger.kernel.org,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: [PATCHv4 1/4] powerpc/64: Leave lockdep hardirq context around replayed interrupts
Date: Wed, 25 Nov 2026 18:15:36 +0530 [thread overview]
Message-ID: <1b75e490-78c7-48a2-b59d-9eec953a0335@linux.ibm.com> (raw)
In-Reply-To: <6a02babe73f316616cf829af3ddbbfc61fb4066a.1795603946.git.ritesh.list@gmail.com>
On 25/11/26 4:56 pm, Ritesh Harjani (IBM) wrote:
> With PROVE_LOCKING, boot warns once and lockdep turns itself off:
> DEBUG_LOCKS_WARN_ON(lockdep_hardirq_context())
> WARNING: kernel/locking/lockdep.c:4448 at lockdep_hardirqs_on_prepare+0x22c/0x2d4, CPU#0: swapper/0/0
> CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.4.0-rc2-00027-g074831f06e18-dirty #123 PREEMPT
> NIP: c0000000002b2f2c LR: c0000000002b2f28 CTR: c000000002426f90
> REGS: c000000004f075c0 TRAP: 0700 Not tainted (7.4.0-rc2-00027-g074831f06e18-dirty)
> MSR: 8000000002021033 <SF,VEC,ME,IR,DR,RI,LE> CR: 48022221 XER: 20040000
> NIP [c0000000002b2f2c] lockdep_hardirqs_on_prepare+0x22c/0x2d4
> LR [c0000000002b2f28] lockdep_hardirqs_on_prepare+0x228/0x2d4
> Call Trace:
> lockdep_hardirqs_on_prepare+0x228/0x2d4 (unreliable)
> trace_hardirqs_on+0x98/0x11c
> irqentry_exit+0x64c/0x1064
> timer_interrupt+0x274/0x6bc
> __replay_soft_interrupts+0x158/0x380
> arch_local_irq_restore+0x1cc/0x244
> console_flush_one_record+0x438/0x654
> console_unlock+0xb8/0x1e0
> vprintk_emit+0x300/0x56c
> vprintk+0x20/0x34
> _printk+0x40/0x54
> lockdep_init+0xdc/0x104
>
> The warning is triggered because trace_hardirqs_on() gets called while
> lockdep's hardirq_context still says we are handling an interrupt. To
> fix that, we need to ensure lockdep's hardirq_context and
> hardirqs_enabled state stays consistent with powerpc's soft-masked
> interrupt replay code and the generic entry/exit code.
>
> With the current change, this is how the new state machine looks like:
> hardirq_context hardirqs_enabled
> arch_local_irq_restore()
> trace_hardirqs_off() 0 1 -> 0
> irq_enter() 0 -> 1 0 (softirqs held off)
> __replay_soft_interrupts()
> lockdep_hardirq_exit() 1 -> 0 0 patch: the loop is not a handler
> timer_interrupt(®s)
> irq_enter_rcu() 0 -> 1 0 handler starts
> irq_exit_rcu() 1 -> 0 0 handler done
> irqentry_exit()
> trace_hardirqs_on() 0 0 -> 1 legal: context is 0
> next_interrupt()
> trace_hardirqs_off() 0 1 -> 0 still replaying: back to off
> ... same for each pending interrupt
> lockdep_hardirq_enter() 0 -> 1 0 patch: restore for the caller
> irq_exit() 1 -> 0 0 softirqs may run now
> trace_hardirqs_on() 0 0 -> 1 IRQs really enabled
>
> Fixes: bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature")
> Cc: stable@vger.kernel.org
> Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
> Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
> Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Closes: https://lore.kernel.org/linuxppc-dev/b44aefc5-e066-478b-8d34-50d2d0deab6b@linux.ibm.com/
> Closes: https://lore.kernel.org/linuxppc-dev/20260922150619.lwWqj1AO@linutronix.de/
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> ---
Applied this patch on top of latest mainline, and issue is fixed. Please
add below tag.
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Regards,
Venkat.
> arch/powerpc/kernel/irq_64.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/kernel/irq_64.c b/arch/powerpc/kernel/irq_64.c
> index d5c48d1b0a31..e2f1e5b7a3a7 100644
> --- a/arch/powerpc/kernel/irq_64.c
> +++ b/arch/powerpc/kernel/irq_64.c
> @@ -76,13 +76,11 @@ static inline void next_interrupt(struct pt_regs *regs)
> }
>
> /*
> - * We are responding to the next interrupt, so interrupt-off
> - * latencies should be reset here.
> + * We are responding to the next interrupt. The irqentry_exit() of the
> + * replayed handler has traced hardirqs on, which also reset the
> + * interrupt-off latencies. Trace them off again.
> */
> - lockdep_hardirq_exit();
> - trace_hardirqs_on();
> trace_hardirqs_off();
> - lockdep_hardirq_enter();
> }
>
> static inline bool irq_happened_test_and_clear(u8 irq)
> @@ -116,6 +114,15 @@ static __no_kcsan void __replay_soft_interrupts(void)
> */
> local_paca->irq_happened |= PACA_IRQ_REPLAYING;
>
> + /*
> + * The irq_enter() of our callers is there to hold off softirqs. Each
> + * replayed handler enters and leaves the hardirq context itself and
> + * returns through irqentry_exit(), which again traces hardirqs on.
> + * Since lockdep only allows that outside of hardirq context, so leave
> + * it for the duration of the replay.
> + */
> + lockdep_hardirq_exit();
> +
> ppc_save_regs(®s);
> regs.softe = IRQS_ENABLED;
> regs.msr |= MSR_EE;
> @@ -168,6 +175,8 @@ static __no_kcsan void __replay_soft_interrupts(void)
> next_interrupt(®s);
> }
>
> + lockdep_hardirq_enter();
> +
> local_paca->irq_happened &= ~PACA_IRQ_REPLAYING;
> }
>
> --
> 2.39.5
>
>
next prev parent reply other threads:[~2026-11-25 12:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:26 [PATCHv4 0/4] powerpc: Misc fixes for debug kernel splats Ritesh Harjani (IBM)
2026-11-25 11:26 ` [PATCHv4 1/4] powerpc/64: Leave lockdep hardirq context around replayed interrupts Ritesh Harjani (IBM)
2026-11-25 12:01 ` Sebastian Andrzej Siewior
2026-11-25 12:45 ` Venkat Rao Bagalkote [this message]
2026-11-25 11:26 ` [PATCHv4 2/4] powerpc/watchdog: Disable preemption in arch_touch_nmi_watchdog() Ritesh Harjani (IBM)
2026-11-25 11:26 ` [PATCHv4 3/4] powerpc/kvm-hv-pmu: Don't allocate gsm/gsb GFP_KERNEL allocations under spinlock Ritesh Harjani (IBM)
2026-11-25 11:26 ` [PATCHv4 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=1b75e490-78c7-48a2-b59d-9eec953a0335@linux.ibm.com \
--to=venkat88@linux.ibm.com \
--cc=bigeasy@linutronix.de \
--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=sshegde@linux.ibm.com \
--cc=stable@vger.kernel.org \
/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®