bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn.topel@gmail.com>
To: Will Deacon <will@kernel.org>
Cc: "Daniel Borkmann" <daniel@iogearbox.net>,
	"John Fastabend" <john.fastabend@gmail.com>,
	Netdev <netdev@vger.kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Björn Töpel" <bjorn.topel@intel.com>, bpf <bpf@vger.kernel.org>,
	"Karlsson, Magnus" <magnus.karlsson@intel.com>,
	"Jonathan Lemon" <jonathan.lemon@gmail.com>,
	mark.rutland@arm.com
Subject: Re: [PATCH bpf-next] xsk: update rings for load-acquire/store-release semantics
Date: Tue, 17 Mar 2020 20:14:09 +0100	[thread overview]
Message-ID: <CAJ+HfNh=XuCU3QBSbJZ-qEj-fx+JrB_iiJGpqKQmOwEjvAROpg@mail.gmail.com> (raw)
In-Reply-To: <20200316184423.GA14143@willie-the-truck>

On Mon, 16 Mar 2020 at 19:44, Will Deacon <will@kernel.org> wrote:
>
> On Tue, Jan 21, 2020 at 12:50:23PM +0100, Björn Töpel wrote:
> > On Tue, 21 Jan 2020 at 00:51, Daniel Borkmann <daniel@iogearbox.net> wrote:
> > >
> > > On 1/20/20 10:21 AM, Björn Töpel wrote:
> > > > From: Björn Töpel <bjorn.topel@intel.com>
> > > >
> > > > Currently, the AF_XDP rings uses fences for the kernel-side
> > > > produce/consume functions. By updating rings for
> > > > load-acquire/store-release semantics, the full barrier (smp_mb()) on
> > > > the consumer side can be replaced.
> > > >
> > > > Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
> > >
> > > If I'm not missing something from the ring update scheme, don't you also need
> > > to adapt to STORE.rel ->producer with matching barrier in tools/lib/bpf/xsk.h ?
> > >
> >
> > Daniel/John,
> >
> > Hmm, I was under the impression that *wasn't* the case. Quoting
> > memory-barriers.txt:
> >
> > --8<--
> > When dealing with CPU-CPU interactions, certain types of memory
> > barrier should always be paired.  A lack of appropriate pairing is
> > almost certainly an error.
> >
> > General barriers pair with each other, though they also pair with most
> > other types of barriers, albeit without multicopy atomicity.  An
> > acquire barrier pairs with a release barrier, but both may also pair
> > with other barriers, including of course general barriers.  A write
> > barrier pairs with a data dependency barrier, a control dependency, an
> > acquire barrier, a release barrier, a read barrier, or a general
> > barrier.  Similarly a read barrier, control dependency, or a data
> > dependency barrier pairs with a write barrier, an acquire barrier, a
> > release barrier, or a general barrier:
> > -->8--
>
> The key part here is "albeit without multicopy atomicity". I don't think
> you care about that at all for these rings as you're very clearly passing a
> message from the producer side to the consumer side in a point-to-point like
> manner, so I think you're ok to change the kernel independently from
> userspace (but I would still recommend updating both eventually).
>
> The only thing you might run into is if anybody is relying on the smp_mb()
> in the consumer to order other unrelated stuff either side of the consume
> operation (or even another consume operation to a different ring!), but it
> looks like you can't rely on that in the xsk queue implementation anyway
> because you cache the global state and so the barriers are conditional.
>

Thanks for getting back, and for the clarification! I'll do a respin
(as part of a another series) that include the userland changes.

Cheers,
Björn

> Will

  reply	other threads:[~2020-03-17 19:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20  9:21 [PATCH bpf-next] xsk: update rings for load-acquire/store-release semantics Björn Töpel
2020-01-20 23:27 ` Daniel Borkmann
2020-01-21 11:50   ` Björn Töpel
2020-03-16 18:44     ` Will Deacon
2020-03-17 19:14       ` Björn Töpel [this message]
2020-03-17 21:03         ` Will Deacon
2020-01-21  1:24 ` John Fastabend

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='CAJ+HfNh=XuCU3QBSbJZ-qEj-fx+JrB_iiJGpqKQmOwEjvAROpg@mail.gmail.com' \
    --to=bjorn.topel@gmail.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=jonathan.lemon@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=will@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).