[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8aad5ff9-6eab-411d-9569-9a2303561ac0@gmail.com>
Date: Thu, 3 Apr 2025 17:43:26 +0700
From: Bui Quang Minh <minhquangbui99@...il.com>
To: virtualization@...ts.linux.dev
Cc: "Michael S . Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, Andrew Lunn <andrew+netdev@...n.ch>,
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>,
Eugenio PĂ©rez <eperezma@...hat.com>,
"David S . Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH] virtio-net: disable delayed refill when setting up xdp
On 4/2/25 12:42, Bui Quang Minh wrote:
> When setting up XDP for a running interface, we call napi_disable() on
> the receive queue's napi. In delayed refill_work, it also calls
> napi_disable() on the receive queue's napi. This can leads to deadlock
> when napi_disable() is called on an already disabled napi. This commit
> fixes this by disabling future and cancelling all inflight delayed
> refill works before calling napi_disabled() in virtnet_xdp_set.
>
> Fixes: 4941d472bf95 ("virtio-net: do not reset during XDP set")
> Signed-off-by: Bui Quang Minh <minhquangbui99@...il.com>
> ---
> drivers/net/virtio_net.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7e4617216a4b..33406d59efe2 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -5956,6 +5956,15 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
> if (!prog && !old_prog)
> return 0;
>
> + /*
> + * Make sure refill_work does not run concurrently to
> + * avoid napi_disable race which leads to deadlock.
> + */
> + if (netif_running(dev)) {
> + disable_delayed_refill(vi);
> + cancel_delayed_work_sync(&vi->refill);
> + }
> +
> if (prog)
> bpf_prog_add(prog, vi->max_queue_pairs - 1);
>
> @@ -6004,6 +6013,8 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
> virtnet_napi_tx_enable(&vi->sq[i]);
> }
> }
> + if (netif_running(dev))
> + enable_delayed_refill(vi);
While doing some testing, it look likes that we must call try_fill_recv
to resume the rx path. I'll do more testing and send a new v2 patch.
>
> return 0;
>
> @@ -6019,6 +6030,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
> virtnet_napi_enable(&vi->rq[i]);
> virtnet_napi_tx_enable(&vi->sq[i]);
> }
> + enable_delayed_refill(vi);
> }
> if (prog)
> bpf_prog_sub(prog, vi->max_queue_pairs - 1);
Powered by blists - more mailing lists