mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v3 0/5] Rework & improve riscv cmpxchg.h and atomic.h
@ 2023-08-04  8:48 Leonardo Bras
  2023-08-04  8:48 ` [RFC PATCH v3 1/5] riscv/cmpxchg: Deduplicate xchg() asm functions Leonardo Bras
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Leonardo Bras @ 2023-08-04  8:48 UTC (permalink / raw)
  To: Will Deacon, Peter Zijlstra, Boqun Feng, Mark Rutland,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Leonardo Bras,
	Andrea Parri, Geert Uytterhoeven, Andrzej Hajda, Palmer Dabbelt,
	Guo Ren
  Cc: linux-kernel, linux-riscv

While studying riscv's cmpxchg.h file, I got really interested in
understanding how RISCV asm implemented the different versions of
{cmp,}xchg.

When I understood the pattern, it made sense for me to remove the
duplications and create macros to make it easier to understand what exactly
changes between the versions: Instruction sufixes & barriers.

Also, did the same kind of work on atomic.c.

After that, I noted both cmpxchg and xchg only accept variables of 
size 4 and 8, compared to x86 and arm64 which do 1,2,4,8.

Now that deduplication is done, it is quite direct to implement them
for variable sizes 1 and 2, so I did it. Then Guo Ren already presented
me some possible users :)

I did compare the generated asm on a test.c that contained usage for every
changed function, and could not detect any change on patches 1 + 2 + 3 
compared with upstream.

Pathes 4 & 5 were compiled-tested, but I could not run-test them yet.

Thanks!
Leo


Changes since squashed cmpxchg RFCv2:
- Removed rc parameter from the new macro: it can be internal to the macro
- 2 new patches: cmpxchg size 1 and 2, xchg size 1 and 2
https://lore.kernel.org/all/20230803051401.710236-2-leobras@redhat.com/

Changes since squashed cmpxchg RFCv1:
- Unified with atomic.c patchset
- Rebased on top of torvalds/master (thanks Andrea Parri!)
- Removed helper macros that were not being used elsewhere in the kernel.
https://lore.kernel.org/all/20230419062505.257231-1-leobras@redhat.com/
https://lore.kernel.org/all/20230406082018.70367-1-leobras@redhat.com/

Changes since (cmpxchg) RFCv3:
- Squashed the 6 original patches in 2: one for cmpxchg and one for xchg
https://lore.kernel.org/all/20230404163741.2762165-1-leobras@redhat.com/

Changes since (cmpxchg) RFCv2:
- Fixed  macros that depend on having a local variable with a magic name
- Previous cast to (long) is now only applied on 4-bytes cmpxchg
https://lore.kernel.org/all/20230321074249.2221674-1-leobras@redhat.com/

Changes since (cmpxchg) RFCv1:
- Fixed patch 4/6 suffix from 'w.aqrl' to '.w.aqrl', to avoid build error
https://lore.kernel.org/all/20230318080059.1109286-1-leobras@redhat.com/


Leonardo Bras (5):
  riscv/cmpxchg: Deduplicate xchg() asm functions
  riscv/cmpxchg: Deduplicate cmpxchg() asm and macros
  riscv/atomic.h : Deduplicate arch_atomic.*
  riscv/cmpxchg: Implement cmpxchg for variables of size 1 and 2
  riscv/cmpxchg: Implement xchg for variables of size 1 and 2

 arch/riscv/include/asm/atomic.h  | 164 ++++++-------
 arch/riscv/include/asm/cmpxchg.h | 393 ++++++++++---------------------
 2 files changed, 195 insertions(+), 362 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-08-11  2:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-04  8:48 [RFC PATCH v3 0/5] Rework & improve riscv cmpxchg.h and atomic.h Leonardo Bras
2023-08-04  8:48 ` [RFC PATCH v3 1/5] riscv/cmpxchg: Deduplicate xchg() asm functions Leonardo Bras
2023-08-04  8:48 ` [RFC PATCH v3 2/5] riscv/cmpxchg: Deduplicate cmpxchg() asm and macros Leonardo Bras
2023-08-04  8:48 ` [RFC PATCH v3 3/5] riscv/atomic.h : Deduplicate arch_atomic.* Leonardo Bras
2023-08-04  8:48 ` [RFC PATCH v3 4/5] riscv/cmpxchg: Implement cmpxchg for variables of size 1 and 2 Leonardo Bras
2023-08-04 17:45   ` Guo Ren
2023-08-05  3:14     ` Leonardo Bras Soares Passos
2023-08-05  4:24       ` Guo Ren
2023-08-07 16:17         ` Leonardo Bras Soares Passos
2023-08-09  2:02           ` Leonardo Bras Soares Passos
2023-08-10  4:06             ` Leonardo Bras Soares Passos
2023-08-11  2:32             ` Guo Ren
2023-08-04  8:48 ` [RFC PATCH v3 5/5] riscv/cmpxchg: Implement xchg " Leonardo Bras

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®