net: move napi_hash[] into read mostly section
authorEric Dumazet <edumazet@google.com>
Wed, 18 Nov 2015 14:31:01 +0000 (06:31 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Nov 2015 21:17:42 +0000 (16:17 -0500)
We do not often add/delete a napi context.
Moving napi_hash[] into read mostly section avoids potential false sharing.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/hashtable.h
net/core/dev.c

index 519b6e2d769ede04d120f6ea3bc5f848e4978148..661e5c2a8e2a49e30d2fe3895f234e321ec81c71 100644 (file)
        struct hlist_head name[1 << (bits)] =                                   \
                        { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
 
+#define DEFINE_READ_MOSTLY_HASHTABLE(name, bits)                               \
+       struct hlist_head name[1 << (bits)] __read_mostly =                     \
+                       { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
+
 #define DECLARE_HASHTABLE(name, bits)                                          \
        struct hlist_head name[1 << (bits)]
 
index ff58a8bc5e3c5090d0395ba887bd688bedab3304..02dfbd91a8e4626659a5b79d65ce554c5fa14ff9 100644 (file)
@@ -184,7 +184,7 @@ EXPORT_SYMBOL(dev_base_lock);
 static DEFINE_SPINLOCK(napi_hash_lock);
 
 static unsigned int napi_gen_id = NR_CPUS;
-static DEFINE_HASHTABLE(napi_hash, 8);
+static DEFINE_READ_MOSTLY_HASHTABLE(napi_hash, 8);
 
 static seqcount_t devnet_rename_seq;