mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] powerpc: Use raw_local_irq_pmu_save/restore() in local_t functions
@ 2026-10-23 15:55 Jerome Marchand
  2026-10-23 17:09 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Jerome Marchand @ 2026-10-23 15:55 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Ritesh Harjani, Shrikanth Hegde, Madhavan Srinivasan
  Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	linuxppc-dev, linux-kernel, Jerome Marchand

On ppc64 with CONFIG_TRACE_IRQFLAGS enabled, the ring buffer code can
enter in an infinite recursion loop.

The problem occurs because some PowerPC's local_t operations
(local_inc/dec in particular) use powerpc_local_irq_pmu_save/restore()
which call trace_hardirqs_on/off() to generate trace events. This
creates a recursion loop:

  ring_buffer_unlock_commit()
    rb_commit()
      local_inc(&cpu_buffer->entries)
        powerpc_local_irq_pmu_save()
          trace_hardirqs_off()
            trace event => ring_buffer_unlock_commit()
              [INFINITE RECURSION]

Use raw_local_irq_pmu_save/restore() instead of their
powerpc_local_* counterparts.

Fixes: 6cd74d2b61749 ("powerpc/64s: Implement local_t using irq soft masking")
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
 arch/powerpc/include/asm/local.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/local.h b/arch/powerpc/include/asm/local.h
index ec6ced6d7cedf..4c033526bfb0d 100644
--- a/arch/powerpc/include/asm/local.h
+++ b/arch/powerpc/include/asm/local.h
@@ -32,9 +32,9 @@ static __inline__ void local_##op(long i, local_t *l)			\
 {									\
 	unsigned long flags;						\
 									\
-	powerpc_local_irq_pmu_save(flags);				\
-	l->v c_op i;						\
-	powerpc_local_irq_pmu_restore(flags);				\
+	raw_local_irq_pmu_save(flags);					\
+	l->v c_op i;							\
+	raw_local_irq_pmu_restore(flags);				\
 }
 
 #define LOCAL_OP_RETURN(op, c_op)					\
@@ -43,9 +43,9 @@ static __inline__ long local_##op##_return(long a, local_t *l)		\
 	long t;								\
 	unsigned long flags;						\
 									\
-	powerpc_local_irq_pmu_save(flags);				\
+	raw_local_irq_pmu_save(flags);					\
 	t = (l->v c_op a);						\
-	powerpc_local_irq_pmu_restore(flags);				\
+	raw_local_irq_pmu_restore(flags);				\
 									\
 	return t;							\
 }
@@ -81,11 +81,11 @@ static __inline__ long local_cmpxchg(local_t *l, long o, long n)
 	long t;
 	unsigned long flags;
 
-	powerpc_local_irq_pmu_save(flags);
+	raw_local_irq_pmu_save(flags);
 	t = l->v;
 	if (t == o)
 		l->v = n;
-	powerpc_local_irq_pmu_restore(flags);
+	raw_local_irq_pmu_restore(flags);
 
 	return t;
 }
@@ -106,10 +106,10 @@ static __inline__ long local_xchg(local_t *l, long n)
 	long t;
 	unsigned long flags;
 
-	powerpc_local_irq_pmu_save(flags);
+	raw_local_irq_pmu_save(flags);
 	t = l->v;
 	l->v = n;
-	powerpc_local_irq_pmu_restore(flags);
+	raw_local_irq_pmu_restore(flags);
 
 	return t;
 }
@@ -128,12 +128,12 @@ static __inline__ bool local_add_unless(local_t *l, long a, long u)
 	unsigned long flags;
 	bool ret = false;
 
-	powerpc_local_irq_pmu_save(flags);
+	raw_local_irq_pmu_save(flags);
 	if (l->v != u) {
 		l->v += a;
 		ret = true;
 	}
-	powerpc_local_irq_pmu_restore(flags);
+	raw_local_irq_pmu_restore(flags);
 
 	return ret;
 }
-- 
2.56.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-23 20:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 15:55 [PATCH] powerpc: Use raw_local_irq_pmu_save/restore() in local_t functions Jerome Marchand
2026-10-23 17:09 ` Steven Rostedt
2026-10-23 19:11   ` Jerome Marchand
2026-10-23 20:02     ` Steven Rostedt

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®