All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Joe Damato <jdamato@fastly.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
	netdev@vger.kernel.org, mkarsten@uwaterloo.ca,
	"Michael S. Tsirkin" <mst@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>,
	"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 3/3] virtio_net: Map NAPIs to queues
Date: Mon, 13 Jan 2025 14:04:46 -0800	[thread overview]
Message-ID: <20250113140446.12d7b7d3@kernel.org> (raw)
In-Reply-To: <Z4VNrAI794LixEXt@LQ3V64L9R2>

On Mon, 13 Jan 2025 09:30:20 -0800 Joe Damato wrote:
> > >  static void virtnet_napi_enable_lock(struct virtqueue *vq,
> > > -                                    struct napi_struct *napi)
> > > +                                    struct napi_struct *napi,
> > > +                                    bool need_rtnl)
> > >  {
> > > +       struct virtnet_info *vi = vq->vdev->priv;
> > > +       int q = vq2rxq(vq);
> > > +
> > >         virtnet_napi_do_enable(vq, napi);
> > > +
> > > +       if (q < vi->curr_queue_pairs) {
> > > +               if (need_rtnl)
> > > +                       rtnl_lock();  
> > 
> > Can we tweak the caller to call rtnl_lock() instead to avoid this trick?  
> 
> The major problem is that if the caller calls rtnl_lock() before
> calling virtnet_napi_enable_lock, then virtnet_napi_do_enable (and
> thus napi_enable) happen under the lock.
> 
> Jakub mentioned in a recent change [1] that napi_enable may soon
> need to sleep.
> 
> Given the above constraints, the only way to avoid the "need_rtnl"
> would be to refactor the code much more, placing calls (or wrappers)
> to netif_queue_set_napi in many locations.
> 
> IMHO: This implementation seemed cleaner than putting calls to
> netif_queue_set_napi throughout the driver.
> 
> Please let me know how you'd like to proceed on this.
> 
> [1]: https://lore.kernel.org/netdev/20250111024742.3680902-1-kuba@kernel.org/

I'm going to make netif_queue_set_napi() take netdev->lock, and remove
the rtnl_lock requirement ~this week. If we need conditional locking
perhaps we're better off waiting?

  reply	other threads:[~2025-01-13 22:04 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
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 [this message]
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=20250113140446.12d7b7d3@kernel.org \
    --to=kuba@kernel.org \
    --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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.