public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] virtio_net: sync rss_trailer.max_tx_vq on queue_pairs change via VQ_PAIRS_SET
@ 2026-04-16 21:21 Brett Creeley
  2026-04-23  7:01 ` Paolo Abeni
  0 siblings, 1 reply; 3+ messages in thread
From: Brett Creeley @ 2026-04-16 21:21 UTC (permalink / raw)
  To: mst, jasowang, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev
  Cc: brett.creeley

When netif_is_rxfh_configured() is true (i.e., the user has explicitly
configured the RSS indirection table), virtnet_set_queues() skips the
RSS update path and falls through to the VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
command to change the number of queue pairs. However, it does not update
vi->rss_trailer.max_tx_vq to reflect the new queue_pairs value.

This causes a mismatch between vi->curr_queue_pairs and
vi->rss_trailer.max_tx_vq. Any subsequent RSS reconfiguration (e.g.,
via ethtool -X) calls virtnet_commit_rss_command(), which sends the
stale max_tx_vq to the device, silently reverting the queue count.

Reproduction:
1. User configured RSS
  ethtool -X eth0 equal 8
2. VQ_PAIRS_SET path; max_tx_vq stays 16
  ethtool -L eth0 combined 12
3. RSS commit uses max_tx_vq=16 instead of 12
  ethtool -X eth0 equal 4

Fix this by updating vi->rss_trailer.max_tx_vq after a successful
VQ_PAIRS_SET command when RSS is enabled, keeping it in sync with
curr_queue_pairs.

Fixes: 50bfcaedd78e ("virtio_net: Update rss when set queue")
Assisted-by: Claude: claude-opus-4.6
Signed-off-by: Brett Creeley <brett.creeley@amd.com>
---
 drivers/net/virtio_net.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index bfb566fecb92..f4adcfee7a80 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -3759,6 +3759,12 @@ static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs)
 			 queue_pairs);
 		return -EINVAL;
 	}
+
+	/* Keep max_tx_vq in sync so that a later RSS command does not
+	 * revert queue_pairs to a stale value.
+	 */
+	if (vi->has_rss)
+		vi->rss_trailer.max_tx_vq = cpu_to_le16(queue_pairs);
 succ:
 	vi->curr_queue_pairs = queue_pairs;
 	if (dev->flags & IFF_UP) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] virtio_net: sync rss_trailer.max_tx_vq on queue_pairs change via VQ_PAIRS_SET
  2026-04-16 21:21 [PATCH net] virtio_net: sync rss_trailer.max_tx_vq on queue_pairs change via VQ_PAIRS_SET Brett Creeley
@ 2026-04-23  7:01 ` Paolo Abeni
  2026-04-23  8:05   ` Michael S. Tsirkin
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Abeni @ 2026-04-23  7:01 UTC (permalink / raw)
  To: Brett Creeley, mst, jasowang, andrew+netdev, davem, edumazet,
	kuba, netdev, Xuan Zhuo, Eugenio Pérez

On 4/16/26 11:21 PM, Brett Creeley wrote:
> When netif_is_rxfh_configured() is true (i.e., the user has explicitly
> configured the RSS indirection table), virtnet_set_queues() skips the
> RSS update path and falls through to the VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
> command to change the number of queue pairs. However, it does not update
> vi->rss_trailer.max_tx_vq to reflect the new queue_pairs value.
> 
> This causes a mismatch between vi->curr_queue_pairs and
> vi->rss_trailer.max_tx_vq. Any subsequent RSS reconfiguration (e.g.,
> via ethtool -X) calls virtnet_commit_rss_command(), which sends the
> stale max_tx_vq to the device, silently reverting the queue count.
> 
> Reproduction:
> 1. User configured RSS
>   ethtool -X eth0 equal 8
> 2. VQ_PAIRS_SET path; max_tx_vq stays 16
>   ethtool -L eth0 combined 12
> 3. RSS commit uses max_tx_vq=16 instead of 12
>   ethtool -X eth0 equal 4
> 
> Fix this by updating vi->rss_trailer.max_tx_vq after a successful
> VQ_PAIRS_SET command when RSS is enabled, keeping it in sync with
> curr_queue_pairs.
> 
> Fixes: 50bfcaedd78e ("virtio_net: Update rss when set queue")
> Assisted-by: Claude: claude-opus-4.6
> Signed-off-by: Brett Creeley <brett.creeley@amd.com>

The patch LGTM, but waiting a little longer just in case the virtio crew
has some comments.

/P


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] virtio_net: sync rss_trailer.max_tx_vq on queue_pairs change via VQ_PAIRS_SET
  2026-04-23  7:01 ` Paolo Abeni
@ 2026-04-23  8:05   ` Michael S. Tsirkin
  0 siblings, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2026-04-23  8:05 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Brett Creeley, jasowang, andrew+netdev, davem, edumazet, kuba,
	netdev, Xuan Zhuo, Eugenio Pérez

On Thu, Apr 23, 2026 at 09:01:26AM +0200, Paolo Abeni wrote:
> On 4/16/26 11:21 PM, Brett Creeley wrote:
> > When netif_is_rxfh_configured() is true (i.e., the user has explicitly
> > configured the RSS indirection table), virtnet_set_queues() skips the
> > RSS update path and falls through to the VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
> > command to change the number of queue pairs. However, it does not update
> > vi->rss_trailer.max_tx_vq to reflect the new queue_pairs value.
> > 
> > This causes a mismatch between vi->curr_queue_pairs and
> > vi->rss_trailer.max_tx_vq. Any subsequent RSS reconfiguration (e.g.,
> > via ethtool -X) calls virtnet_commit_rss_command(), which sends the
> > stale max_tx_vq to the device, silently reverting the queue count.
> > 
> > Reproduction:
> > 1. User configured RSS
> >   ethtool -X eth0 equal 8
> > 2. VQ_PAIRS_SET path; max_tx_vq stays 16
> >   ethtool -L eth0 combined 12
> > 3. RSS commit uses max_tx_vq=16 instead of 12
> >   ethtool -X eth0 equal 4
> > 
> > Fix this by updating vi->rss_trailer.max_tx_vq after a successful
> > VQ_PAIRS_SET command when RSS is enabled, keeping it in sync with
> > curr_queue_pairs.
> > 
> > Fixes: 50bfcaedd78e ("virtio_net: Update rss when set queue")
> > Assisted-by: Claude: claude-opus-4.6
> > Signed-off-by: Brett Creeley <brett.creeley@amd.com>
> 
> The patch LGTM, but waiting a little longer just in case the virtio crew
> has some comments.
> 
> /P

Acked-by: Michael S. Tsirkin <mst@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-23  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 21:21 [PATCH net] virtio_net: sync rss_trailer.max_tx_vq on queue_pairs change via VQ_PAIRS_SET Brett Creeley
2026-04-23  7:01 ` Paolo Abeni
2026-04-23  8:05   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox