From: Longjun Tang <lange_tang@163.com>
To: mst@redhat.com, kuba@kernel.org
Cc: jasowangio@gmail.com, xuanzhuo@linux.alibaba.com,
virtualization@lists.linux.dev, netdev@vger.kernel.org,
tanglongjun@kylinos.cn
Subject: [RFC PATCH 3/3] virtio_net: add rx_timeouts per-queue statistic
Date: Fri, 28 Aug 2026 15:43:26 +0800 [thread overview]
Message-ID: <20260828074326.65594-4-lange_tang@163.com> (raw)
In-Reply-To: <20260828074326.65594-1-lange_tang@163.com>
From: Longjun Tang <tanglongjun@kylinos.cn>
Add an rx_timeouts field to the per-queue RX statistics, expose
it via ethtool and increment it when the RX watchdog fires,
so RX watchdog timeouts can be observed per queue.
Assisted-by: Kilo:deepseek-v4-pro
Signed-off-by: Longjun Tang <tanglongjun@kylinos.cn>
---
drivers/net/virtio_net.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 02d0c4a67360..44a093604d82 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -134,6 +134,7 @@ struct virtnet_rq_stats {
u64_stats_t xdp_redirects;
u64_stats_t xdp_drops;
u64_stats_t kicks;
+ u64_stats_t rx_timeouts;
};
#define VIRTNET_SQ_STAT(name, m) {name, offsetof(struct virtnet_sq_stats, m), -1}
@@ -167,6 +168,7 @@ static const struct virtnet_stat_desc virtnet_rq_stats_desc[] = {
VIRTNET_RQ_STAT("xdp_redirects", xdp_redirects),
VIRTNET_RQ_STAT("xdp_drops", xdp_drops),
VIRTNET_RQ_STAT("kicks", kicks),
+ VIRTNET_RQ_STAT("rx_timeouts", rx_timeouts),
};
static const struct virtnet_stat_desc virtnet_sq_stats_desc_qstat[] = {
@@ -3069,8 +3071,9 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
*
* 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.
+ * no new interrupt for rx_watchdog_timeo seconds. On detection it
+ * records the event in the per-queue rx_timeouts statistic and logs a
+ * warning.
*/
static void virtnet_rx_watchdog(struct timer_list *t)
{
@@ -3102,6 +3105,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);
+
netdev_warn(vi->dev, "RX queue %u stalled for %u ms\n",
i, stall_ms);
--
2.43.0
prev parent reply other threads:[~2026-08-28 7:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 7:43 [RFC PATCH 0/3] virtio_net: introduce an RX queue watchdog for stuck detection Longjun Tang
2026-08-28 7:43 ` [RFC PATCH 1/3] virtio: add virtqueue_get_last_used_idx() helper Longjun Tang
2026-08-28 7:43 ` [RFC PATCH 2/3] virtio_net: introduce an RX queue watchdog for stuck detection Longjun Tang
2026-08-28 7:43 ` Longjun Tang [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=20260828074326.65594-4-lange_tang@163.com \
--to=lange_tang@163.com \
--cc=jasowangio@gmail.com \
--cc=kuba@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=tanglongjun@kylinos.cn \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/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