From 2a348e4c945502204125d0519b55433b7d41853c Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 13 Jan 2017 05:25:46 +0100 Subject: Use __read_mostly attribute when possible --- src/crypto/chacha20poly1305.c | 6 +++--- src/data.c | 4 ++-- src/noise.c | 4 ++-- src/ratelimiter.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/crypto/chacha20poly1305.c b/src/crypto/chacha20poly1305.c index 8f187fc..28e27b6 100644 --- a/src/crypto/chacha20poly1305.c +++ b/src/crypto/chacha20poly1305.c @@ -27,9 +27,9 @@ asmlinkage void poly1305_asm_2block_sse2(u32 *h, const u8 *src, const u32 *r, un #ifdef CONFIG_AS_AVX2 asmlinkage void poly1305_asm_4block_avx2(u32 *h, const u8 *src, const u32 *r, unsigned int blocks, const u32 *u); #endif -static bool chacha20poly1305_use_avx2 = false; -static bool chacha20poly1305_use_ssse3 = false; -static bool chacha20poly1305_use_sse2 = false; +static bool chacha20poly1305_use_avx2 __read_mostly = false; +static bool chacha20poly1305_use_ssse3 __read_mostly = false; +static bool chacha20poly1305_use_sse2 __read_mostly = false; void chacha20poly1305_init(void) { chacha20poly1305_use_sse2 = boot_cpu_has(X86_FEATURE_XMM2); diff --git a/src/data.c b/src/data.c index cf5a392..6cc6ce4 100644 --- a/src/data.c +++ b/src/data.c @@ -43,8 +43,8 @@ struct decryption_ctx { }; #ifdef CONFIG_WIREGUARD_PARALLEL -static struct kmem_cache *encryption_ctx_cache; -static struct kmem_cache *decryption_ctx_cache; +static struct kmem_cache *encryption_ctx_cache __read_mostly; +static struct kmem_cache *decryption_ctx_cache __read_mostly; int packet_init_data_caches(void) { diff --git a/src/noise.c b/src/noise.c index 9555e58..0ffffd7 100644 --- a/src/noise.c +++ b/src/noise.c @@ -24,8 +24,8 @@ static const u8 handshake_name[33] = "Noise_IK_25519_ChaChaPoly_BLAKE2s"; static const u8 handshake_psk_name[36] = "NoisePSK_IK_25519_ChaChaPoly_BLAKE2s"; -static u8 handshake_name_hash[NOISE_HASH_LEN]; -static u8 handshake_psk_name_hash[NOISE_HASH_LEN]; +static u8 handshake_name_hash[NOISE_HASH_LEN] __read_mostly; +static u8 handshake_psk_name_hash[NOISE_HASH_LEN] __read_mostly; static const u8 identifier_name[34] = "WireGuard v0 zx2c4 Jason@zx2c4.com"; static atomic64_t keypair_counter = ATOMIC64_INIT(0); diff --git a/src/ratelimiter.c b/src/ratelimiter.c index 30e4175..c45d7ce 100644 --- a/src/ratelimiter.c +++ b/src/ratelimiter.c @@ -8,9 +8,9 @@ #include #include -static struct xt_match *v4_match; +static struct xt_match *v4_match __read_mostly; #if IS_ENABLED(CONFIG_IPV6) -static struct xt_match *v6_match; +static struct xt_match *v6_match __read_mostly; #endif enum { -- cgit v1.2.3-59-g8ed1b