From: Magnus Karlsson <magnus.karlsson@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Li RongQing <lirongqing@baidu.com>,
Network Development <netdev@vger.kernel.org>,
bpf <bpf@vger.kernel.org>,
"Karlsson, Magnus" <magnus.karlsson@intel.com>
Subject: Re: [PATCH][V2] libbpf: add support for canceling cached_cons advance
Date: Wed, 25 Nov 2020 09:30:53 +0100 [thread overview]
Message-ID: <CAJ8uoz1JdmHc9nwa4cY20S-GN62RAJUEPGY4LcmdTM4FjuGTow@mail.gmail.com> (raw)
In-Reply-To: <fe9eeaa5-d40a-9be4-a96b-cdd80095da47@iogearbox.net>
On Tue, Nov 24, 2020 at 10:58 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 11/24/20 9:12 AM, Magnus Karlsson wrote:
> > On Tue, Nov 24, 2020 at 8:33 AM Li RongQing <lirongqing@baidu.com> wrote:
> >>
> >> Add a new function for returning descriptors the user received
> >> after an xsk_ring_cons__peek call. After the application has
> >> gotten a number of descriptors from a ring, it might not be able
> >> to or want to process them all for various reasons. Therefore,
> >> it would be useful to have an interface for returning or
> >> cancelling a number of them so that they are returned to the ring.
> >>
> >> This patch adds a new function called xsk_ring_cons__cancel that
> >> performs this operation on nb descriptors counted from the end of
> >> the batch of descriptors that was received through the peek call.
> >>
> >> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> >> [ Magnus Karlsson: rewrote changelog ]
> >> Cc: Magnus Karlsson <magnus.karlsson@intel.com>
> >> ---
> >> diff with v1: fix the building, and rewrote changelog
> >>
> >> tools/lib/bpf/xsk.h | 6 ++++++
> >> 1 file changed, 6 insertions(+)
> >>
> >> diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h
> >> index 1069c46364ff..1719a327e5f9 100644
> >> --- a/tools/lib/bpf/xsk.h
> >> +++ b/tools/lib/bpf/xsk.h
> >> @@ -153,6 +153,12 @@ static inline size_t xsk_ring_cons__peek(struct xsk_ring_cons *cons,
> >> return entries;
> >> }
> >>
> >> +static inline void xsk_ring_cons__cancel(struct xsk_ring_cons *cons,
> >> + size_t nb)
> >> +{
> >> + cons->cached_cons -= nb;
> >> +}
> >> +
> >> static inline void xsk_ring_cons__release(struct xsk_ring_cons *cons, size_t nb)
> >> {
> >> /* Make sure data has been read before indicating we are done
> >> --
> >> 2.17.3
> >
> > Thank you RongQing.
> >
> > Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
>
> @Magnus: shouldn't the xsk_ring_cons__cancel() nb type be '__u32 nb' instead?
All the other interfaces have size_t as the type for "nb". It is kind
of weird as a __u32 would have made more sense, but cannot actually
remember why I chose a size_t two years ago. But for consistency with
the other interfaces, let us keep it a size_t for now. I will do some
research around the reason.
> Thanks,
> Daniel
next prev parent reply other threads:[~2020-11-25 8:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 7:21 [PATCH][V2] libbpf: add support for canceling cached_cons advance Li RongQing
2020-11-24 8:12 ` Magnus Karlsson
2020-11-24 21:58 ` Daniel Borkmann
2020-11-25 8:30 ` Magnus Karlsson [this message]
2020-11-25 9:02 ` Daniel Borkmann
2020-11-25 9:13 ` Magnus Karlsson
2020-11-25 10:06 ` Daniel Borkmann
2020-11-25 10:09 ` Magnus Karlsson
2020-11-25 12:22 ` Daniel Borkmann
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=CAJ8uoz1JdmHc9nwa4cY20S-GN62RAJUEPGY4LcmdTM4FjuGTow@mail.gmail.com \
--to=magnus.karlsson@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=lirongqing@baidu.com \
--cc=magnus.karlsson@intel.com \
--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).