bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 v2 bpf-next] net: veth: alloc skb in bulk for ndo_xdp_xmit
Date: Fri, 29 Jan 2021 22:41:14 +0100	[thread overview]
Message-ID: <20210129214114.GA20729@lore-desk> (raw)
In-Reply-To: <36298336-72f9-75a5-781e-7cb01dac1702@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2127 bytes --]

> On 2021/01/29 4:41, Lorenzo Bianconi wrote:
> > Split ndo_xdp_xmit and ndo_start_xmit use cases in veth_xdp_rcv routine
> > in order to alloc skbs in bulk for XDP_PASS verdict.
> > Introduce xdp_alloc_skb_bulk utility routine to alloc skb bulk list.
> > The proposed approach has been tested in the following scenario:
> > 
> > eth (ixgbe) --> XDP_REDIRECT --> veth0 --> (remote-ns) veth1 --> XDP_PASS
> > 
> > XDP_REDIRECT: xdp_redirect_map bpf sample
> > XDP_PASS: xdp_rxq_info bpf sample
> > 
> > traffic generator: pkt_gen sending udp traffic on a remote device
> > 
> > bpf-next master: ~3.64Mpps
> > bpf-next + skb bulking allocation: ~3.75Mpps
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> ...
> > +/* frames array contains VETH_XDP_BATCH at most */
> > +static void veth_xdp_rcv_batch(struct veth_rq *rq, void **frames,
> > +			       int n_xdpf, struct veth_xdp_tx_bq *bq,
> > +			       struct veth_stats *stats)
> > +{
> > +	void *skbs[VETH_XDP_BATCH];
> > +	int i, n_skb = 0;
> > +
> > +	for (i = 0; i < n_xdpf; i++) {
> > +		struct xdp_frame *frame = frames[i];
> > +
> > +		stats->xdp_bytes += frame->len;
> > +		frame = veth_xdp_rcv_one(rq, frame, bq, stats);
> > +		if (frame)
> > +			frames[n_skb++] = frame;
> > +	}
> 
> Maybe we can move this block to veth_xdp_rcv() and make the logic even more simple?
> 
> Something like this:
> 
> static int veth_xdp_rcv(struct veth_rq *rq, int budget,
> 	...
> 		if (veth_is_xdp_frame(ptr)) {
> 			struct xdp_frame *frame = veth_ptr_to_xdp(ptr);
> 
> 			stats->xdp_bytes += frame->len;
> 			frame = veth_xdp_rcv_one(rq, frame, bq, stats);
> 			if (frame) {
> 				xdpf[n_xdpf++] = frame;
> 				if (n_xdpf == VETH_XDP_BATCH) {
> 					veth_xdp_rcv_batch(rq, xdpf, n_xdpf, bq,
> 							   stats);
> 					n_xdpf = 0;
> 				}
> 			}
> 
> Then we can fully make use of skb bulk allocation as xdpf[] does not include
> frames which may be XDP_TX'ed or XDP_REDIRECT'ed.
> 
> WDYT?

I gues the code is more readable, I will fix in v3. Thanks.

Regards,
Lorenzo

> 
> Toshiaki Makita

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      parent reply	other threads:[~2021-01-29 21:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <415937741661ac331be09c0e59b4ff1eacfee782.1611861943.git.lorenzo@kernel.org>
     [not found] ` <20210129170216.6a879619@carbon>
2021-01-29 19:17   ` [PATCH v2 bpf-next] net: veth: alloc skb in bulk for ndo_xdp_xmit Jesper Dangaard Brouer
2021-01-29 21:46     ` Lorenzo Bianconi
2021-01-29 21:49       ` Lorenzo Bianconi
2021-02-01 10:06         ` Jesper Dangaard Brouer
     [not found] ` <36298336-72f9-75a5-781e-7cb01dac1702@gmail.com>
2021-01-29 21:41   ` Lorenzo Bianconi [this message]

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=20210129214114.GA20729@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).