]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv6/ip6_fib.c
fib: avoid false sharing on fib_table_hash
[net-next-2.6.git] / net / ipv6 / ip6_fib.c
index b6a585909d3560d0f9c0396fe8ed4b136c0ef5f6..de382114609b7de8d0cbf5c5447a18d4f5a89a2d 100644 (file)
@@ -1500,15 +1500,18 @@ static void fib6_gc_timer_cb(unsigned long arg)
 
 static int __net_init fib6_net_init(struct net *net)
 {
+       size_t size = sizeof(struct hlist_head) * FIB6_TABLE_HASHSZ;
+
        setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net);
 
        net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL);
        if (!net->ipv6.rt6_stats)
                goto out_timer;
 
-       net->ipv6.fib_table_hash = kcalloc(FIB6_TABLE_HASHSZ,
-                                          sizeof(*net->ipv6.fib_table_hash),
-                                          GFP_KERNEL);
+       /* Avoid false sharing : Use at least a full cache line */
+       size = max_t(size_t, size, L1_CACHE_BYTES);
+
+       net->ipv6.fib_table_hash = kzalloc(size, GFP_KERNEL);
        if (!net->ipv6.fib_table_hash)
                goto out_rt6_stats;