From: Kautuk Consul <kconsul@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Rohan McLure <rmclure@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Kautuk Consul <kconsul@linux.vnet.ibm.com>
Subject: [PATCH v2] arch/powerpc/include/asm/barrier.h: redefine rmb and wmb to lwsync
Date: Wed, 22 Feb 2023 14:33:44 +0530 [thread overview]
Message-ID: <20230222090344.189270-1-kconsul@linux.vnet.ibm.com> (raw)
A link from ibm.com states:
"Ensures that all instructions preceding the call to __lwsync
complete before any subsequent store instructions can be executed
on the processor that executed the function. Also, it ensures that
all load instructions preceding the call to __lwsync complete before
any subsequent load instructions can be executed on the processor
that executed the function. This allows you to synchronize between
multiple processors with minimal performance impact, as __lwsync
does not wait for confirmation from each processor."
Thats why smp_rmb() and smp_wmb() are defined to lwsync.
But this same understanding applies to parallel pipeline
execution on each PowerPC processor.
So, use the lwsync instruction for rmb() and wmb() on the PPC
architectures that support it.
Signed-off-by: Kautuk Consul <kconsul@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/barrier.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
index b95b666f0374..e088dacc0ee8 100644
--- a/arch/powerpc/include/asm/barrier.h
+++ b/arch/powerpc/include/asm/barrier.h
@@ -36,8 +36,15 @@
* heavy-weight sync, so smp_wmb() can be a lighter-weight eieio.
*/
#define __mb() __asm__ __volatile__ ("sync" : : : "memory")
+
+/* The sub-arch has lwsync. */
+#if defined(CONFIG_PPC64) || defined(CONFIG_PPC_E500MC)
+#define __rmb() __asm__ __volatile__ ("lwsync" : : : "memory")
+#define __wmb() __asm__ __volatile__ ("lwsync" : : : "memory")
+#else
#define __rmb() __asm__ __volatile__ ("sync" : : : "memory")
#define __wmb() __asm__ __volatile__ ("sync" : : : "memory")
+#endif
/* The sub-arch has lwsync */
#if defined(CONFIG_PPC64) || defined(CONFIG_PPC_E500MC)
--
2.31.1
next reply other threads:[~2023-02-22 9:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-22 9:03 Kautuk Consul [this message]
2023-02-22 9:30 ` [PATCH v2] arch/powerpc/include/asm/barrier.h: redefine rmb and wmb to lwsync Kautuk Consul
2023-02-22 9:44 ` Christophe Leroy
2023-02-22 9:49 ` Kautuk Consul
2023-02-22 9:43 ` Christophe Leroy
2023-02-22 9:46 ` Kautuk Consul
2023-02-22 9:51 ` Christophe Leroy
2023-02-22 9:55 ` Kautuk Consul
2023-02-22 17:47 ` Paul E. McKenney
2023-02-23 3:51 ` Michael Ellerman
2023-02-23 4:07 ` Kautuk Consul
2023-02-23 4:43 ` Kautuk Consul
2023-02-23 9:24 ` Michael Ellerman
2023-02-23 4:01 ` Kautuk Consul
2023-02-23 4:16 ` Paul E. McKenney
2023-02-23 4:22 ` Kautuk Consul
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=20230222090344.189270-1-kconsul@linux.vnet.ibm.com \
--to=kconsul@linux.vnet.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=rmclure@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