Skip to content

Add a bhash2 table hashed by port + address

Jakub Kicinski netdev 1 version Applied

Status from this message: This series was applied to netdev/net-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v5 Latest2 patches 0 repliesApplied 2/2

v4 from the cover letter

https://lore.kernel.org/netdev/[email protected]/

* Remove "inline" in check_bind2_bucket_match function
* Add line breaks to limit lengths to 80 columns
* Rebase to master and fix merge conflict

Patches in v5 All 2 applied

#Subject and filesSizeRepliesApplied
1/2net: Add a second bind table hashed by port and addressinclude/net/inet_connection_sock.h include/net/inet_hashtables.h include/net/sock.h +4 more+489 -830 repliesApplied
2/2selftests: Add test for timing a bind request to a port with a populated bhash entrytools/testing/selftests/net/.gitignore tools/testing/selftests/net/Makefile tools/testing/selftests/net/bind_bhash_test.c+122 -00 repliesApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchEric DumazetKuniyuki Iwashima
1/2R-b A-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH net-next v5 resend 0/2] Add a bhash2 table hashed by port + address

Joanne Koong says:

This patchset proposes adding a bhash2 table that hashes by port and address. The motivation behind bhash2 is to expedite bind requests in situations where the port has many sockets in its bhash table entry, which makes checking bind conflicts costly especially given that we acquire the table entry spinlock while doing so, which can cause softirq cpu lockups and can prevent new tcp connections.

We ran into this problem at Meta where the traffic team binds a large number of IPs to port 443 and the bind() call took a significant amount of time which led to cpu softirq lockups, which caused packet drops and other failures on the machine

The patches are as follows:
1/2 - Adds a second bhash table (bhash2) hashed by port and address 2/2 - Adds a test for timing how long an additional bind request takes when the bhash entry is populated

When experimentally testing this on a local server for ~24k sockets bound to the port, the results seen were:

ipv4:
before - 0.002317 seconds
with bhash2 - 0.000018 seconds

ipv6:
before - 0.002431 seconds
with bhash2 - 0.000021 seconds

v4 -> v5:
v4:
https://lore.kernel.org/netdev/[email protected]/

* Remove "inline" in check_bind2_bucket_match function
* Add line breaks to limit lengths to 80 columns
* Rebase to master and fix merge conflict

v3 -> v4:
v3:
https://lore.kernel.org/netdev/[email protected]/

* Fix the fix for the dccp bhash2 allocation

v2 -> v3:
v2:
https://lore.kernel.org/netdev/[email protected]/

* Fix bhash2 allocation error handling for dccp
* Rebase onto net-next/master

v1 -> v2:
v1:
https://lore.kernel.org/netdev/[email protected]/

* Attached test for timing bind request

Joanne Koong (2):
net: Add a second bind table hashed by port and address
selftests: Add test for timing a bind request to a port with a
populated bhash entry

 include/net/inet_connection_sock.h            |   3 +
 include/net/inet_hashtables.h                 |  68 ++++-
 include/net/sock.h                            |  14 +
 net/dccp/proto.c                              |  33 ++-
 net/ipv4/inet_connection_sock.c               | 247 +++++++++++++-----
 net/ipv4/inet_hashtables.c                    | 193 +++++++++++++-
 net/ipv4/tcp.c                                |  14 +-
 tools/testing/selftests/net/.gitignore        |   1 +
 tools/testing/selftests/net/Makefile          |   2 +
 tools/testing/selftests/net/bind_bhash_test.c | 119 +++++++++
 10 files changed, 611 insertions(+), 83 deletions(-)
 create mode 100644 tools/testing/selftests/net/bind_bhash_test.c
Signature · 1 line
2.34.3