Skip to contentSkip to conversation

parisc: irq: Trace hardirq state in do_cpu_irq_mask()

PATCH Applied Karl Mehltretter 2 participants 2 messages Nov 8 – Nov 18 PA-RISC architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parisc: irq: Trace hardirq state in do_cpu_irq_mask()

intr_extint calls do_cpu_irq_mask() with PSW[I] already clear. Since commit 044d0d6de9f5 ("lockdep: Only trace IRQ edges"), its local_irq_disable() then skips trace_hardirqs_off(), and lockdep assertions fail in the timer tick:

  WARNING: kernel/rcu/tree.c:2739 at rcu_sched_clock_irq+0x618/0x1f84

The return to a context with PSW[I] set has not been annotated since TRACE_IRQFLAGS_SUPPORT was enabled. Annotate both transitions.

Fixes 366dd4ea9d5f ("parisc: Fix ftrace function tracer")

---
Assisted by an LLM.

Tested under QEMU hppa (32-bit, -smp 2, PREEMPT, PROVE_LOCKING) on mainline d48723711bae: 13 to 18 lockdep warnings per boot before, none after (two boots each and one with ftrace=irqsoff). Locking selftests pass.

The exit annotation assumes intr_return does not call preempt_schedule_irq(). It currently never does: intr_do_preempt tests PSW_D rather than PSW_I ("bb,<,n %r20, 31 - PSW_SM_I"), and a kprobe saw no calls. Fixing that needs the same annotation after preempt_schedule_irq().

 arch/parisc/kernel/irq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/parisc/kernel/irq.c +3 -1
index dff66be65d290..d9f6cb04e4bcf 100644
@@ -497,7 +497,7 @@ asmlinkage void do_cpu_irq_mask(struct pt_regs *regs)
 #endif
 
 	old_regs = set_irq_regs(regs);
-	local_irq_disable();
+	trace_hardirqs_off();
 	irq_enter_rcu();
 
 	eirr_val = mfctl(23) & cpu_eiem & per_cpu(local_ack_eiem, cpu);
@@ -535,6 +535,8 @@ asmlinkage void do_cpu_irq_mask(struct pt_regs *regs)
  out:
 	irq_exit_rcu();
 	set_irq_regs(old_regs);
+	if (!irqs_disabled_flags(regs->gr[0]))
+		trace_hardirqs_on();
 	return;
 
  set_out:

base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee

Signature · 1 line
2.39.5 (Apple Git-154)
maintainer Applied
#1 lore raw
Quoted 20 lines · Karl Mehltretter

intr_extint calls do_cpu_irq_mask() with PSW[I] already clear. Since commit 044d0d6de9f5 ("lockdep: Only trace IRQ edges"), its local_irq_disable() then skips trace_hardirqs_off(), and lockdep assertions fail in the timer tick:

   WARNING: kernel/rcu/tree.c:2739 at rcu_sched_clock_irq+0x618/0x1f84

The return to a context with PSW[I] set has not been annotated since TRACE_IRQFLAGS_SUPPORT was enabled. Annotate both transitions.

Fixes 366dd4ea9d5f ("parisc: Fix ftrace function tracer")

---
Assisted by an LLM.

Tested under QEMU hppa (32-bit, -smp 2, PREEMPT, PROVE_LOCKING) on mainline d48723711bae: 13 to 18 lockdep warnings per boot before, none after (two boots each and one with ftrace=irqsoff). Locking selftests pass.

Quoted 8 lines

The exit annotation assumes intr_return does not call preempt_schedule_irq(). It currently never does: intr_do_preempt tests PSW_D rather than PSW_I ("bb,<,n %r20, 31 - PSW_SM_I"), and a kprobe saw no calls. Fixing that needs the same annotation after preempt_schedule_irq().

  arch/parisc/kernel/irq.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

applied.

Thanks!
Helge