diff options
author | Eric Dumazet <edumazet@google.com> | 2012-06-08 01:03:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-08 17:27:23 -0400 |
commit | 7123aaa3a1416529ce461e98108e6b343b294643 (patch) | |
tree | 094070a521666979523411422109cce72a1db8c4 /include/net/af_unix.h | |
parent | 54db0cc2ba0d38166acc2d6bae21721405305537 (diff) |
af_unix: speedup /proc/net/unix
/proc/net/unix has quadratic behavior, and can hold unix_table_lock for
a while if high number of unix sockets are alive. (90 ms for 200k
sockets...)
We already have a hash table, so its quite easy to use it.
Problem is unbound sockets are still hashed in a single hash slot
(unix_socket_table[UNIX_HASH_TABLE])
This patch also spreads unbound sockets to 256 hash slots, to speedup
both /proc/net/unix and unix_diag.
Time to read /proc/net/unix with 200k unix sockets :
(time dd if=/proc/net/unix of=/dev/null bs=4k)
before : 520 secs
after : 2 secs
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/af_unix.h')
-rw-r--r-- | include/net/af_unix.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 2ee33da36a7a..b5f8988e4283 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -14,10 +14,11 @@ extern struct sock *unix_get_socket(struct file *filp); | |||
14 | extern struct sock *unix_peer_get(struct sock *); | 14 | extern struct sock *unix_peer_get(struct sock *); |
15 | 15 | ||
16 | #define UNIX_HASH_SIZE 256 | 16 | #define UNIX_HASH_SIZE 256 |
17 | #define UNIX_HASH_BITS 8 | ||
17 | 18 | ||
18 | extern unsigned int unix_tot_inflight; | 19 | extern unsigned int unix_tot_inflight; |
19 | extern spinlock_t unix_table_lock; | 20 | extern spinlock_t unix_table_lock; |
20 | extern struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; | 21 | extern struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE]; |
21 | 22 | ||
22 | struct unix_address { | 23 | struct unix_address { |
23 | atomic_t refcnt; | 24 | atomic_t refcnt; |