Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux...
[pandora-kernel.git] / net / ipv4 / fib_frontend.c
index 919f2ad..36e27c2 100644 (file)
@@ -153,7 +153,7 @@ static void fib_flush(struct net *net)
  * @addr: the source address
  * @devref: if true, take a reference on the found device
  *
- * If a caller uses devref=false, it should be protected by RCU
+ * If a caller uses devref=false, it should be protected by RCU, or RTNL
  */
 struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref)
 {
@@ -1016,16 +1016,15 @@ static struct notifier_block fib_netdev_notifier = {
 static int __net_init ip_fib_net_init(struct net *net)
 {
        int err;
-       unsigned int i;
+       size_t size = sizeof(struct hlist_head) * FIB_TABLE_HASHSZ;
+
+       /* Avoid false sharing : Use at least a full cache line */
+       size = max_t(size_t, size, L1_CACHE_BYTES);
 
-       net->ipv4.fib_table_hash = kzalloc(
-                       sizeof(struct hlist_head)*FIB_TABLE_HASHSZ, GFP_KERNEL);
+       net->ipv4.fib_table_hash = kzalloc(size, GFP_KERNEL);
        if (net->ipv4.fib_table_hash == NULL)
                return -ENOMEM;
 
-       for (i = 0; i < FIB_TABLE_HASHSZ; i++)
-               INIT_HLIST_HEAD(&net->ipv4.fib_table_hash[i]);
-
        err = fib4_rules_init(net);
        if (err < 0)
                goto fail;