linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] riscv: Add helpers use_alternative_{likely,unlikely}
@ 2025-08-20 13:44 Vivian Wang
  2025-08-20 13:44 ` [PATCH 1/6] riscv: Introduce use_alternative_{likely,unlikely} Vivian Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Vivian Wang @ 2025-08-20 13:44 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Yury Norov, Rasmus Villemoes
  Cc: Vivian Wang, Vivian Wang, linux-riscv, linux-kernel,
	Aydın Mercan

There are about a dozen uses of asm goto in arch/riscv just to select
between two code paths with the alternative mechanism. Introduce helpers
similar to arm64's alternative_has_cap_{likely,unlikely} for this, and
convert the existing code to use it.

I did not use the name alternative_has_cap_{likely,unlikely} since riscv
alternatives are not all CPU capabilities.

In each case, I have tried to preserve the existing logic while picking
between "likely" and "unlikely".

These patches are also available at:

https://github.com/dramforever/linux/tree/riscv/altn-helper/v1

---
Vivian Wang (6):
      riscv: Introduce use_alternative_{likely,unlikely}
      riscv: pgtable: Convert to use_alternative_unlikely
      riscv: checksum: Convert to use_alternative_likely
      riscv: hweight: Convert to use_alternative_likely
      riscv: bitops: Convert to use_alternative_likely
      riscv: cmpxchg: Convert to use_alternative_likely

 arch/riscv/include/asm/alternative-macros.h |  73 ++++++++++++++++
 arch/riscv/include/asm/arch_hweight.h       |  42 ++++------
 arch/riscv/include/asm/bitops.h             | 112 +++++++++++--------------
 arch/riscv/include/asm/checksum.h           |  13 +--
 arch/riscv/include/asm/cmpxchg.h            | 125 ++++++++++++++--------------
 arch/riscv/include/asm/pgtable.h            |  15 ++--
 arch/riscv/lib/csum.c                       |  65 ++++++---------
 arch/riscv/mm/pgtable.c                     |  22 +++--
 8 files changed, 247 insertions(+), 220 deletions(-)
---
base-commit: 062b3e4a1f880f104a8d4b90b767788786aa7b78
change-id: 20250820-riscv-altn-helper-wip-00af3a552c37

Best regards,
-- 
Vivian "dramforever" Wang


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2025-08-20 20:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 13:44 [PATCH 0/6] riscv: Add helpers use_alternative_{likely,unlikely} Vivian Wang
2025-08-20 13:44 ` [PATCH 1/6] riscv: Introduce use_alternative_{likely,unlikely} Vivian Wang
2025-08-20 14:56   ` Yury Norov
2025-08-20 15:25     ` Vivian Wang
2025-08-20 15:43       ` Yury Norov
2025-08-20 16:41         ` Vivian Wang
2025-08-20 13:44 ` [PATCH 2/6] riscv: pgtable: Convert to use_alternative_unlikely Vivian Wang
2025-08-20 13:44 ` [PATCH 3/6] riscv: checksum: Convert to use_alternative_likely Vivian Wang
2025-08-20 13:44 ` [PATCH 4/6] riscv: hweight: " Vivian Wang
2025-08-20 13:44 ` [PATCH 5/6] riscv: bitops: " Vivian Wang
2025-08-20 15:04   ` Yury Norov
2025-08-20 15:36     ` Vivian Wang
2025-08-20 13:44 ` [PATCH 6/6] riscv: cmpxchg: " Vivian Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).