From: Paolo Abeni <pabeni@redhat.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
mptcp@lists.linux.dev, David Ahern <dsahern@kernel.org>,
Mat Martineau <mathew.j.martineau@linux.intel.com>,
Matthieu Baerts <matthieu.baerts@tessares.net>
Subject: [PATCH net-next 0/2] udp: avoid false sharing on receive
Date: Wed, 19 Oct 2022 12:01:59 +0200 [thread overview]
Message-ID: <cover.1666173045.git.pabeni@redhat.com> (raw)
Under high UDP load, the BH processing and the user-space receiver can
run on different cores.
The UDP implementation does a lot of effort to avoid false sharing in
the receive path, but recent changes to the struct sock layout moved
the sk_forward_alloc and the sk_rcvbuf fields on the same cacheline:
/* --- cacheline 4 boundary (256 bytes) --- */
struct sk_buff * tail;
} sk_backlog;
int sk_forward_alloc;
unsigned int sk_reserved_mem;
unsigned int sk_ll_usec;
unsigned int sk_napi_id;
int sk_rcvbuf;
sk_forward_alloc is updated by the BH, while sk_rcvbuf is accessed by
udp_recvmsg(), causing false sharing.
A possible solution would be to re-order the struct sock fields to avoid
the false sharing. Such change is subject to being invalidated by future
changes and could have negative side effects on other workload.
Instead this series uses a different approach, touching only the UDP
socket layout.
The first patch generalizes the custom setsockopt infrastructure, to
allow UDP tracking the buffer size, and the second patch addresses the
issue, copying the relevant buffer information into an already hot
cacheline.
Overall the above gives a 10% peek throughput increase under UDP flood.
Paolo Abeni (2):
net: introduce and use custom sockopt socket flag
udp: track the forward memory release threshold in an hot cacheline
include/linux/net.h | 1 +
include/linux/udp.h | 3 +++
net/ipv4/udp.c | 22 +++++++++++++++++++---
net/ipv6/udp.c | 8 ++++++--
net/mptcp/protocol.c | 4 ++++
net/socket.c | 8 +-------
6 files changed, 34 insertions(+), 12 deletions(-)
--
2.37.3
next reply other threads:[~2022-10-19 11:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 10:01 Paolo Abeni [this message]
2022-10-19 10:02 ` [PATCH net-next 1/2] net: introduce and use custom sockopt socket flag Paolo Abeni
2022-10-19 15:16 ` Matthieu Baerts
2022-10-19 10:02 ` [PATCH net-next 2/2] udp: track the forward memory release threshold in an hot cacheline Paolo Abeni
2022-10-19 16:33 ` Kuniyuki Iwashima
2022-10-19 16:58 ` Paolo Abeni
2022-10-19 17:09 ` Kuniyuki Iwashima
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=cover.1666173045.git.pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=mathew.j.martineau@linux.intel.com \
--cc=matthieu.baerts@tessares.net \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
/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).