Re: [RFC Optimizing veth xsk performance 05/10] veth: use send queue tx napi to xmit xsk tx desc
From: Simon Horman
Date: Fri Aug 04 2023 - 16:59:44 EST
On Thu, Aug 03, 2023 at 10:04:31PM +0800, huangjie.albert wrote:
Please include a patch description.
> Signed-off-by: huangjie.albert <huangjie.albert@xxxxxxxxxxxxx>
Please consider formatting this as:
... Albert Huang <huangjie.albert@xxxxxxxxxxxxx>
> ---
> drivers/net/veth.c | 265 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 264 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 63c3ebe4c5d0..944761807ca4 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -27,6 +27,8 @@
> #include <linux/bpf_trace.h>
> #include <linux/net_tstamp.h>
> #include <net/page_pool.h>
> +#include <net/xdp_sock_drv.h>
> +#include <net/xdp.h>
>
> #define DRV_NAME "veth"
> #define DRV_VERSION "1.0"
> @@ -1061,6 +1063,176 @@ static int veth_poll(struct napi_struct *napi, int budget)
> return done;
> }
>
> +static int veth_xsk_tx_xmit(struct veth_sq *sq, struct xsk_buff_pool *xsk_pool, int budget)
> +{
> + struct veth_priv *priv, *peer_priv;
> + struct net_device *dev, *peer_dev;
> + struct veth_rq *peer_rq;
> + struct veth_stats peer_stats = {};
> + struct veth_stats stats = {};
> + struct veth_xdp_tx_bq bq;
> + struct xdp_desc desc;
> + void *xdpf;
> + int done = 0;
Please try to use reverse xmas tree ordering - longest line to shortest -
for local variable declarations in new Networking code.
https://github.com/ecree-solarflare/xmastree is your friend here.
> +
> + bq.count = 0;
> + dev = sq->dev;
> + priv = netdev_priv(dev);
> + peer_dev = priv->peer;
Sparse seems a bit unhappy about this.
.../veth.c:1081:18: warning: incorrect type in assignment (different address spaces)
.../veth.c:1081:18: expected struct net_device *peer_dev
.../veth.c:1081:18: got struct net_device [noderef] __rcu *peer
Looking over existing code in this file, perhaps this is appropriate:
peer_dev = rtnl_dereference(priv->peer);
Likewise in a few other places in this patch.
...