Skip to content

Commit b893281

Browse files
tomratbertdavem330
authored andcommitted
ila: Call library function alloc_bucket_locks
To allocate the array of bucket locks for the hash table we now call library function alloc_bucket_spinlocks. Signed-off-by: Tom Herbert <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f7a2ba5 commit b893281

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

net/ipv6/ila/ila_xlat.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,14 @@ struct ila_net {
3131
bool hooks_registered;
3232
};
3333

34+
#define MAX_LOCKS 1024
3435
#define LOCKS_PER_CPU 10
3536

3637
static int alloc_ila_locks(struct ila_net *ilan)
3738
{
38-
unsigned int i, size;
39-
unsigned int nr_pcpus = num_possible_cpus();
40-
41-
nr_pcpus = min_t(unsigned int, nr_pcpus, 32UL);
42-
size = roundup_pow_of_two(nr_pcpus * LOCKS_PER_CPU);
43-
44-
if (sizeof(spinlock_t) != 0) {
45-
ilan->locks = kvmalloc_array(size, sizeof(spinlock_t),
46-
GFP_KERNEL);
47-
if (!ilan->locks)
48-
return -ENOMEM;
49-
for (i = 0; i < size; i++)
50-
spin_lock_init(&ilan->locks[i]);
51-
}
52-
ilan->locks_mask = size - 1;
53-
54-
return 0;
39+
return alloc_bucket_spinlocks(&ilan->locks, &ilan->locks_mask,
40+
MAX_LOCKS, LOCKS_PER_CPU,
41+
GFP_KERNEL);
5542
}
5643

5744
static u32 hashrnd __read_mostly;
@@ -640,7 +627,7 @@ static __net_exit void ila_exit_net(struct net *net)
640627

641628
rhashtable_free_and_destroy(&ilan->rhash_table, ila_free_cb, NULL);
642629

643-
kvfree(ilan->locks);
630+
free_bucket_spinlocks(ilan->locks);
644631

645632
if (ilan->hooks_registered)
646633
nf_unregister_net_hooks(net, ila_nf_hook_ops,

0 commit comments

Comments
 (0)