diff options
author | Eric Dumazet <edumazet@google.com> | 2015-10-09 04:33:21 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-13 04:28:20 +0200 |
commit | 70da268b569d32a9fddeea85dc18043de9d89f89 (patch) | |
tree | 6c698924212dcbfbb155e794f6089d2226889f0f /net/core | |
parent | packet: support per-packet fwmark for af_packet sendmsg (diff) | |
download | linux-70da268b569d32a9fddeea85dc18043de9d89f89.tar.xz linux-70da268b569d32a9fddeea85dc18043de9d89f89.zip |
net: SO_INCOMING_CPU setsockopt() support
SO_INCOMING_CPU as added in commit 2c8c56e15df3 was a getsockopt() command
to fetch incoming cpu handling a particular TCP flow after accept()
This commits adds setsockopt() support and extends SO_REUSEPORT selection
logic : If a TCP listener or UDP socket has this option set, a packet is
delivered to this socket only if CPU handling the packet matches the specified
one.
This allows to build very efficient TCP servers, using one listener per
RX queue, as the associated TCP listener should only accept flows handled
in softirq by the same cpu.
This provides optimal NUMA behavior and keep cpu caches hot.
Note that __inet_lookup_listener() still has to iterate over the list of
all listeners. Following patch puts sk_refcnt in a different cache line
to let this iteration hit only shared and read mostly cache lines.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/sock.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 33957776cc1a..dcc7d62654d5 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -988,6 +988,10 @@ set_rcvbuf: sk->sk_max_pacing_rate); break; + case SO_INCOMING_CPU: + sk->sk_incoming_cpu = val; + break; + default: ret = -ENOPROTOOPT; break; @@ -2379,6 +2383,7 @@ void sock_init_data(struct socket *sock, struct sock *sk) sk->sk_max_pacing_rate = ~0U; sk->sk_pacing_rate = ~0U; + sk->sk_incoming_cpu = -1; /* * Before updating sk_refcnt, we must commit prior changes to memory * (Documentation/RCU/rculist_nulls.txt for details) |