From: guoren@kernel.org
To: mark.rutland@arm.com, peterz@infradead.org,
keescook@chromium.org, paulmck@kernel.org, ubizjak@gmail.com,
tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, Guo Ren <guoren@linux.alibaba.com>,
Guo Ren <guoren@kernel.org>
Subject: [PATCH] locking/atomic: Add acquire and release fence for atomic(64)_read(set)
Date: Fri, 24 Nov 2023 11:25:08 -0500 [thread overview]
Message-ID: <20231124162508.3331357-1-guoren@kernel.org> (raw)
From: Guo Ren <guoren@linux.alibaba.com>
The definitions of atomic(64)_read(set) are relax version, so
add acquire and release fence for them.
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Guo Ren <guoren@kernel.org>
---
include/linux/atomic/atomic-arch-fallback.h | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/linux/atomic/atomic-arch-fallback.h b/include/linux/atomic/atomic-arch-fallback.h
index 18f5744dfb5d..9775900eeefd 100644
--- a/include/linux/atomic/atomic-arch-fallback.h
+++ b/include/linux/atomic/atomic-arch-fallback.h
@@ -460,7 +460,10 @@ raw_atomic_read_acquire(const atomic_t *v)
#if defined(arch_atomic_read_acquire)
return arch_atomic_read_acquire(v);
#elif defined(arch_atomic_read)
- return arch_atomic_read(v);
+ int ret;
+ ret = arch_atomic_read(v);
+ __atomic_acquire_fence();
+ return ret;
#else
int ret;
@@ -509,6 +512,7 @@ raw_atomic_set_release(atomic_t *v, int i)
#if defined(arch_atomic_set_release)
arch_atomic_set_release(v, i);
#elif defined(arch_atomic_set)
+ __atomic_release_fence();
arch_atomic_set(v, i);
#else
if (__native_word(atomic_t)) {
@@ -2576,7 +2580,10 @@ raw_atomic64_read_acquire(const atomic64_t *v)
#if defined(arch_atomic64_read_acquire)
return arch_atomic64_read_acquire(v);
#elif defined(arch_atomic64_read)
- return arch_atomic64_read(v);
+ s64 ret;
+ ret = arch_atomic64_read(v);
+ __atomic_acquire_fence();
+ return ret;
#else
s64 ret;
@@ -2625,6 +2632,7 @@ raw_atomic64_set_release(atomic64_t *v, s64 i)
#if defined(arch_atomic64_set_release)
arch_atomic64_set_release(v, i);
#elif defined(arch_atomic64_set)
+ __atomic_release_fence();
arch_atomic64_set(v, i);
#else
if (__native_word(atomic64_t)) {
@@ -4657,4 +4665,4 @@ raw_atomic64_dec_if_positive(atomic64_t *v)
}
#endif /* _LINUX_ATOMIC_FALLBACK_H */
-// 202b45c7db600ce36198eb1f1fc2c2d5268ace2d
+// 3135f55051cf62b76664e528bf04337c44a14e72
--
2.36.1
next reply other threads:[~2023-11-24 16:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 16:25 guoren [this message]
2023-11-24 16:32 ` Peter Zijlstra
2023-11-25 1:35 ` Guo Ren
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=20231124162508.3331357-1-guoren@kernel.org \
--to=guoren@kernel.org \
--cc=guoren@linux.alibaba.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=ubizjak@gmail.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®