]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lib/crc: make the CPU feature static keys __ro_after_init
authorEric Biggers <ebiggers@google.com>
Sun, 13 Apr 2025 15:43:50 +0000 (08:43 -0700)
committerEric Biggers <ebiggers@google.com>
Mon, 28 Apr 2025 16:07:19 +0000 (09:07 -0700)
All of the CRC library's CPU feature static_keys are initialized by
initcalls and never change afterwards, so there's no need for them to be
in the regular .data section.  Put them in .data..ro_after_init instead.

Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Heiko Carstens <hca@linux.ibm.com> # s390
Link: https://lore.kernel.org/r/20250413154350.10819-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
12 files changed:
arch/arm/lib/crc-t10dif-glue.c
arch/arm/lib/crc32-glue.c
arch/arm64/lib/crc-t10dif-glue.c
arch/loongarch/lib/crc32-loongarch.c
arch/mips/lib/crc32-mips.c
arch/powerpc/lib/crc-t10dif-glue.c
arch/powerpc/lib/crc32-glue.c
arch/s390/lib/crc32-glue.c
arch/sparc/lib/crc32_glue.c
arch/x86/lib/crc-t10dif-glue.c
arch/x86/lib/crc32-glue.c
arch/x86/lib/crc64-glue.c

index 6efad3d78284ecd8c0a74c25c332d17286b91d07..382437094bddd627ea2743568a8b9f6d5572722f 100644 (file)
@@ -16,8 +16,8 @@
 #include <asm/neon.h>
 #include <asm/simd.h>
 
-static DEFINE_STATIC_KEY_FALSE(have_neon);
-static DEFINE_STATIC_KEY_FALSE(have_pmull);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pmull);
 
 #define CRC_T10DIF_PMULL_CHUNK_SIZE    16U
 
index 4340351dbde8cdfeecf751478257d862473b4907..7ef7db9c0de738fa3b4da9c756a75124bf64e81c 100644 (file)
@@ -18,8 +18,8 @@
 #include <asm/neon.h>
 #include <asm/simd.h>
 
-static DEFINE_STATIC_KEY_FALSE(have_crc32);
-static DEFINE_STATIC_KEY_FALSE(have_pmull);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pmull);
 
 #define PMULL_MIN_LEN  64      /* min size of buffer for pmull functions */
 
index bacd18f2316887bfed828654369a55ef8e3f5f18..99d0b5668a2866eb3c8e4c9f42e82caf46925af6 100644 (file)
@@ -17,8 +17,8 @@
 #include <asm/neon.h>
 #include <asm/simd.h>
 
-static DEFINE_STATIC_KEY_FALSE(have_asimd);
-static DEFINE_STATIC_KEY_FALSE(have_pmull);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_asimd);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pmull);
 
 #define CRC_T10DIF_PMULL_CHUNK_SIZE    16U
 
index c44ee4f32557819cc788f07cf33094eb50eebae2..8e6d1f517e73c8904cffedcd4a52b22316db4601 100644 (file)
@@ -26,7 +26,7 @@ do {                                                  \
 #define CRC32(crc, value, size)                _CRC32(crc, value, size, crc)
 #define CRC32C(crc, value, size)       _CRC32(crc, value, size, crcc)
 
-static DEFINE_STATIC_KEY_FALSE(have_crc32);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32);
 
 u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
 {
index 676a4b3e290b926c110f760df639a5c870217407..84df361e71813d699319581a690b85fbca9a86c4 100644 (file)
@@ -62,7 +62,7 @@ do {                                                  \
 #define CRC32C(crc, value, size) \
        _CRC32(crc, value, size, crc32c)
 
-static DEFINE_STATIC_KEY_FALSE(have_crc32);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32);
 
 u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
 {
index f411b0120cc55a5016783a3b962a275968ba8130..ddd5c4088f508dbfa871b16b35e0e13c550e3bdb 100644 (file)
@@ -21,7 +21,7 @@
 
 #define VECTOR_BREAKPOINT      64
 
-static DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
 
 u32 __crct10dif_vpmsum(u32 crc, unsigned char const *p, size_t len);
 
index dbd10f339183dea8b9df84da45eb1ddf7da65bb4..42f2dd3c85dde5fa0d2c56d13cebc92910ba97f2 100644 (file)
@@ -13,7 +13,7 @@
 
 #define VECTOR_BREAKPOINT      512
 
-static DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vec_crypto);
 
 u32 __crc32c_vpmsum(u32 crc, const u8 *p, size_t len);
 
index 124214a273401037afbc9daa4e06d96ac5ab48e0..8f20a8e595c38c49f4cdb3e081b2c1c8b5eb889e 100644 (file)
@@ -18,7 +18,7 @@
 #define VX_ALIGNMENT           16L
 #define VX_ALIGN_MASK          (VX_ALIGNMENT - 1)
 
-static DEFINE_STATIC_KEY_FALSE(have_vxrs);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vxrs);
 
 /*
  * DEFINE_CRC32_VX() - Define a CRC-32 function using the vector extension
index a70752c729cf6983315c44682acf51fb5e9efcbe..d34e7cc7e1a1e7a28726fc6ddbe8c3db4df4e713 100644 (file)
@@ -17,7 +17,7 @@
 #include <asm/pstate.h>
 #include <asm/elf.h>
 
-static DEFINE_STATIC_KEY_FALSE(have_crc32c_opcode);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32c_opcode);
 
 u32 crc32_le_arch(u32 crc, const u8 *data, size_t len)
 {
index f89c335cde3c5b0604c2bdc1f10f09921627f345..d073b3678edc225a963cae49e338645b368b30d3 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/module.h>
 #include "crc-pclmul-template.h"
 
-static DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
 
 DECLARE_CRC_PCLMUL_FUNCS(crc16_msb, u16);
 
index e3f93b17ac3f160eb1e88efcdad6791c052e2a23..e6a6285cfca87bc9c1a1a75d68d373bae765631e 100644 (file)
@@ -11,8 +11,8 @@
 #include <linux/module.h>
 #include "crc-pclmul-template.h"
 
-static DEFINE_STATIC_KEY_FALSE(have_crc32);
-static DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_crc32);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
 
 DECLARE_CRC_PCLMUL_FUNCS(crc32_lsb, u32);
 
index b0e1b719ecbfb8ba876ec19c75aecf8bd581d2eb..1214ee726c16d8e61ca3c22b476c61069a2d8d32 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/module.h>
 #include "crc-pclmul-template.h"
 
-static DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pclmulqdq);
 
 DECLARE_CRC_PCLMUL_FUNCS(crc64_msb, u64);
 DECLARE_CRC_PCLMUL_FUNCS(crc64_lsb, u64);