* [RFC PATCH v1 3/5] locking/atomic: mips: Refactor xchg_small to use atomic_fetch_and_or
@ 2021-07-28 11:49 Rui Wang
0 siblings, 0 replies; only message in thread
From: Rui Wang @ 2021-07-28 11:49 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Will Deacon, Arnd Bergmann
Cc: Waiman Long, Boqun Feng, Guo Ren, linux-arch, Rui Wang, hev,
Xuefeng Li, Huacai Chen, Jiaxun Yang, Huacai Chen
From: wangrui <wangrui@loongson.cn>
Signed-by-off: Rui Wang <wangrui@loongson.cn>
Signed-by-off: hev <r@hev.cc>
---
arch/mips/kernel/cmpxchg.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/arch/mips/kernel/cmpxchg.c b/arch/mips/kernel/cmpxchg.c
index ac9c8cfb2ba9..34ef35194cbe 100644
--- a/arch/mips/kernel/cmpxchg.c
+++ b/arch/mips/kernel/cmpxchg.c
@@ -9,7 +9,7 @@
unsigned long __xchg_small(volatile void *ptr, unsigned long val, unsigned int size)
{
- u32 old32, new32, load32, mask;
+ u32 old32, mask;
volatile u32 *ptr32;
unsigned int shift;
@@ -36,15 +36,9 @@ unsigned long __xchg_small(volatile void *ptr, unsigned long val, unsigned int s
* includes our byte of interest, and load its value.
*/
ptr32 = (volatile u32 *)((unsigned long)ptr & ~0x3);
- load32 = *ptr32;
-
- do {
- old32 = load32;
- new32 = (load32 & ~mask) | (val << shift);
- load32 = arch_cmpxchg(ptr32, old32, new32);
- } while (load32 != old32);
+ old32 = atomic_fetch_and_or(ptr32, ~mask, val << shift);
- return (load32 & mask) >> shift;
+ return (old32 & mask) >> shift;
}
unsigned long __cmpxchg_small(volatile void *ptr, unsigned long old,
--
2.32.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-28 11:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-28 11:49 [RFC PATCH v1 3/5] locking/atomic: mips: Refactor xchg_small to use atomic_fetch_and_or Rui Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.