XDP-Newbies Archive mirror
 help / color / mirror / Atom feed
From: "Július Milan" <julius.milan.22@gmail.com>
To: xdp-newbies@vger.kernel.org
Subject: thread safe, lock free AF_XDP setup
Date: Mon, 10 Jul 2023 15:43:13 +0200	[thread overview]
Message-ID: <CANaGk7uNc171gmxH=NspPokePc+4eg2qg+jK+kVispnJcwRinA@mail.gmail.com> (raw)

Hi all

I am missing a full understanding of what really is thread safe and
what is not, when using AF_XDP.

RX and TX operations look obvious as every xsk socket has its own RX
and TX rings and so I can have multiple threads, as long as they don't
try to use the same ring of the same socket concurrently, that's the
only limitation (Am I correct yet?). So I can have for example 1:1
mapping of thread to xsk socket to avoid locking.

However what about UMEM rings, i.e. Completion and Fill queue?
About ring operations as __peek, __reserve ..., it is written (for ex.
here: https://www.kernel.org/doc/html/latest/networking/af_xdp.html#rings),
that they are not thread safe.
So it seems that I should use mutex to access them.
But I can see in:
https://github.com/xdp-project/bpf-examples/blob/master/AF_XDP-forwarding/xsk_fwd.c#L526
That they are filled / drained without locking, how is it then?

Does it make a difference if the socket is created by
xsk_socket__create_shared or xsk_socket__create?

What is the limitation that cannot be broken, as I described it for RX
/ TX? (if correctly)

Best Regards
Julius

             reply	other threads:[~2023-07-10 13:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10 13:43 Július Milan [this message]
2023-07-10 13:57 ` thread safe, lock free AF_XDP setup Magnus Karlsson
2023-07-10 14:39   ` Július Milan

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='CANaGk7uNc171gmxH=NspPokePc+4eg2qg+jK+kVispnJcwRinA@mail.gmail.com' \
    --to=julius.milan.22@gmail.com \
    --cc=xdp-newbies@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 read-only IMAP folder(s) and NNTP newsgroup(s).