mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: Joe Damato <jdamato@fastly.com>, netdev@vger.kernel.org
Cc: mkarsten@uwaterloo.ca, "Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"open list:VIRTIO CORE AND NET DRIVERS"
	<virtualization@lists.linux.dev>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next 2/3] virtio_net: Hold RTNL for NAPI to queue mapping
Date: Fri, 10 Jan 2025 23:22:14 +0100	[thread overview]
Message-ID: <253f7ca1-758a-40f1-aeda-411a6a68e31d@engleder-embedded.com> (raw)
In-Reply-To: <20250110202605.429475-3-jdamato@fastly.com>


On 10.01.25 21:26, Joe Damato wrote:
> Prepare for NAPI to queue mapping by holding RTNL in code paths where
> NAPIs will be mapped to queue IDs and RTNL is not currently held.
> 
> Signed-off-by: Joe Damato <jdamato@fastly.com>
> ---
>   drivers/net/virtio_net.c | 17 ++++++++++++++---
>   1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index cff18c66b54a..4e88d352d3eb 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -2803,11 +2803,17 @@ static void virtnet_napi_do_enable(struct virtqueue *vq,
>   	local_bh_enable();
>   }
>   
> -static void virtnet_napi_enable(struct virtqueue *vq, struct napi_struct *napi)
> +static void virtnet_napi_enable_lock(struct virtqueue *vq,
> +				     struct napi_struct *napi)
>   {
>   	virtnet_napi_do_enable(vq, napi);
>   }
>   
> +static void virtnet_napi_enable(struct virtqueue *vq, struct napi_struct *napi)
> +{
> +	virtnet_napi_enable_lock(vq, napi);
> +}
> +
>   static void virtnet_napi_tx_enable(struct virtnet_info *vi,
>   				   struct virtqueue *vq,
>   				   struct napi_struct *napi)
> @@ -2844,7 +2850,7 @@ static void refill_work(struct work_struct *work)
>   
>   		napi_disable(&rq->napi);
>   		still_empty = !try_fill_recv(vi, rq, GFP_KERNEL);
> -		virtnet_napi_enable(rq->vq, &rq->napi);
> +		virtnet_napi_enable_lock(rq->vq, &rq->napi);
>   
>   		/* In theory, this can happen: if we don't get any buffers in
>   		 * we will *never* try to fill again.
> @@ -5621,8 +5627,11 @@ static void virtnet_freeze_down(struct virtio_device *vdev)
>   	netif_tx_lock_bh(vi->dev);
>   	netif_device_detach(vi->dev);
>   	netif_tx_unlock_bh(vi->dev);
> -	if (netif_running(vi->dev))
> +	if (netif_running(vi->dev)) {
> +		rtnl_lock();
>   		virtnet_close(vi->dev);
> +		rtnl_unlock();
> +	}
>   }
>   
>   static int init_vqs(struct virtnet_info *vi);
> @@ -5642,7 +5651,9 @@ static int virtnet_restore_up(struct virtio_device *vdev)
>   	enable_rx_mode_work(vi);
>   
>   	if (netif_running(vi->dev)) {
> +		rtnl_lock();
>   		err = virtnet_open(vi->dev);
> +		rtnl_unlock();
>   		if (err)
>   			return err;
>   	}

Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>

  reply	other threads:[~2025-01-10 22:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10 20:26 [PATCH net-next 0/3] virtio_net: Link queues to NAPIs Joe Damato
2025-01-10 20:26 ` [PATCH net-next 1/3] virtio_net: Prepare for NAPI to queue mapping Joe Damato
2025-01-10 22:21   ` Gerhard Engleder
2025-01-10 20:26 ` [PATCH net-next 2/3] virtio_net: Hold RTNL " Joe Damato
2025-01-10 22:22   ` Gerhard Engleder [this message]
2025-01-10 20:26 ` [PATCH net-next 3/3] virtio_net: Map NAPIs to queues Joe Damato
2025-01-10 22:25   ` Gerhard Engleder
2025-01-13  4:05   ` Jason Wang
2025-01-13 17:30     ` Joe Damato
2025-01-13 22:04       ` Jakub Kicinski
2025-01-13 22:23         ` Joe Damato
2025-01-13 22:32           ` Jakub Kicinski
2025-01-13  6:03 ` [PATCH net-next 0/3] virtio_net: Link queues to NAPIs Lei Yang

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=253f7ca1-758a-40f1-aeda-411a6a68e31d@engleder-embedded.com \
    --to=gerhard@engleder-embedded.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jdamato@fastly.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkarsten@uwaterloo.ca \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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

all inboxes | Powered by JetHome®