From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
lorenzo.bianconi@redhat.com, davem@davemloft.net,
kuba@kernel.org, ast@kernel.org, song@kernel.org,
brouer@redhat.com
Subject: Re: [PATCH v2 bpf-next] cpumap: bulk skb using netif_receive_skb_list
Date: Thu, 15 Apr 2021 17:21:48 +0200 [thread overview]
Message-ID: <20210415172148.4f1e2440@carbon> (raw)
In-Reply-To: <252403c5-d3a7-03fb-24c3-0f328f8f8c70@iogearbox.net>
On Thu, 15 Apr 2021 17:05:36 +0200
Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 4/13/21 6:22 PM, Lorenzo Bianconi wrote:
> > Rely on netif_receive_skb_list routine to send skbs converted from
> > xdp_frames in cpu_map_kthread_run in order to improve i-cache usage.
> > The proposed patch has been tested running xdp_redirect_cpu bpf sample
> > available in the kernel tree that is used to redirect UDP frames from
> > ixgbe driver to a cpumap entry and then to the networking stack.
> > UDP frames are generated using pkt_gen.
> >
> > $xdp_redirect_cpu --cpu <cpu> --progname xdp_cpu_map0 --dev <eth>
> >
> > bpf-next: ~2.2Mpps
> > bpf-next + cpumap skb-list: ~3.15Mpps
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > Changes since v1:
> > - fixed comment
> > - rebased on top of bpf-next tree
> > ---
> > kernel/bpf/cpumap.c | 11 +++++------
> > 1 file changed, 5 insertions(+), 6 deletions(-)
> >
> > diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> > index 0cf2791d5099..d89551a508b2 100644
> > --- a/kernel/bpf/cpumap.c
> > +++ b/kernel/bpf/cpumap.c
> > @@ -27,7 +27,7 @@
> > #include <linux/capability.h>
> > #include <trace/events/xdp.h>
> >
> > -#include <linux/netdevice.h> /* netif_receive_skb_core */
> > +#include <linux/netdevice.h> /* netif_receive_skb_list */
> > #include <linux/etherdevice.h> /* eth_type_trans */
> >
> > /* General idea: XDP packets getting XDP redirected to another CPU,
> > @@ -257,6 +257,7 @@ static int cpu_map_kthread_run(void *data)
> > void *frames[CPUMAP_BATCH];
> > void *skbs[CPUMAP_BATCH];
> > int i, n, m, nframes;
> > + LIST_HEAD(list);
> >
> > /* Release CPU reschedule checks */
> > if (__ptr_ring_empty(rcpu->queue)) {
> > @@ -305,7 +306,6 @@ static int cpu_map_kthread_run(void *data)
> > for (i = 0; i < nframes; i++) {
> > struct xdp_frame *xdpf = frames[i];
> > struct sk_buff *skb = skbs[i];
> > - int ret;
> >
> > skb = __xdp_build_skb_from_frame(xdpf, skb,
> > xdpf->dev_rx);
> > @@ -314,11 +314,10 @@ static int cpu_map_kthread_run(void *data)
> > continue;
> > }
> >
> > - /* Inject into network stack */
> > - ret = netif_receive_skb_core(skb);
> > - if (ret == NET_RX_DROP)
> > - drops++;
> > + list_add_tail(&skb->list, &list);
> > }
> > + netif_receive_skb_list(&list);
> > +
> > /* Feedback loop via tracepoint */
> > trace_xdp_cpumap_kthread(rcpu->map_id, n, drops, sched, &stats);
>
> Given we stop counting drops with the netif_receive_skb_list(), we should then
> also remove drops from trace_xdp_cpumap_kthread(), imho, as otherwise it is rather
> misleading (as in: drops actually happening, but 0 are shown from the tracepoint).
> Given they are not considered stable API, I would just remove those to make it clear
> to users that they cannot rely on this counter anymore anyway.
After Lorenzo's change, the 'drops' still count if kmem_cache_alloc_bulk
cannot alloc SKBs. I guess that will not occur very often. But how
can people/users debug such a case? Maybe the MM-layer can tell us?
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2021-04-15 15:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-13 16:22 [PATCH v2 bpf-next] cpumap: bulk skb using netif_receive_skb_list Lorenzo Bianconi
2021-04-13 17:57 ` Jesper Dangaard Brouer
2021-04-13 19:41 ` Toke Høiland-Jørgensen
2021-04-15 15:05 ` Daniel Borkmann
2021-04-15 15:21 ` Jesper Dangaard Brouer [this message]
2021-04-15 15:55 ` David Ahern
2021-04-15 16:03 ` Lorenzo Bianconi
2021-04-15 18:00 ` David Ahern
2021-04-15 20:10 ` Lorenzo Bianconi
2021-04-15 20:31 ` 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=20210415172148.4f1e2440@carbon \
--to=brouer@redhat.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=song@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).