mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 17:23:36 +00:00
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 <tom@quantonium.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f7a2ba5ab9
commit
b893281715
@ -31,27 +31,14 @@ struct ila_net {
|
|||||||
bool hooks_registered;
|
bool hooks_registered;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MAX_LOCKS 1024
|
||||||
#define LOCKS_PER_CPU 10
|
#define LOCKS_PER_CPU 10
|
||||||
|
|
||||||
static int alloc_ila_locks(struct ila_net *ilan)
|
static int alloc_ila_locks(struct ila_net *ilan)
|
||||||
{
|
{
|
||||||
unsigned int i, size;
|
return alloc_bucket_spinlocks(&ilan->locks, &ilan->locks_mask,
|
||||||
unsigned int nr_pcpus = num_possible_cpus();
|
MAX_LOCKS, LOCKS_PER_CPU,
|
||||||
|
GFP_KERNEL);
|
||||||
nr_pcpus = min_t(unsigned int, nr_pcpus, 32UL);
|
|
||||||
size = roundup_pow_of_two(nr_pcpus * LOCKS_PER_CPU);
|
|
||||||
|
|
||||||
if (sizeof(spinlock_t) != 0) {
|
|
||||||
ilan->locks = kvmalloc_array(size, sizeof(spinlock_t),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!ilan->locks)
|
|
||||||
return -ENOMEM;
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
spin_lock_init(&ilan->locks[i]);
|
|
||||||
}
|
|
||||||
ilan->locks_mask = size - 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 hashrnd __read_mostly;
|
static u32 hashrnd __read_mostly;
|
||||||
@ -640,7 +627,7 @@ static __net_exit void ila_exit_net(struct net *net)
|
|||||||
|
|
||||||
rhashtable_free_and_destroy(&ilan->rhash_table, ila_free_cb, NULL);
|
rhashtable_free_and_destroy(&ilan->rhash_table, ila_free_cb, NULL);
|
||||||
|
|
||||||
kvfree(ilan->locks);
|
free_bucket_spinlocks(ilan->locks);
|
||||||
|
|
||||||
if (ilan->hooks_registered)
|
if (ilan->hooks_registered)
|
||||||
nf_unregister_net_hooks(net, ila_nf_hook_ops,
|
nf_unregister_net_hooks(net, ila_nf_hook_ops,
|
||||||
|
Loading…
Reference in New Issue
Block a user