From: sashiko-bot@kernel.org
To: "Longjun Tang" <lange_tang@163.com>
Cc: virtualization@lists.linux.dev,
"Eugenio Perez" <eperezma@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [RFC RESEND 2/3] virtio_net: introduce an RX queue watchdog for stuck detection
Date: Wed, 09 Sep 2026 09:27:19 +0000 [thread overview]
Message-ID: <20260909092719.904181F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260908092646.108865-3-lange_tang@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing watchdog state initialization when dynamically increasing receive queues, leading to immediate false stall warnings.
--
commit c9ed39984b2f85816232c0d723aba63e3a109800
Author: Longjun Tang <tanglongjun@kylinos.cn>
virtio_net: introduce an RX queue watchdog for stuck detection
This commit introduces a per-device watchdog to detect stalled RX queues in
virtio-net. The watchdog periodically scans queues and logs a warning if a
queue has a non-zero backlog but makes no progress and receives no interrupts.
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index e34c52d059d39..c28de03c177b3 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
[ ... ]
> @@ -3046,6 +3058,77 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
> return received;
> }
>
> +/*
> + * This watchdog detects that state: a queue is considered stalled when
> + * it has a non-zero backlog, makes no consumption progress and receives
> + * no new interrupt for rx_watchdog_timeo seconds. On detection it logs
> + * a warning.
> + */
> +static void virtnet_rx_watchdog(struct timer_list *t)
> +{
> + struct virtnet_info *vi = timer_container_of(vi, t, rx_watchdog);
> + unsigned long timeout = rx_watchdog_timeo * HZ;
> + int i;
> +
> + if (!rx_watchdog_timeo)
> + return;
> +
> + for (i = 0; i < vi->curr_queue_pairs; i++) {
> + struct receive_queue *rq = &vi->rq[i];
> + u16 last_used = virtqueue_get_last_used_idx(rq->vq);
> + u16 calls = rq->calls;
> + bool backlog = virtqueue_poll(rq->vq, last_used);
> +
> + if (!backlog || last_used != rq->watchdog_last_used_idx ||
> + calls != rq->watchdog_calls) {
> + /* No pending data, or the queue made progress, or a
> + * new interrupt arrived: restart the window.
> + */
> + rq->watchdog_last_used_idx = last_used;
> + rq->watchdog_calls = calls;
> + rq->watchdog_jiffies = jiffies;
> + continue;
> + }
> +
> + if (time_after(jiffies, rq->watchdog_jiffies + timeout)) {
[Severity: Medium]
When receive queues are dynamically increased via ethtool, does this condition
falsely evaluate to true?
Looking at virtnet_set_queues(), it increases vi->curr_queue_pairs but doesn't
initialize watchdog_jiffies for the newly added queues:
virtnet_set_queues() {
...
vi->curr_queue_pairs = queue_pairs;
if (dev->flags & IFF_UP) {
local_bh_disable();
for (int i = 0; i < vi->curr_queue_pairs; ++i)
virtqueue_napi_schedule(&vi->rq[i].napi, vi->rq[i].vq);
local_bh_enable();
}
...
}
If the watchdog timer executes right after NAPI fills the new ring and a
packet is immediately received (making backlog true), the watchdog evaluates
the time_after() condition.
Since watchdog_jiffies remains 0 for the new queues, would this immediately
log a false positive "RX queue stalled" warning with a huge stall time?
> + unsigned int stall_ms =
> + jiffies_to_msecs(jiffies - rq->watchdog_jiffies);
> +
> + netdev_warn(vi->dev, "RX queue %u stalled for %u ms\n",
> + i, stall_ms);
> +
> + /* Rate-limit to one event per timeout. */
> + rq->watchdog_jiffies = jiffies;
> + }
> + }
> +
> + mod_timer(&vi->rx_watchdog, jiffies + HZ);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908092646.108865-1-lange_tang@163.com?part=2
next 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 [this message]
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
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=20260909092719.904181F00A3E@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