Article View: linux.kernel.netdev
Article #13099[PATCH 0/3] virtio_net: introduce an RX queue watchdog for stuck detection
From: Longjun Tang
Date: Mon, 09 Nov 2026 09:43
Date: Mon, 09 Nov 2026 09:43
67 lines
10906 bytes
10906 bytes
From: Longjun Tang <tanglongjun@kylinos.cn>
Hi Michael, Kuba,
I once ran into a problem where the virtio_net receive queue became
permanently stuck.
The virtio_net RX path relies on backend interrupt notifications.
The backend(vhost_net/vhost-user) appends buffers to the used ring
and then notifies the guest, relying on the hypervisor(KVM) to inject
the interrupt. On receiving it, virtio_net schedules NAPI, drains the
used ring and refills descriptors.
If the hypervisor fails to inject the interrupt(e.g. a transient KVM
failure), the guest never schedules NAPI, so it neither consumes buffers
nor returns descriptors. The backend keeps appending until the ring is full,
then stops and, with no free descriptors left, also stops sending
notifications. Both sides now wait for the other, and the RX queue is
permanently stuck.
The root cause is the lost interrupt in the hypervisor, and the proper
fix belongs there. Nevertheless, I believe virtio_net needs a way to
observe and diagnose it. Today, once a queue hangs, there is no signal
to the operator that anything is wrong: the RX path has no equivalent of
the TX watchdog (ndo_tx_timeout). This series lets virtio_net detect and
recover a stuck RX queue.
Implementation
--------------
Patch 1 exports virtqueue_get_last_used_idx(), a read-only accessor for
the last consumed used ring index. Together with the existing
virtqueue_poll(), it lets a driver ask whether the device has produced
buffers that the driver has not consumed yet ("backlog").
Patch 2 adds a per-device RX watchdog that scans all RX queues once per
second. A queue is considered stuck when, for rx_watchdog_timeo seconds
(default 5, 0 disables it), all of the following hold simultaneously:
- the queue has a non-zero backlog (unconsumed buffers in the used ring);
- the driver makes no consumption progress (last_used unchanged);
- no new interrupt arrives (rq->calls unchanged).
On detection it logs a warning, rate-limited to once per timeout, and
reschedules NAPI, which drains the used ring and refills the descriptors,
so the queue recovers.
Patch 3 adds a per-queue rx_timeouts statistic, exposed via ethtool -S,
so the number of stuck events can be observed per queue.
questions and comments are welcome.
Thanks!
Lange
Longjun Tang (3):
virtio: add virtqueue_get_last_used_idx() helper
virtio_net: introduce an RX queue watchdog for stuck detection
virtio_net: add rx_timeouts per-queue statistic
drivers/net/virtio_net.c | 112 +++++++++++++++++++++++++++++++++++
drivers/virtio/virtio_ring.c | 18 +++++-
include/linux/virtio.h | 2 +
3 files changed, 130 insertions(+), 2 deletions(-)
--
2.51.0
Technical Details
Message-ID:
<20261109094310.103979-1-lange_tang@163.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359183-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359183-linux-kernel-netdev=dewy.ru From: lange_tang@163.com (Longjun Tang) Newsgroups: linux.kernel.netdev Subject: [PATCH 0/3] virtio_net: introduce an RX queue watchdog for stuck detection Date: Mon, 9 Nov 2026 17:43:07 +0800 Organization: Usenet Network Message-ID: <20261109094310.103979-1-lange_tang@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="320309"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:cxvwsBfdjCGnjPd5ZoQ/F0cBj2c= sha256:mZS+jv0YxYLt1Sms2NL4OSzHUonUD375sTjEtqP/0ZI= sha1:628gSp7WkJa75hqEO3ipVNct8Q8= sha256:clV9Hn2/IdYr8KZpeySwvKv1h9D/oNcNsmD1AaM6ZuM= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 1D11311376D; Mon, 9 Nov 2026 12:47:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.148 X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rmxMBwPl2MAR; Mon, 9 Nov 2026 12:47:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-359183-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id BD029113768; Mon, 9 Nov 2026 12:47:31 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id B00B1607044; Mon, 9 Nov 2026 09:43:55 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794217429; b=dtMU4Fuc0NcCWRbAgmvzxZ0b8MOYXb+jYNdCXwXhipq6rvfIcyjW0zpNemmtZ+4N/4aQ skJJJEVlGr+IL2Sickg4pmpta/ZjKwYgOuybhl0kIMTvtLMwI9o75Xs+DEFgGBxYpoELT Ny+29XMrTJHkQd+9I/IWHMjV6AK2VTnU5ivN0VqVYWRhXzRGq6kD8105bBzn2YZw2tU/Z hhiWO3LhnCwmvnlFKfOuOPBIVbfDf5tohIMBJzWSaeNtQuT9b7VdJ9FQqZBC6+1Ip4EZ9 b5h9gqDhe3PoZxsFnrDWzmH2KIHO1AlbTZ1yay9QXCGz7Tt+qp48zAcPv3dFFI2m+rw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794217429; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-Id:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=o4Ehh7rNSx9OYGc6ilukIoNG08FCDxa37EOyEFmx9NU=; b=jzqYoFxl1+GZtRhWOIfeV/nfH4xae1aKVwuAKNio8+7UPmc+6FWs65ilV9xryq0BPzA8 aZroTthGzBkZcE7dNS4R5z0gopgABOVoPKjdEhZ86R6935PN6hMmYK7XRhs+fWBc5OZSu SdOYy1tkhkeF/dn4nnrMRd1jkeQH7wa1pZrH0hrHQGoXGlfErVCti2qtO6VUFHS5et2HZ X6eYtgWrHhhoKZBJMZELG/un+ElwCRycyMakTvQzMd/ZSei9D3aqvnTyd5NYSjmglTmx0 9oBuM0qEDIO9g6OgRt2aIXPPd9FRVm3vLHPC0vs0eEYxuht3G0LAuNNSGBbwlfsJsUg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=S9cCK6S2; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E78FD606D808; Mon, 9 Nov 2026 09:43:48 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=S9cCK6S2 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.4 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794217428; b=MJ8DClr5dEsY8aemdfqBb0YvP1IW69OP4phAiJ2KJCFooqsLMK28MGwKCfr3LDjgwHqk dRcDGqmKS6kv5rZDt2sOHfIcGMYBiOkLL4jzUO05cN4R4zx+lDoa8OPMs6krM16vWje9W /wegr9PeH8Plk9V4WFxHRlVTBQxgju5pLm3JmbJkKxDME7BXkIbMp1JMBIxKazYb1deEG HmKo/Q1NvBllaORHG7nauRzdPLOMkEBhkXYMVBnk5iZaFOTUMqiZ5W3TDLg3mxWART29D 0ekfTgREq/nFoyQMgUvj4h0Hw1inb0eEkbGfmh9FOn+DN4yGfdFizdZiljiSyFIuI5g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794217428; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=o4Ehh7rNSx9OYGc6ilukIoNG08FCDxa37EOyEFmx9NU=; b=fBpI/aG73jvH9o/ogrh0w0hM0Xu84rcgesZ4DaN6PsGlfQKvurqbYaAcKNzNa+WjfLDc 0P3GXjutsKB5THIwn5sgFcZo+pSgsPlMFVKZxGVAk6xzcD4fiCpI8dwj8be/VLX6B0bkP 2zEv35DlDu7WisdwLTpugqF9OGExmgq0WFf93L+3hFXTpHbyN1/C1zpPRAv6Fh1yKsDGw vGBZ2C4kPIZDaGzs2VwK5+jl35i/jeFt0cYyuqKX8v6nvgSzs7xCXafH5qJBj1CSL/5UP BNY2QQ9KFvbRJiG6TWUBJ4rE11qg4cPKnz67+LRlEauN5OW7noCSNOKbBanUF3nkchg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=S9cCK6S2; arc=none smtp.remote-ip=117.135.210.4 X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB896606A334 for <netdev@vger.kernel.org>; Mon, 9 Nov 2026 09:43:45 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EB896606A334 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=o4 Ehh7rNSx9OYGc6ilukIoNG08FCDxa37EOyEFmx9NU=; b=S9cCK6S2PidwVwFs4x plcas/CA2D1mMy92pSblcB0nqd4AZScdpKRX9nhzkZ9dbfPnYqHeOoLE15Y/Z6zf 7ZrrxODaJvRZn+d230h8abQg7nOaaMCE5f1Mw/REYTqn8izx+t2TAgcBIIpE4QQW tpt8pVcJIOZ2Rz3W410jWOx9c= X-Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wBHJCGvlfFq58sxGQ--.4049S2; Mon, 09 Nov 2026 17:43:12 +0800 (CST) X-Cc: xuanzhuo@linux.alibaba.com, virtualization@lists.linux.dev, netdev@vger.kernel.org, tanglongjun@kylinos.cn X-Mailer: git-send-email 2.25.1 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-CM-TRANSID: _____wBHJCGvlfFq58sxGQ--.4049S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCw4fCryrKF48uF4rJry7Jrb_yoW5XF18pF WYkw4YvrykJryI9a4SqF4DJry5Can3ArsFyrs2q348GFs0kr40qr1jkFy5tFyUCr97Cw12 vrsY93yku34DZaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j5J5rUUUUU= X-CM-SenderInfo: 5odqwvxbwd0wi6rwjhhfrp/xtbC4RCo1mrxlbDM+gAA3H