From: Paolo Abeni <pabeni@redhat.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH v2 net-next] net: generalize skb freeing deferral to per-cpu lists
Date: Tue, 26 Apr 2022 17:28:07 +0200 [thread overview]
Message-ID: <b4df9653b93b9b0bdc8a91f5560ec027848200a9.camel@redhat.com> (raw)
In-Reply-To: <CANn89iLuqGdbHkyUcTZd+Ww6vUxqNg0L4eC5Xt8bqLMDmDM18w@mail.gmail.com>
On Tue, 2022-04-26 at 06:11 -0700, Eric Dumazet wrote:
> On Tue, Apr 26, 2022 at 12:38 AM Paolo Abeni <pabeni@redhat.com> wrote:
> > On Fri, 2022-04-22 at 13:12 -0700, Eric Dumazet wrote:
> > [...]
> > > @@ -6571,6 +6577,28 @@ static int napi_threaded_poll(void *data)
> > > return 0;
> > > }
> > >
> > > +static void skb_defer_free_flush(struct softnet_data *sd)
> > > +{
> > > + struct sk_buff *skb, *next;
> > > + unsigned long flags;
> > > +
> > > + /* Paired with WRITE_ONCE() in skb_attempt_defer_free() */
> > > + if (!READ_ONCE(sd->defer_list))
> > > + return;
> > > +
> > > + spin_lock_irqsave(&sd->defer_lock, flags);
> > > + skb = sd->defer_list;
> >
> > I *think* that this read can possibly be fused with the previous one,
> > and another READ_ONCE() should avoid that.
>
> Only the lockless read needs READ_ONCE()
>
> For the one after spin_lock_irqsave(&sd->defer_lock, flags),
> there is no need for any additional barrier.
>
> If the compiler really wants to use multiple one-byte-at-a-time loads,
> we are not going to fight, there might be good reasons for that.
I'm unsure I explained my doubt in a clear way: what I fear is that the
compiler could emit a single read instruction, corresponding to the
READ_ONCE() outside the lock, so that the spin-locked section will
operate on "old" defer_list.
If that happens we could end-up with 'defer_count' underestimating the
list lenght. It looks like that is tolerable, as we will still be
protected vs defer_list growing too much.
Acked-by: Paolo Abeni <pabeni@redhat.com>
next prev parent reply other threads:[~2022-04-26 15:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 20:12 [PATCH v2 net-next] net: generalize skb freeing deferral to per-cpu lists Eric Dumazet
2022-04-26 7:38 ` Paolo Abeni
2022-04-26 13:11 ` Eric Dumazet
2022-04-26 15:28 ` Paolo Abeni [this message]
2022-04-26 16:13 ` Eric Dumazet
2022-04-27 0:50 ` patchwork-bot+netdevbpf
2022-04-27 15:34 ` Ido Schimmel
2022-04-27 16:53 ` Eric Dumazet
2022-04-27 17:11 ` Eric Dumazet
2022-04-27 17:59 ` Eric Dumazet
2022-04-27 18:54 ` Eric Dumazet
2022-04-29 16:18 ` Qian Cai
2022-04-29 16:23 ` Eric Dumazet
2022-04-29 20:44 ` Qian Cai
2022-05-06 6:44 ` [net] 72fd55c0db: invoked_oom-killer:gfp_mask=0x kernel test robot
2022-05-06 8:15 ` 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=b4df9653b93b9b0bdc8a91f5560ec027848200a9.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--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).