Skip to content
Commit 98322f22 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

udp: optimize bind(0) if many ports are in use



commit 9088c560
(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: default avatarVitaly Mayatskikh <v.mayatskih@gmail.com>
Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Tested-by: default avatarVitaly Mayatskikh <v.mayatskih@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8527bec5
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment