summaryrefslogtreecommitdiff
path: root/include/net/udp.h
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2022-10-20 20:48:52 +0300
committerDavid S. Miller <davem@davemloft.net>2022-10-24 12:52:50 +0300
commit8a3854c7b8e4532063b14bed34115079b7d0cb36 (patch)
treecd84d6b901d6d1e14185481909982e4f267cd512 /include/net/udp.h
parenta5ef058dc4d9a3e60d1808a0700e18e0e37e408e (diff)
downloadlinux-8a3854c7b8e4532063b14bed34115079b7d0cb36.tar.xz
udp: track the forward memory release threshold in an hot cacheline
When the receiver process and the BH runs on different cores, udp_rmem_release() experience a cache miss while accessing sk_rcvbuf, as the latter shares the same cacheline with sk_forward_alloc, written by the BH. With this patch, UDP tracks the rcvbuf value and its update via custom SOL_SOCKET socket options, and copies the forward memory threshold value used by udp_rmem_release() in a different cacheline, already accessed by the above function and uncontended. Since the UDP socket init operation grown a bit, factor out the common code between v4 and v6 in a shared helper. Overall the above give a 10% peek throughput increase under UDP flood. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Acked-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/udp.h')
-rw-r--r--include/net/udp.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/net/udp.h b/include/net/udp.h
index fee053bcd17c..de4b528522bb 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -174,6 +174,15 @@ INDIRECT_CALLABLE_DECLARE(int udpv6_rcv(struct sk_buff *));
struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
netdev_features_t features, bool is_ipv6);
+static inline void udp_lib_init_sock(struct sock *sk)
+{
+ struct udp_sock *up = udp_sk(sk);
+
+ skb_queue_head_init(&up->reader_queue);
+ up->forward_threshold = sk->sk_rcvbuf >> 2;
+ set_bit(SOCK_CUSTOM_SOCKOPT, &sk->sk_socket->flags);
+}
+
/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
static inline int udp_lib_hash(struct sock *sk)
{