netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: netdev@vger.kernel.org
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	Eric Dumazet <edumazet@google.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
	Neal Cardwell <ncardwell@google.com>,
	David Ahern <dsahern@kernel.org>
Subject: [RFC PATCH 0/2] udp: avoid false sharing on sk_tsflags
Date: Fri,  7 Feb 2025 17:23:43 +0100	[thread overview]
Message-ID: <cover.1738940816.git.pabeni@redhat.com> (raw)

While benchmarking the recently shared page frag revert, I observed a
lot of cache misses in the UDP RX path due to false sharing between the
sk_tsflags and the sk_forward_alloc sk fields.

Here comes a solution attempt for such a problem, inspired by commit
f796feabb9f5 ("udp: add local "peek offset enabled" flag").

The first patch adds a new proto op allowing protocol specific operation
on tsflags updates, and the 2nd one leverages such operation to cache
the problematic field in a cache friendly manner.

The need for a new operation is possibly suboptimal, hence the RFC tag,
but I could not find other good solutions. I considered:
- moving the sk_tsflags just before 'sk_policy', in the 'sock_read_rxtx'
  group. It arguably belongs to such group, but the change would create
  a couple of holes, increasing the 'struct sock' size and would have 
  side effects on other protocols
- moving the sk_tsflags just before 'sk_stamp'; similar to the above,
  would possibly reduce the side effects, as most of 'struct sock'
  layout will be unchanged. Could increase the number of cacheline
  accessed in the TX path.

I opted for the present solution as it should minimize the side effects
to other protocols.

Paolo Abeni (2):
  sock: introduce set_tsflags operation
  udp: avoid false sharing via protocol specific set_tsflags

 include/linux/udp.h | 12 ++++++++++++
 include/net/sock.h  | 15 +++++++++++----
 include/net/tcp.h   |  1 +
 net/core/sock.c     | 24 +++++++++---------------
 net/ipv4/tcp.c      | 16 ++++++++++++++++
 net/ipv4/tcp_ipv4.c |  1 +
 net/ipv4/udp.c      |  3 ++-
 net/ipv6/tcp_ipv6.c |  1 +
 net/ipv6/udp.c      |  3 ++-
 9 files changed, 55 insertions(+), 21 deletions(-)

-- 
2.48.1


             reply	other threads:[~2025-02-07 16:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07 16:23 Paolo Abeni [this message]
2025-02-07 16:23 ` [RFC PATCH 1/2] sock: introduce set_tsflags operation Paolo Abeni
2025-02-07 16:23 ` [RFC PATCH 2/2] udp: avoid false sharing via protocol specific set_tsflags Paolo Abeni
2025-02-10  4:00 ` [RFC PATCH 0/2] udp: avoid false sharing on sk_tsflags Willem de Bruijn
2025-02-10 15:13   ` Eric Dumazet
2025-02-10 16:16     ` Paolo Abeni
2025-02-10 16:37       ` Eric Dumazet
2025-02-10 17:53         ` Willem de Bruijn
2025-02-10 20:54           ` Paolo Abeni
2025-02-10 21:24       ` Paolo Abeni
2025-02-10 21:26         ` Eric Dumazet
2025-02-11  3:16           ` Willem de Bruijn
2025-02-10 21:33         ` Eric Dumazet
2025-02-10  7:49 ` 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=cover.1738940816.git.pabeni@redhat.com \
    --to=pabeni@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemdebruijn.kernel@gmail.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).