[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACGkMEsSR9uu1n7kFZLDxeje=_JWzadVtqcYizwYRypmnR4Wdw@mail.gmail.com>
Date: Thu, 20 Apr 2023 14:28:59 +0800
From: Jason Wang <jasowang@...hat.com>
To: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
Cc: netdev@...r.kernel.org, "Michael S. Tsirkin" <mst@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
virtualization@...ts.linux-foundation.org, bpf@...r.kernel.org
Subject: Re: [PATCH net-next v2 12/14] virtio_net: small: optimize code
On Tue, Apr 18, 2023 at 2:53 PM Xuan Zhuo <xuanzhuo@...ux.alibaba.com> wrote:
>
> In the case of XDP-PASS, skb_reserve uses the delta to compatible
> non-XDP, now remove this logic.
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
Acked-by: Jason Wang <jasowang@...hat.com>
Thanks
> ---
> drivers/net/virtio_net.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 34220f5f27d1..f6f5903face2 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -959,9 +959,7 @@ static struct sk_buff *receive_small_xdp(struct net_device *dev,
> unsigned int buflen;
> struct xdp_buff xdp;
> struct sk_buff *skb;
> - unsigned int delta = 0;
> unsigned int metasize = 0;
> - void *orig_data;
> u32 act;
>
> if (unlikely(hdr->hdr.gso_type))
> @@ -994,14 +992,12 @@ static struct sk_buff *receive_small_xdp(struct net_device *dev,
> xdp_init_buff(&xdp, buflen, &rq->xdp_rxq);
> xdp_prepare_buff(&xdp, buf + VIRTNET_RX_PAD + vi->hdr_len,
> xdp_headroom, len, true);
> - orig_data = xdp.data;
>
> act = virtnet_xdp_handler(xdp_prog, &xdp, dev, xdp_xmit, stats);
>
> switch (act) {
> case VIRTNET_XDP_RES_PASS:
> /* Recalculate length in case bpf program changed it */
> - delta = orig_data - xdp.data;
> len = xdp.data_end - xdp.data;
> metasize = xdp.data - xdp.data_meta;
> break;
> @@ -1017,7 +1013,7 @@ static struct sk_buff *receive_small_xdp(struct net_device *dev,
> if (!skb)
> goto err;
>
> - skb_reserve(skb, headroom - delta);
> + skb_reserve(skb, xdp.data - buf);
> skb_put(skb, len);
> if (metasize)
> skb_metadata_set(skb, metasize);
> --
> 2.32.0.3.g01195cf9f
>
Powered by blists - more mailing lists