]> git.baikalelectronics.ru Git - kernel.git/commit
udp: optimize bind(0) if many ports are in use
authorEric Dumazet <dada1@cosmosbay.com>
Tue, 27 Jan 2009 05:35:35 +0000 (21:35 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Jan 2009 05:35:35 +0000 (21:35 -0800)
commit7788fc00f7d2180f7f59d1611ea6d8b25052ebeb
tree22a06e97ece02db900f7d4f496639582b828a4ee
parent89e817d640cede8792e75f90bada6b4a1dde1c82
udp: optimize bind(0) if many ports are in use

commit b057d9b8ed4d1fb0f84987c79f38f7e12deac1a6
(udp: Improve port randomization) introduced a regression for UDP bind() syscall
to null port (getting a random port) in case lot of ports are already in use.

This is because we do about 28000 scans of very long chains (220 sockets per chain),
with many spin_lock_bh()/spin_unlock_bh() calls.

Fix this using a bitmap (64 bytes for current value of UDP_HTABLE_SIZE)
so that we scan chains at most once.

Instead of 250 ms per bind() call, we get after patch a time of 2.9 ms

Based on a report from Vitaly Mayatskikh

Reported-by: Vitaly Mayatskikh <v.mayatskih@gmail.com>
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Tested-by: Vitaly Mayatskikh <v.mayatskih@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/udp.c