1. 12 Feb, 2016 3 commits
    • David S. Miller's avatar
      Merge branch 'tcp_dccp_ports' · e51271d4
      David S. Miller authored
      Eric Dumazet says:
      
      ====================
      tcp/dccp: better use of ephemeral ports
      
      Big servers have bloated bind table, making very hard to succeed
      ephemeral port allocations, without special containers/namespace tricks.
      
      This patch series extends the strategy added in commit 07f4c900
      ("tcp/dccp: try to not exhaust ip_local_port_range in connect()").
      
      Since ports used by connect() are much likely to be shared among them,
      we give a hint to both bind() and connect() to keep the crowds separated
      if possible.
      
      Of course, if on a specific host an application needs to allocate ~30000
      ports using bind(), it will still be able to do so. Same for ~30000 connect()
      to a unique 2-tuple (dst addr, dst port)
      
      New implemetation is also more friendly to softirqs and reschedules.
      
      v2: rebase after TCP SO_REUSEPORT changes
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e51271d4
    • Eric Dumazet's avatar
      tcp/dccp: better use of ephemeral ports in bind() · ea8add2b
      Eric Dumazet authored
      Implement strategy used in __inet_hash_connect() in opposite way :
      
      Try to find a candidate using odd ports, then fallback to even ports.
      
      We no longer disable BH for whole traversal, but one bucket at a time.
      We also use cond_resched() to yield cpu to other tasks if needed.
      
      I removed one indentation level and tried to mirror the loop we have
      in __inet_hash_connect() and variable names to ease code maintenance.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ea8add2b
    • Eric Dumazet's avatar
      tcp/dccp: better use of ephemeral ports in connect() · 1580ab63
      Eric Dumazet authored
      In commit 07f4c900 ("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: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1580ab63
  2. 11 Feb, 2016 37 commits