From: sashiko-bot@kernel.org
To: "Longjun Tang" <lange_tang@163.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
virtualization@lists.linux.dev,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [RFC RESEND 3/3] virtio_net: add rx_timeouts per-queue statistic
Date: Wed, 09 Sep 2026 09:27:18 +0000 [thread overview]
Message-ID: <20260909092718.D3F471F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260908092646.108865-4-lange_tang@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Concurrent writers to per-queue u64_stats_sync from timer context and NAPI violate mutual exclusion.
--
commit 2e5fa229ff4c8c773848d0c1f36b14c2d2f2edf7
Author: Longjun Tang <tanglongjun@kylinos.cn>
virtio_net: add rx_timeouts per-queue statistic
This commit adds an rx_timeouts field to the per-queue RX statistics.
It increments the counter when the RX watchdog fires and exposes it
via ethtool to track per-queue stall events.
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
[ ... ]
> @@ -3094,6 +3097,10 @@ static void virtnet_rx_watchdog(struct timer_list *t)
> unsigned int stall_ms =
> jiffies_to_msecs(jiffies - rq->watchdog_jiffies);
>
> + u64_stats_update_begin(&rq->stats.syncp);
> + u64_stats_inc(&rq->stats.rx_timeouts);
> + u64_stats_update_end(&rq->stats.syncp);
[Severity: High]
Does this introduce a race condition with the NAPI poll loop?
The u64_stats_sync API requires mutually exclusive writers per syncp.
This timer callback (virtnet_rx_watchdog) executes in a global timer softirq
context on an arbitrary CPU and writes to rq->stats.syncp.
Concurrently, NAPI polling executes in the receive queue's bound softirq
context on another CPU and also writes to rq->stats.syncp. Since
rx_timeouts was added to virtnet_rq_stats_desc, NAPI dynamically iterates
over it during virtnet_receive():
drivers/net/virtio_net.c:virtnet_receive() {
...
u64_stats_add(item, u64_stats_read(src));
...
}
Concurrent writers corrupt the sequence counter on 32-bit systems, causing
readers (such as ndo_get_stats64 via ethtool) to spin in an infinite
retry loop.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908092646.108865-1-lange_tang@163.com?part=3
prev parent reply other threads:[~2026-09-09 9:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 9:26 [RFC RESEND 0/3] virtio_net: introduce an RX queue watchdog for stuck detection Longjun Tang
2026-09-08 9:26 ` [RFC RESEND 1/3] virtio: add virtqueue_get_last_used_idx() helper Longjun Tang
2026-09-09 9:27 ` sashiko-bot
2026-09-08 9:26 ` [RFC RESEND 2/3] virtio_net: introduce an RX queue watchdog for stuck detection Longjun Tang
2026-09-09 9:27 ` sashiko-bot
2026-09-08 9:26 ` [RFC RESEND 3/3] virtio_net: add rx_timeouts per-queue statistic Longjun Tang
2026-09-09 9:27 ` sashiko-bot [this message]
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=20260909092718.D3F471F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=eperezma@redhat.com \
--cc=lange_tang@163.com \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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