[INET]: Remove per bucket rwlock in tcp/dccp ehash table.
As done two years ago on IP route cache table (commit
22c047ccbc
) , we can avoid using one
lock per hash bucket for the huge TCP/DCCP hash tables.
On a typical x86_64 platform, this saves about 2MB or 4MB of ram, for
litle performance differences. (we hit a different cache line for the
rwlock, but then the bucket cache line have a better sharing factor
among cpus, since we dirty it less often). For netstat or ss commands
that want a full scan of hash table, we perform fewer memory accesses.
Using a 'small' table of hashed rwlocks should be more than enough to
provide correct SMP concurrency between different buckets, without
using too much memory. Sizing of this table depends on
num_possible_cpus() and various CONFIG settings.
This patch provides some locking abstraction that may ease a future
work using a different model for TCP/DCCP table.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
efac52762b
commit
230140cffa
@@ -1072,11 +1072,13 @@ static int __init dccp_init(void)
|
||||
}
|
||||
|
||||
for (i = 0; i < dccp_hashinfo.ehash_size; i++) {
|
||||
rwlock_init(&dccp_hashinfo.ehash[i].lock);
|
||||
INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].chain);
|
||||
INIT_HLIST_HEAD(&dccp_hashinfo.ehash[i].twchain);
|
||||
}
|
||||
|
||||
if (inet_ehash_locks_alloc(&dccp_hashinfo))
|
||||
goto out_free_dccp_ehash;
|
||||
|
||||
bhash_order = ehash_order;
|
||||
|
||||
do {
|
||||
@@ -1091,7 +1093,7 @@ static int __init dccp_init(void)
|
||||
|
||||
if (!dccp_hashinfo.bhash) {
|
||||
DCCP_CRIT("Failed to allocate DCCP bind hash table");
|
||||
goto out_free_dccp_ehash;
|
||||
goto out_free_dccp_locks;
|
||||
}
|
||||
|
||||
for (i = 0; i < dccp_hashinfo.bhash_size; i++) {
|
||||
@@ -1121,6 +1123,8 @@ out_free_dccp_mib:
|
||||
out_free_dccp_bhash:
|
||||
free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
|
||||
dccp_hashinfo.bhash = NULL;
|
||||
out_free_dccp_locks:
|
||||
inet_ehash_locks_free(&dccp_hashinfo);
|
||||
out_free_dccp_ehash:
|
||||
free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order);
|
||||
dccp_hashinfo.ehash = NULL;
|
||||
@@ -1139,6 +1143,7 @@ static void __exit dccp_fini(void)
|
||||
free_pages((unsigned long)dccp_hashinfo.ehash,
|
||||
get_order(dccp_hashinfo.ehash_size *
|
||||
sizeof(struct inet_ehash_bucket)));
|
||||
inet_ehash_locks_free(&dccp_hashinfo);
|
||||
kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
|
||||
dccp_ackvec_exit();
|
||||
dccp_sysctl_exit();
|
||||
|
Reference in New Issue
Block a user