* [PATCH RESEND -tip 1/2] locking/atomic/x86: Introduce read64_nonatomic macro to x86_32 with cx8
@ 2024-06-05 18:13 Uros Bizjak
2024-06-05 18:13 ` [PATCH RESEND -tip 2/2] locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void Uros Bizjak
2024-07-17 14:38 ` [tip: locking/core] locking/atomic/x86: Introduce the read64_nonatomic macro to x86_32 with cx8 tip-bot2 for Uros Bizjak
0 siblings, 2 replies; 4+ messages in thread
From: Uros Bizjak @ 2024-06-05 18:13 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin
As described in:
commit e73c4e34a0e9 ("locking/atomic/x86: Introduce arch_atomic64_read_nonatomic() to x86_32")
the value preload before the cmpxchg loop does not need to be atomic.
Introduce read64_nonatomic macro to load the value from atomic_t
location in a faster non-atomic way and use it in atomic64_cx8_32.S.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/lib/atomic64_cx8_32.S | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
index 90afb488b396..b2eff07d65e4 100644
--- a/arch/x86/lib/atomic64_cx8_32.S
+++ b/arch/x86/lib/atomic64_cx8_32.S
@@ -16,6 +16,11 @@
cmpxchg8b (\reg)
.endm
+.macro read64_nonatomic reg
+ movl (\reg), %eax
+ movl 4(\reg), %edx
+.endm
+
SYM_FUNC_START(atomic64_read_cx8)
read64 %ecx
RET
@@ -51,7 +56,7 @@ SYM_FUNC_START(atomic64_\func\()_return_cx8)
movl %edx, %edi
movl %ecx, %ebp
- read64 %ecx
+ read64_nonatomic %ecx
1:
movl %eax, %ebx
movl %edx, %ecx
@@ -79,7 +84,7 @@ addsub_return sub sub sbb
SYM_FUNC_START(atomic64_\func\()_return_cx8)
pushl %ebx
- read64 %esi
+ read64_nonatomic %esi
1:
movl %eax, %ebx
movl %edx, %ecx
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH RESEND -tip 2/2] locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void
2024-06-05 18:13 [PATCH RESEND -tip 1/2] locking/atomic/x86: Introduce read64_nonatomic macro to x86_32 with cx8 Uros Bizjak
@ 2024-06-05 18:13 ` Uros Bizjak
2024-07-17 14:38 ` [tip: locking/core] " tip-bot2 for Uros Bizjak
2024-07-17 14:38 ` [tip: locking/core] locking/atomic/x86: Introduce the read64_nonatomic macro to x86_32 with cx8 tip-bot2 for Uros Bizjak
1 sibling, 1 reply; 4+ messages in thread
From: Uros Bizjak @ 2024-06-05 18:13 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin
Correct the return type of x86_32 arch_atomic64_add() and
arch_atomic64_sub() functions to void and remove redundant return.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/include/asm/atomic64_32.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
index 8db2ec4d6cda..1f650b4dde50 100644
--- a/arch/x86/include/asm/atomic64_32.h
+++ b/arch/x86/include/asm/atomic64_32.h
@@ -163,20 +163,18 @@ static __always_inline s64 arch_atomic64_dec_return(atomic64_t *v)
}
#define arch_atomic64_dec_return arch_atomic64_dec_return
-static __always_inline s64 arch_atomic64_add(s64 i, atomic64_t *v)
+static __always_inline void arch_atomic64_add(s64 i, atomic64_t *v)
{
__alternative_atomic64(add, add_return,
ASM_OUTPUT2("+A" (i), "+c" (v)),
ASM_NO_INPUT_CLOBBER("memory"));
- return i;
}
-static __always_inline s64 arch_atomic64_sub(s64 i, atomic64_t *v)
+static __always_inline void arch_atomic64_sub(s64 i, atomic64_t *v)
{
__alternative_atomic64(sub, sub_return,
ASM_OUTPUT2("+A" (i), "+c" (v)),
ASM_NO_INPUT_CLOBBER("memory"));
- return i;
}
static __always_inline void arch_atomic64_inc(atomic64_t *v)
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [tip: locking/core] locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void
2024-06-05 18:13 ` [PATCH RESEND -tip 2/2] locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void Uros Bizjak
@ 2024-07-17 14:38 ` tip-bot2 for Uros Bizjak
0 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2024-07-17 14:38 UTC (permalink / raw)
To: linux-tip-commits
Cc: Uros Bizjak, Ingo Molnar, Linus Torvalds, x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: dce2a224763ce968445e14c43b49321936309c75
Gitweb: https://git.kernel.org/tip/dce2a224763ce968445e14c43b49321936309c75
Author: Uros Bizjak <ubizjak@gmail.com>
AuthorDate: Wed, 05 Jun 2024 20:13:16 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 17 Jul 2024 16:28:19 +02:00
locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void
Correct the return type of x86_32 arch_atomic64_add() and
arch_atomic64_sub() functions to 'void' and remove redundant return.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20240605181424.3228-2-ubizjak@gmail.com
---
arch/x86/include/asm/atomic64_32.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
index 8db2ec4..1f650b4 100644
--- a/arch/x86/include/asm/atomic64_32.h
+++ b/arch/x86/include/asm/atomic64_32.h
@@ -163,20 +163,18 @@ static __always_inline s64 arch_atomic64_dec_return(atomic64_t *v)
}
#define arch_atomic64_dec_return arch_atomic64_dec_return
-static __always_inline s64 arch_atomic64_add(s64 i, atomic64_t *v)
+static __always_inline void arch_atomic64_add(s64 i, atomic64_t *v)
{
__alternative_atomic64(add, add_return,
ASM_OUTPUT2("+A" (i), "+c" (v)),
ASM_NO_INPUT_CLOBBER("memory"));
- return i;
}
-static __always_inline s64 arch_atomic64_sub(s64 i, atomic64_t *v)
+static __always_inline void arch_atomic64_sub(s64 i, atomic64_t *v)
{
__alternative_atomic64(sub, sub_return,
ASM_OUTPUT2("+A" (i), "+c" (v)),
ASM_NO_INPUT_CLOBBER("memory"));
- return i;
}
static __always_inline void arch_atomic64_inc(atomic64_t *v)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [tip: locking/core] locking/atomic/x86: Introduce the read64_nonatomic macro to x86_32 with cx8
2024-06-05 18:13 [PATCH RESEND -tip 1/2] locking/atomic/x86: Introduce read64_nonatomic macro to x86_32 with cx8 Uros Bizjak
2024-06-05 18:13 ` [PATCH RESEND -tip 2/2] locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void Uros Bizjak
@ 2024-07-17 14:38 ` tip-bot2 for Uros Bizjak
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2024-07-17 14:38 UTC (permalink / raw)
To: linux-tip-commits
Cc: Uros Bizjak, Ingo Molnar, Linus Torvalds, x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 6e30a7c98a9fda2f894e970e9cd637657f39c59d
Gitweb: https://git.kernel.org/tip/6e30a7c98a9fda2f894e970e9cd637657f39c59d
Author: Uros Bizjak <ubizjak@gmail.com>
AuthorDate: Wed, 05 Jun 2024 20:13:15 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 17 Jul 2024 16:28:11 +02:00
locking/atomic/x86: Introduce the read64_nonatomic macro to x86_32 with cx8
As described in commit:
e73c4e34a0e9 ("locking/atomic/x86: Introduce arch_atomic64_read_nonatomic() to x86_32")
the value preload before the CMPXCHG loop does not need to be atomic.
Introduce the read64_nonatomic assembly macro to load the value from a
atomic_t location in a faster non-atomic way and use it in
atomic64_cx8_32.S.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20240605181424.3228-1-ubizjak@gmail.com
---
arch/x86/lib/atomic64_cx8_32.S | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
index 90afb48..b2eff07 100644
--- a/arch/x86/lib/atomic64_cx8_32.S
+++ b/arch/x86/lib/atomic64_cx8_32.S
@@ -16,6 +16,11 @@
cmpxchg8b (\reg)
.endm
+.macro read64_nonatomic reg
+ movl (\reg), %eax
+ movl 4(\reg), %edx
+.endm
+
SYM_FUNC_START(atomic64_read_cx8)
read64 %ecx
RET
@@ -51,7 +56,7 @@ SYM_FUNC_START(atomic64_\func\()_return_cx8)
movl %edx, %edi
movl %ecx, %ebp
- read64 %ecx
+ read64_nonatomic %ecx
1:
movl %eax, %ebx
movl %edx, %ecx
@@ -79,7 +84,7 @@ addsub_return sub sub sbb
SYM_FUNC_START(atomic64_\func\()_return_cx8)
pushl %ebx
- read64 %esi
+ read64_nonatomic %esi
1:
movl %eax, %ebx
movl %edx, %ecx
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-17 14:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 18:13 [PATCH RESEND -tip 1/2] locking/atomic/x86: Introduce read64_nonatomic macro to x86_32 with cx8 Uros Bizjak
2024-06-05 18:13 ` [PATCH RESEND -tip 2/2] locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void Uros Bizjak
2024-07-17 14:38 ` [tip: locking/core] " tip-bot2 for Uros Bizjak
2024-07-17 14:38 ` [tip: locking/core] locking/atomic/x86: Introduce the read64_nonatomic macro to x86_32 with cx8 tip-bot2 for Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox