Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

s390/crc32: Remove have_vxrs static key

Replace the have_vxrs static key with a cpu_has_vx() call. cpu_has_vx()
resolves into a compile time constant (true) if the kernel is compiled
for z13 or newer. Otherwise it generates an unconditional one
instruction branch, which is patched based on CPU alternatives.

In any case the generated code is at least as good as before and avoids
static key handling.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Link: https://lore.kernel.org/r/20250417125318.12521F12-hca@linux.ibm.com/
Signed-off-by: Eric Biggers <ebiggers@google.com>

authored by

Heiko Carstens and committed by
Eric Biggers
93b988cf 7ef377c4

+3 -7
+3 -7
arch/s390/lib/crc32-glue.c
··· 18 18 #define VX_ALIGNMENT 16L 19 19 #define VX_ALIGN_MASK (VX_ALIGNMENT - 1) 20 20 21 - static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vxrs); 22 - 23 21 /* 24 22 * DEFINE_CRC32_VX() - Define a CRC-32 function using the vector extension 25 23 * ··· 32 34 unsigned long prealign, aligned, remaining; \ 33 35 DECLARE_KERNEL_FPU_ONSTACK16(vxstate); \ 34 36 \ 35 - if (datalen < VX_MIN_LEN + VX_ALIGN_MASK || \ 36 - !static_branch_likely(&have_vxrs)) \ 37 + if (datalen < VX_MIN_LEN + VX_ALIGN_MASK || !cpu_has_vx()) \ 37 38 return ___crc32_sw(crc, data, datalen); \ 38 39 \ 39 40 if ((unsigned long)data & VX_ALIGN_MASK) { \ ··· 63 66 64 67 static int __init crc32_s390_init(void) 65 68 { 66 - if (cpu_have_feature(S390_CPU_FEATURE_VXRS)) 67 - static_branch_enable(&have_vxrs); 68 69 return 0; 69 70 } 70 71 arch_initcall(crc32_s390_init); ··· 74 79 75 80 u32 crc32_optimizations(void) 76 81 { 77 - if (static_key_enabled(&have_vxrs)) 82 + if (cpu_has_vx()) { 78 83 return CRC32_LE_OPTIMIZATION | 79 84 CRC32_BE_OPTIMIZATION | 80 85 CRC32C_OPTIMIZATION; 86 + } 81 87 return 0; 82 88 } 83 89 EXPORT_SYMBOL(crc32_optimizations);