]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
tcp: Skip empty hash buckets faster in /proc/net/tcp
authorAndi Kleen <ak@suse.de>
Thu, 28 Aug 2008 08:08:02 +0000 (01:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Aug 2008 08:08:02 +0000 (01:08 -0700)
commit6eac56040787c3ff604fe7d48bbbb7897cd1387c
tree1d3271c33d8d65bfea4aaf5d770f73ccd6da5825
parent4d40555250320520c5398569457962b3984fc75e
tcp: Skip empty hash buckets faster in /proc/net/tcp

On most systems most of the TCP established/time-wait hash buckets are empty.
When walking the hash table for /proc/net/tcp their read locks would
always be aquired just to find out they're empty. This patch changes the code
to check first if the buckets have any entries before taking the lock, which
is much cheaper than taking a lock. Since the hash tables are large
this makes a measurable difference on processing /proc/net/tcp,
especially on architectures with slow read_lock (e.g. PPC)

On a 2GB Core2 system time cat /proc/net/tcp > /dev/null (with a mostly
empty hash table) goes from 0.046s to 0.005s.

On systems with slower atomics (like P4 or POWER4) or larger hash tables
(more RAM) the difference is much higher.

This can be noticeable because there are some daemons around who regularly
scan /proc/net/tcp.

Original idea for this patch from Marcus Meissner, but redone by me.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_ipv4.c