aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/inet_hashtables.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-07-23 03:41:16 -0400
committerDavid S. Miller <davem@davemloft.net>2015-07-23 03:41:16 -0400
commitc5e40ee287db61a79af1746954ee03ebbf1ff8a3 (patch)
tree007da00e75e9b84766ac4868421705300e1e2e14 /net/ipv4/inet_hashtables.c
parent052831879945be0d9fad2216b127147c565ec1b1 (diff)
parentc5dfd654d0ec0a28fe81e7bd4d4fd984a9855e09 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts: net/bridge/br_mdb.c br_mdb.c conflict was a function call being removed to fix a bug in 'net' but whose signature was changed in 'net-next'. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_hashtables.c')
-rw-r--r--net/ipv4/inet_hashtables.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index f8b3701a6c3c..89120196a949 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -610,22 +610,21 @@ EXPORT_SYMBOL_GPL(inet_hashinfo_init);
610 610
611int inet_ehash_locks_alloc(struct inet_hashinfo *hashinfo) 611int inet_ehash_locks_alloc(struct inet_hashinfo *hashinfo)
612{ 612{
613 unsigned int locksz = sizeof(spinlock_t);
613 unsigned int i, nblocks = 1; 614 unsigned int i, nblocks = 1;
614 615
615 if (sizeof(spinlock_t) != 0) { 616 if (locksz != 0) {
616 /* allocate 2 cache lines or at least one spinlock per cpu */ 617 /* allocate 2 cache lines or at least one spinlock per cpu */
617 nblocks = max_t(unsigned int, 618 nblocks = max(2U * L1_CACHE_BYTES / locksz, 1U);
618 2 * L1_CACHE_BYTES / sizeof(spinlock_t),
619 1);
620 nblocks = roundup_pow_of_two(nblocks * num_possible_cpus()); 619 nblocks = roundup_pow_of_two(nblocks * num_possible_cpus());
621 620
622 /* no more locks than number of hash buckets */ 621 /* no more locks than number of hash buckets */
623 nblocks = min(nblocks, hashinfo->ehash_mask + 1); 622 nblocks = min(nblocks, hashinfo->ehash_mask + 1);
624 623
625 hashinfo->ehash_locks = kmalloc_array(nblocks, sizeof(spinlock_t), 624 hashinfo->ehash_locks = kmalloc_array(nblocks, locksz,
626 GFP_KERNEL | __GFP_NOWARN); 625 GFP_KERNEL | __GFP_NOWARN);
627 if (!hashinfo->ehash_locks) 626 if (!hashinfo->ehash_locks)
628 hashinfo->ehash_locks = vmalloc(nblocks * sizeof(spinlock_t)); 627 hashinfo->ehash_locks = vmalloc(nblocks * locksz);
629 628
630 if (!hashinfo->ehash_locks) 629 if (!hashinfo->ehash_locks)
631 return -ENOMEM; 630 return -ENOMEM;