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