Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Eric Dumazet <edumazet@google.com>,  Paolo Abeni <pabeni@redhat.com>
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 netdev@vger.kernel.org,  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: Re: [RFC PATCH 0/2] udp: avoid false sharing on sk_tsflags
Date: Mon, 10 Feb 2025 12:53:49 -0500	[thread overview]
Message-ID: <67aa3d2d6df73_6ea21294e6@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <CANn89iLaDEjuDAE-Bupi4iDjt4wa90NA8bRjH8_0qWOQpHJ98Q@mail.gmail.com>

Eric Dumazet wrote:
> On Mon, Feb 10, 2025 at 5:16 PM Paolo Abeni <pabeni@redhat.com> wrote:
> >
> > On 2/10/25 4:13 PM, Eric Dumazet wrote:
> > > On Mon, Feb 10, 2025 at 5:00 AM Willem de Bruijn
> > > <willemdebruijn.kernel@gmail.com> wrote:
> > >>
> > >> Paolo Abeni wrote:
> > >>> 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.
> > >>
> > >> The code looks solid at a high level to me.
> > >>
> > >> But if the issue can be adddressed by just moving a field, that is
> > >> quite appealing. So have no reviewed closely yet.
> > >>
> > >
> > > sk_tsflags has not been put in an optimal group, I would indeed move it,
> > > even if this creates one hole.
> > >
> > > Holes tend to be used quite fast anyway with new fields.
> > >
> > > Perhaps sock_read_tx group would be the best location,
> > > because tcp_recv_timestamp() is not called in the fast path.
> >
> > Just to wrap my head on the above reasoning: for UDP such a change could
> > possibly increase the number of `struct sock` cache-line accessed in the
> > RX path (the `sock_write_tx` group should not be touched otherwise) but
> > that will not matter much, because we expect a low number of UDP sockets
> > in the system, right?
> 
> Are you referring to UDP applications needing timestamps ?
> 
> Because sk_tsflags is mostly always used in TX

I thought the issue on rx was with the test in sock_recv_cmsgs.

  reply	other threads:[~2025-02-10 17:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07 16:23 [RFC PATCH 0/2] udp: avoid false sharing on sk_tsflags Paolo Abeni
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 [this message]
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=67aa3d2d6df73_6ea21294e6@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.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=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