]> git.baikalelectronics.ru Git - kernel.git/commit
tcp/dccp: better use of ephemeral ports in connect()
authorEric Dumazet <edumazet@google.com>
Fri, 12 Feb 2016 00:28:49 +0000 (16:28 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 12 Feb 2016 10:28:32 +0000 (05:28 -0500)
commit29b645d600316ed72b495c060e751fbbaaa0ef82
tree5a8fe8b98df62f6bc8ae18b1aec8a7215622c628
parentbaf0c59c768cc59a0546a70863ed7a1e39d5995e
tcp/dccp: better use of ephemeral ports in connect()

In commit 63e4fadda7ad ("tcp/dccp: try to not exhaust ip_local_port_range
in connect()"), I added a very simple heuristic, so that we got better
chances to use even ports, and allow bind() users to have more available
slots.

It gave nice results, but with more than 200,000 TCP sessions on a typical
server, the ~30,000 ephemeral ports are still a rare resource.

I chose to go a step further, by looking at all even ports, and if none
was available, fallback to odd ports.

The companion patch does the same in bind(), but in opposite way.

I've seen exec times of up to 30ms on busy servers, so I no longer
disable BH for the whole traversal, but only for each hash bucket.
I also call cond_resched() to be gentle to other tasks.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/inet_hashtables.c