mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jerome Marchand <jmarchan@redhat.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Christophe Leroy <chleroy@kernel.org>,
	Ritesh Harjani <ritesh.list@gmail.com>,
	Shrikanth Hegde <sshegde@linux.ibm.com>,
	Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	Jerome Marchand <jmarchan@redhat.com>
Subject: [PATCH] powerpc: Use raw_local_irq_pmu_save/restore() in local_t functions
Date: Fri, 23 Oct 2026 17:55:29 +0200	[thread overview]
Message-ID: <20261023155529.3895393-1-jmarchan@redhat.com> (raw)

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


             reply	other threads:[~2026-10-23 15:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 15:55 Jerome Marchand [this message]
2026-10-23 17:09 ` Steven Rostedt
2026-10-23 19:11   ` Jerome Marchand
2026-10-23 20:02     ` Steven Rostedt

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=20261023155529.3895393-1-jmarchan@redhat.com \
    --to=jmarchan@redhat.com \
    --cc=chleroy@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.vnet.ibm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=sshegde@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

all inboxes | Powered by JetHome®