From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Stanislav Fomichev <stfomichev@gmail.com>
Cc: Jason Xing <kerneljasonxing@gmail.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<bjorn@kernel.org>, <magnus.karlsson@intel.com>,
<jonathan.lemon@gmail.com>, <sdf@fomichev.me>, <ast@kernel.org>,
<daniel@iogearbox.net>, <hawk@kernel.org>,
<john.fastabend@gmail.com>, <joe@dama.to>,
<willemdebruijn.kernel@gmail.com>, <bpf@vger.kernel.org>,
<netdev@vger.kernel.org>, Jason Xing <kernelxing@tencent.com>
Subject: Re: [PATCH net-next] net: xsk: update tx queue consumer immdiately after transmission
Date: Fri, 20 Jun 2025 17:35:36 +0200 [thread overview]
Message-ID: <aFV/yG6pFEPwrwDz@boxer> (raw)
In-Reply-To: <aFVr60tw3QJopcOo@mini-arch>
On Fri, Jun 20, 2025 at 07:10:51AM -0700, Stanislav Fomichev wrote:
> On 06/19, Jason Xing wrote:
> > From: Jason Xing <kernelxing@tencent.com>
> >
> > For afxdp, the return value of sendto() syscall doesn't reflect how many
> > descs handled in the kernel. One of use cases is that when user-space
> > application tries to know the number of transmitted skbs and then decides
> > if it continues to send, say, is it stopped due to max tx budget?
> >
> > The following formular can be used after sending to learn how many
> > skbs/descs the kernel takes care of:
> >
> > tx_queue.consumers_before - tx_queue.consumers_after
> >
> > Prior to the current patch, the consumer of tx queue is not immdiately
> > updated at the end of each sendto syscall, which leads the consumer
> > value out-of-dated from the perspective of user space. So this patch
> > requires store operation to pass the cached value to the shared value
> > to handle the problem.
> >
> > Signed-off-by: Jason Xing <kernelxing@tencent.com>
> > ---
> > net/xdp/xsk.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> > index 7c47f665e9d1..3288ab2d67b4 100644
> > --- a/net/xdp/xsk.c
> > +++ b/net/xdp/xsk.c
> > @@ -856,6 +856,8 @@ static int __xsk_generic_xmit(struct sock *sk)
> > }
> >
> > out:
> > + __xskq_cons_release(xs->tx);
> > +
> > if (sent_frame)
> > if (xsk_tx_writeable(xs))
> > sk->sk_write_space(sk);
>
> So for the "good" case we are going to write the cons twice? From
> xskq_cons_peek_desc and from here? Maybe make this __xskq_cons_release
> conditional ('if (err)')?
this patch updates a global state of producer whereas generic xmit loop
updates local value. this global state is also updated within peeking
function.
from quick look patch seems to be correct however my mind is in vacation
mode so i'll take a second look on monday.
>
> I also wonder whether we should add a test for that? Should be easy to
> verify by sending more than 32 packets. Is there a place in
> tools/testing/selftests/bpf/xskxceiver.c to add that?
next prev parent reply other threads:[~2025-06-20 15:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 9:36 [PATCH net-next] net: xsk: update tx queue consumer immdiately after transmission Jason Xing
2025-06-20 14:10 ` Stanislav Fomichev
2025-06-20 15:25 ` Jason Xing
2025-06-20 15:58 ` Stanislav Fomichev
2025-06-20 16:26 ` Jason Xing
2025-06-20 16:29 ` Jason Xing
2025-06-23 5:31 ` Jason Xing
2025-06-20 15:35 ` Maciej Fijalkowski [this message]
2025-06-20 15:42 ` Jason Xing
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=aFV/yG6pFEPwrwDz@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=joe@dama.to \
--cc=john.fastabend@gmail.com \
--cc=jonathan.lemon@gmail.com \
--cc=kerneljasonxing@gmail.com \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=stfomichev@gmail.com \
--cc=willemdebruijn.kernel@gmail.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;
as well as URLs for NNTP newsgroup(s).