From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Toshiaki Makita <toshiaki.makita1@gmail.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, davem@davemloft.net,
kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net,
lorenzo.bianconi@redhat.com, brouer@redhat.com, toke@redhat.com
Subject: Re: [PATCH bpf-next 1/3] net: veth: introduce bulking for XDP_PASS
Date: Thu, 28 Jan 2021 18:41:26 +0100 [thread overview]
Message-ID: <20210128174126.GA2965@lore-desk> (raw)
In-Reply-To: <de16aab2-58a5-dd0b-1577-4fa04a6806ce@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2779 bytes --]
> On 2021/01/27 3:41, Lorenzo Bianconi wrote:
> > Introduce bulking support for XDP_PASS verdict forwarding skbs to
> > the networking stack
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > drivers/net/veth.c | 43 ++++++++++++++++++++++++++-----------------
> > 1 file changed, 26 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> > index 6e03b619c93c..23137d9966da 100644
> > --- a/drivers/net/veth.c
> > +++ b/drivers/net/veth.c
> > @@ -35,6 +35,7 @@
> > #define VETH_XDP_HEADROOM (XDP_PACKET_HEADROOM + NET_IP_ALIGN)
> > #define VETH_XDP_TX_BULK_SIZE 16
> > +#define VETH_XDP_BATCH 8
> > struct veth_stats {
> > u64 rx_drops;
> > @@ -787,27 +788,35 @@ static int veth_xdp_rcv(struct veth_rq *rq, int budget,
> > int i, done = 0;
> > for (i = 0; i < budget; i++) {
> > - void *ptr = __ptr_ring_consume(&rq->xdp_ring);
> > - struct sk_buff *skb;
> > + void *frames[VETH_XDP_BATCH];
> > + void *skbs[VETH_XDP_BATCH];
> > + int i, n_frame, n_skb = 0;
>
> 'i' is a shadowed variable. I think this may be confusing.
ack, I will fix it in v2
>
> > - if (!ptr)
> > + n_frame = __ptr_ring_consume_batched(&rq->xdp_ring, frames,
> > + VETH_XDP_BATCH);
>
> This apparently exceeds the budget.
> This will process budget*VETH_XDP_BATCH packets at most.
> (You are probably aware of this because you return 'i' instead of 'done'?)
right, I will fix it in v2
>
> Also I'm not sure if we need to introduce __ptr_ring_consume_batched() here.
> The function just does __ptr_ring_consume() n times.
>
> IIUC Your final code looks like this:
>
> for (budget) {
> n_frame = __ptr_ring_consume_batched(VETH_XDP_BATCH);
> for (n_frame) {
> if (frame is XDP)
> xdpf[n_xdpf++] = to_xdp(frame);
> else
> skbs[n_skb++] = frame;
> }
>
> if (n_xdpf)
> veth_xdp_rcv_batch(xdpf);
>
> for (n_skb) {
> skb = veth_xdp_rcv_skb(skbs[i]);
> napi_gro_receive(skb);
> }
> }
>
> Your code processes VETH_XDP_BATCH packets at a time no matter whether each
> of them is xdp_frame or skb, but I think you actually want to process
> VETH_XDP_BATCH xdp_frames at a time?
> Then, why not doing like this?
>
> for (budget) {
> ptr = __ptr_ring_consume();
> if (ptr is XDP) {
> if (n_xdpf >= VETH_XDP_BATCH) {
> veth_xdp_rcv_batch(xdpf);
> n_xdpf = 0;
> }
> xdpf[n_xdpf++] = to_xdp(ptr);
> } else {
> skb = veth_xdp_rcv_skb(ptr);
> napi_gro_receive(skb);
> }
> }
> if (n_xdpf)
> veth_xdp_rcv_batch(xdpf);
I agree, the code is more readable. I will fix it in v2.
I guess we can drop patch 2/3 and squash patch 1/3 and 3/3.
Regards,
Lorenzo
>
> Toshiaki Makita
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2021-01-28 17:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 18:41 [PATCH bpf-next 0/3] veth: add skb bulking allocation for XDP_PASS Lorenzo Bianconi
2021-01-26 18:41 ` [PATCH bpf-next 1/3] net: veth: introduce bulking " Lorenzo Bianconi
2021-01-28 14:06 ` Jesper Dangaard Brouer
2021-01-28 15:17 ` Toshiaki Makita
2021-01-28 17:41 ` Lorenzo Bianconi [this message]
2021-01-26 18:42 ` [PATCH bpf-next 2/3] net: xdp: move XDP_BATCH_SIZE in common header Lorenzo Bianconi
2021-01-26 18:42 ` [PATCH bpf-next 3/3] net: veth: alloc skb in bulk for ndo_xdp_xmit Lorenzo Bianconi
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=20210128174126.GA2965@lore-desk \
--to=lorenzo@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=toke@redhat.com \
--cc=toshiaki.makita1@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).