* [PATCH v2] virtio_net: simplify tx queue wake condition check
@ 2025-07-10 2:32 liming.wu
2025-07-11 23:10 ` patchwork-bot+netdevbpf
2025-07-15 15:31 ` Lei Yang
0 siblings, 2 replies; 3+ messages in thread
From: liming.wu @ 2025-07-10 2:32 UTC (permalink / raw)
To: Michael S . Tsirkin, Jason Wang, Jakub Kicinski
Cc: kvm, virtualization, netdev, linux-kernel, angus.chen, Liming Wu,
Lei Yang
From: Liming Wu <liming.wu@jaguarmicro.com>
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>
---
drivers/net/virtio_net.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 5d674eb9a0f2..07a378220643 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -3021,12 +3021,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);
}
@@ -3218,12 +3217,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);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] virtio_net: simplify tx queue wake condition check
2025-07-10 2:32 [PATCH v2] virtio_net: simplify tx queue wake condition check liming.wu
@ 2025-07-11 23:10 ` patchwork-bot+netdevbpf
2025-07-15 15:31 ` Lei Yang
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-11 23:10 UTC (permalink / raw)
To: Liming Wu
Cc: mst, jasowang, kuba, kvm, virtualization, netdev, linux-kernel,
angus.chen, leiyang
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 10 Jul 2025 10:32:08 +0800 you wrote:
> From: Liming Wu <liming.wu@jaguarmicro.com>
>
> 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.
>
> [...]
Here is the summary with links:
- [v2] virtio_net: simplify tx queue wake condition check
https://git.kernel.org/netdev/net-next/c/2f82e9954662
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] virtio_net: simplify tx queue wake condition check
2025-07-10 2:32 [PATCH v2] virtio_net: simplify tx queue wake condition check liming.wu
2025-07-11 23:10 ` patchwork-bot+netdevbpf
@ 2025-07-15 15:31 ` Lei Yang
1 sibling, 0 replies; 3+ messages in thread
From: Lei Yang @ 2025-07-15 15:31 UTC (permalink / raw)
To: liming.wu
Cc: Michael S . Tsirkin, Jason Wang, Jakub Kicinski, kvm,
virtualization, netdev, linux-kernel, angus.chen
Tested this series of patches v2 with virtio-net regression tests,
everything works fine.
Tested-by: Lei Yang <leiyang@redhat.com>
On Thu, Jul 10, 2025 at 10:32 AM <liming.wu@jaguarmicro.com> wrote:
>
> From: Liming Wu <liming.wu@jaguarmicro.com>
>
> 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>
> ---
> drivers/net/virtio_net.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 5d674eb9a0f2..07a378220643 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -3021,12 +3021,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);
> }
>
> @@ -3218,12 +3217,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);
> }
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-15 15:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 2:32 [PATCH v2] virtio_net: simplify tx queue wake condition check liming.wu
2025-07-11 23:10 ` patchwork-bot+netdevbpf
2025-07-15 15:31 ` Lei Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).