]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
virtio_net: simplify tx queue wake condition check
authorLiming Wu <liming.wu@jaguarmicro.com>
Thu, 10 Jul 2025 02:32:08 +0000 (10:32 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 11 Jul 2025 22:59:54 +0000 (15:59 -0700)
Consolidate the two nested if conditions for checking tx queue wake
conditions into a single combined condition. This improves code
readability without changing functionality. And move netif_tx_wake_queue
into if condition to reduce unnecessary checks for queue stops.

Signed-off-by: Liming Wu <liming.wu@jaguarmicro.com>
Tested-by: Lei Yang <leiyang@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://patch.msgid.link/20250710023208.846-1-liming.wu@jaguarmicro.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/virtio_net.c

index 64453f4da82504c5ac84f81eed231fd69abb84fe..90c29753e04ba37ec146f35ebc8ff5ea4d725598 100644 (file)
@@ -3064,12 +3064,11 @@ static void virtnet_poll_cleantx(struct receive_queue *rq, int budget)
                        free_old_xmit(sq, txq, !!budget);
                } while (unlikely(!virtqueue_enable_cb_delayed(sq->vq)));
 
-               if (sq->vq->num_free >= MAX_SKB_FRAGS + 2) {
-                       if (netif_tx_queue_stopped(txq)) {
-                               u64_stats_update_begin(&sq->stats.syncp);
-                               u64_stats_inc(&sq->stats.wake);
-                               u64_stats_update_end(&sq->stats.syncp);
-                       }
+               if (sq->vq->num_free >= MAX_SKB_FRAGS + 2 &&
+                   netif_tx_queue_stopped(txq)) {
+                       u64_stats_update_begin(&sq->stats.syncp);
+                       u64_stats_inc(&sq->stats.wake);
+                       u64_stats_update_end(&sq->stats.syncp);
                        netif_tx_wake_queue(txq);
                }
 
@@ -3261,12 +3260,11 @@ static int virtnet_poll_tx(struct napi_struct *napi, int budget)
        else
                free_old_xmit(sq, txq, !!budget);
 
-       if (sq->vq->num_free >= MAX_SKB_FRAGS + 2) {
-               if (netif_tx_queue_stopped(txq)) {
-                       u64_stats_update_begin(&sq->stats.syncp);
-                       u64_stats_inc(&sq->stats.wake);
-                       u64_stats_update_end(&sq->stats.syncp);
-               }
+       if (sq->vq->num_free >= MAX_SKB_FRAGS + 2 &&
+           netif_tx_queue_stopped(txq)) {
+               u64_stats_update_begin(&sq->stats.syncp);
+               u64_stats_inc(&sq->stats.wake);
+               u64_stats_update_end(&sq->stats.syncp);
                netif_tx_wake_queue(txq);
        }