From: Jakub Sitnicki <jakub@cloudflare.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
kernel-team@cloudflare.com
Subject: Re: [PATCH net-next 0/2] tcp/dccp: refine source port selection
Date: Wed, 03 Jan 2024 15:17:26 +0100 [thread overview]
Message-ID: <87sf3e8ppa.fsf@cloudflare.com> (raw)
In-Reply-To: <20231214192939.1962891-1-edumazet@google.com>
On Thu, Dec 14, 2023 at 07:29 PM GMT, Eric Dumazet wrote:
> This patch series leverages IP_LOCAL_PORT_RANGE option
> to no longer favor even source port selection at connect() time.
>
> This should lower time taken by connect() for hosts having
> many active connections to the same destination.
>
> Eric Dumazet (2):
> inet: returns a bool from inet_sk_get_local_port_range()
> tcp/dccp: change source port selection at connect() time
>
> include/net/ip.h | 2 +-
> net/ipv4/inet_connection_sock.c | 21 ++++++++++++++++-----
> net/ipv4/inet_hashtables.c | 27 ++++++++++++++++-----------
> 3 files changed, 33 insertions(+), 17 deletions(-)
This is great. Thank you.
# sysctl net.ipv4.ip_local_port_range
net.ipv4.ip_local_port_range = 32768 60999
# { sleep 3; stress-ng --sockmany 1 --sockmany-ops 20000; } & \
> /usr/share/bcc/tools/funclatency inet_hash_connect
[1] 240
Tracing 1 functions for "inet_hash_connect"... Hit Ctrl-C to end.
stress-ng: info: [243] defaulting to a 1 day, 0 secs run per stressor
stress-ng: info: [243] dispatching hogs: 1 sockmany
stress-ng: info: [243] skipped: 0
stress-ng: info: [243] passed: 1: sockmany (1)
stress-ng: info: [243] failed: 0
stress-ng: info: [243] metrics untrustworthy: 0
stress-ng: info: [243] successful run completed in 27.60 secs
^C
nsecs : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 0 | |
8 -> 15 : 0 | |
16 -> 31 : 0 | |
32 -> 63 : 0 | |
64 -> 127 : 0 | |
128 -> 255 : 0 | |
256 -> 511 : 0 | |
512 -> 1023 : 511 |** |
1024 -> 2047 : 8698 |****************************************|
2048 -> 4095 : 2870 |************* |
4096 -> 8191 : 1471 |****** |
8192 -> 16383 : 389 |* |
16384 -> 32767 : 114 | |
32768 -> 65535 : 43 | |
65536 -> 131071 : 15 | |
131072 -> 262143 : 0 | |
262144 -> 524287 : 1 | |
524288 -> 1048575 : 1 | |
1048576 -> 2097151 : 3 | |
2097152 -> 4194303 : 1609 |******* |
4194304 -> 8388607 : 4272 |******************* |
8388608 -> 16777215 : 4 | |
avg = 1314821 nsecs, total: 26297744706 nsecs, count: 20001
Detaching...
[1]+ Done { sleep 3; stress-ng --sockmany 1 --sockmany-ops 20000; }
# { sleep 3; LD_PRELOAD=./setsockopt_ip_local_port_range.so stress-ng --sockmany 1 --sockmany-ops 20000; } & \
> /usr/share/bcc/tools/funclatency inet_hash_connect
[1] 246
Tracing 1 functions for "inet_hash_connect"... Hit Ctrl-C to end.
stress-ng: info: [249] defaulting to a 1 day, 0 secs run per stressor
stress-ng: info: [249] dispatching hogs: 1 sockmany
stress-ng: info: [249] skipped: 0
stress-ng: info: [249] passed: 1: sockmany (1)
stress-ng: info: [249] failed: 0
stress-ng: info: [249] metrics untrustworthy: 0
stress-ng: info: [249] successful run completed in 1.01 secs
^C
nsecs : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 0 | |
8 -> 15 : 0 | |
16 -> 31 : 0 | |
32 -> 63 : 0 | |
64 -> 127 : 0 | |
128 -> 255 : 0 | |
256 -> 511 : 0 | |
512 -> 1023 : 2085 |****** |
1024 -> 2047 : 13401 |****************************************|
2048 -> 4095 : 3877 |*********** |
4096 -> 8191 : 561 |* |
8192 -> 16383 : 60 | |
16384 -> 32767 : 16 | |
32768 -> 65535 : 2 | |
avg = 1768 nsecs, total: 35376609 nsecs, count: 20002
Detaching...
[1]+ Done { sleep 3; LD_PRELOAD=./setsockopt_ip_local_port_range.so stress-ng --sockmany 1 --sockmany-ops 20000; }
# cat ./setsockopt_ip_local_port_range.c
#include <dlfcn.h>
#include <linux/in.h>
#include <sys/socket.h>
int socket(int domain, int type, int protocol)
{
int (*socket_fn)(int, int, int) = dlsym(RTLD_NEXT, "socket");
int fd;
fd = socket_fn(domain, type, protocol);
if (fd < 0)
return -1;
if (domain == AF_INET || domain == AF_INET6) {
setsockopt(fd, IPPROTO_IP, IP_LOCAL_PORT_RANGE,
&(__u32){ 0xffffU << 16 }, sizeof(__u32));
}
return fd;
}
#
next prev parent reply other threads:[~2024-01-03 14:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 19:29 [PATCH net-next 0/2] tcp/dccp: refine source port selection Eric Dumazet
2023-12-14 19:29 ` [PATCH net-next 1/2] inet: returns a bool from inet_sk_get_local_port_range() Eric Dumazet
2023-12-15 1:50 ` Kuniyuki Iwashima
2023-12-14 19:29 ` [PATCH net-next 2/2] tcp/dccp: change source port selection at connect() time Eric Dumazet
2023-12-15 1:58 ` Kuniyuki Iwashima
2023-12-15 2:26 ` Jason Xing
2023-12-16 2:10 ` [PATCH net-next 0/2] tcp/dccp: refine source port selection patchwork-bot+netdevbpf
2024-01-03 14:17 ` Jakub Sitnicki [this message]
2024-01-03 16:48 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sf3e8ppa.fsf@cloudflare.com \
--to=jakub@cloudflare.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).