Article View: linux.kernel.netdev
Article #21611Re:Re: [PATCH v2 0/3] virtio_net: introduce an RX queue watchdog for stuck detection
From: "Lange Tang"
Date: Tue, 24 Nov 2026 08:41
Date: Tue, 24 Nov 2026 08:41
66 lines
13703 bytes
13703 bytes
At 2026-11-21 01:45:22, "Michael S. Tsirkin" <mst@redhat.com> wrote:
>On Fri, Nov 20, 2026 at 03:18:23PM +0800, Longjun Tang wrote:
>> 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.
>>
>
>Why virtio net specifically?
Compared to a physical NIC, the interrupt injection path of virtio net is
longer: host backend (QEMU/vhost-user, here OVS-DPDK) -> eventfd -> irqfd ->
injected into the vCPU by KVM. This path loses interrupts more easily than a
physical NIC. On bare metal the interrupt is a single hardware hop and stays
pending until taken, so it cannot be missed.
>
>
>> Implementation
>> --------------
>>
>> Patch 1 exposes last_used_idx through a new helper, which is used by both
>> the split and the packed ring and denotes the position the driver has
>> last consumed. 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 5 seconds, all of the
>> following hold simultaneously:
>> - the queue has a non-zero backlog (unconsumed buffers);
>
>
>what does unconsumed mean?
That the driver has not taken the completed buffers out of the queue yet:
the device has published a completion (virtqueue_poll() is true) but the
driver has not consumed it.
>
>> - 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 ring and refills the descriptors,
>> so the queue recovers.
>>
>> Patch 3 adds a per-queue stalls statistic, exposed via ethtool -S, so
>> the number of stuck events can be observed per queue.
>
>
>
>> questions and comments are welcome.
>>
>> Thanks!
>> Lange
>>
>> Changes in v2:
>> - 1/3: fix the kdoc.
>> - 2/3: drop the module parameter, use a fixed 5s timeout.
>> - 3/3: rename rx_timeouts to stalls.
>>
>> Longjun Tang (3):
>> virtio: add virtqueue_get_last_used_idx() helper
>> virtio_net: introduce an RX queue watchdog for stuck detection
>> virtio_net: add stalls per-queue statistic
>>
>> drivers/net/virtio_net.c | 105 +++++++++++++++++++++++++++++++++++
>> drivers/virtio/virtio_ring.c | 18 +++++-
>> include/linux/virtio.h | 2 +
>> 3 files changed, 123 insertions(+), 2 deletions(-)
>>
>> --
>> 2.25.1
Technical Details
Message-ID:
<41f156cf.73ac.1a20cb7c9d3.Coremail.lange_tang@163.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370118-linux-kernel-netdev=dewy.ruReferences:
<20261120071826.198604-1-lange_tang@163.com> <20261120124403-mutt-send-email-mst@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370118-linux-kernel-netdev=dewy.ru
From: lange_tang@163.com ("Lange Tang")
Newsgroups: linux.kernel.netdev
Subject: Re:Re: [PATCH v2 0/3] virtio_net: introduce an RX queue watchdog
for stuck detection
Date: Tue, 24 Nov 2026 16:41:41 +0800 (CST)
Organization: Usenet Network
Message-ID: <41f156cf.73ac.1a20cb7c9d3.Coremail.lange_tang@163.com>
References: <20261120071826.198604-1-lange_tang@163.com>
<20261120124403-mutt-send-email-mst@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=GBK
Content-Transfer-Encoding: base64
Injection-Info: usenet.network;
logging-data="4091430"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:/MP+aJMJmvYyNVm38XsM7T8oEjk= sha256:SgRFYVCk13rXQfbLodYlH01E66pUAAhKoLMRxMR0FPA=
sha1:T8ptwrpID770AiPgRRfcJVMqTkA= sha256:KM/UsaJOrdY/COBBERP24zrr5Dspa5G9kJX3ocgM+vM=
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 AC6B6125DE4; Tue, 24 Nov 2026 11:42:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, 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] 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 N4OiMu3meAOt;
Tue, 24 Nov 2026 11:42:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-370118-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id CDDA4125DE0; Tue, 24 Nov 2026 11:42:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id A701E29DCA; Tue, 24 Nov 2026 08:42:17 +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=1795509735;
b=cIvho6NgO7P3NWB3E6xFjzAVMpEOrkoUngZ9JyAicuuuL9vj/rjgpGH5a6UhVmIX+btz
qLn0ULURuKNdd7iopgDRGimSO2NyzigFYMPZ59QaURVC5OgKQzOxjxZ4thm5X/2gYy/Np
DzWQLR2m4tOJ35PdfHdLROpzq9XnQO4OzkAkQ2+aJNaJPwARV3CDdgmZV3TYLRiGNqzq6
6hAZuudykvoW9I+9Z6rTKTywzTIttInrVRX0e5MsN5DlNytT5s6E8Yv8eEVKjOJgZBR/z
zQte3yq9zJDISd/GHwy9rcCDNYVogCe3V4cBHjb6HyPD9p1b5VffhDeeebcX5qQB2bA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795509735;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Date:From:To:Cc:
Subject:X-Priority:X-Mailer:In-Reply-To:References:X-NTES-SC:
Content-Transfer-Encoding:Content-Type:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Message-ID:X-Coremail-Locale:X-CM-TRANSID:
X-CM-SenderInfo:X-Coremail-Antispam;
bh=yayRZDW92bf30dpBjibbBJc+yczvJ6DpFo7UtXjysZw=;
b=EoUkx4pafUGwQ7/nlTGpSi6SqBxlt+i9yW6rwiBDU6GqcL8CwSBRpJ4mA2a8VT1H6Q7W
Iv8VOKq79z44nr9xhQ+wQMR4mNydMQdoITZaRWBNDrQ3elTMTfGiAkE+6r3WRtcV0uA8r
ByYnL/00yvfto1mWoN9NIHLlszYCuymxrx6CDS++q/46XI+gv5Na8Gkulgz/l4116e0x/
MRvst6ajjErSdPimeWKhxrAsvBQwHautY7U8rXx94+h+J26tEdi+JIC8MwVjIsp/aOflb
vGQAZsRlB21kGFwBlMiJvDEDpqj+8D1hqBP7pocikinwl0zMAfkkOAxh8kSKESnsqAA==
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="L3/Y6Eh1";
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 085A5606A336;
Tue, 24 Nov 2026 08:42:15 +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=L3/Y6Eh1
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=1795509734;
b=HbCrxPFXQEWTFlpFQ4RKUOH/58YUdzmoSUy6tBKY3dzApMwbz0WTBtiqQO8F74hKrzHR
KYDJ8zA7n0bjdLmFtcNnwk2mADsCzaP8rawOUp4YiUkVkwh3kG9olD746hKEULKexavX+
vkModAtpcV8xaD4fludYFQlgRzXTRrO96pyGhfu6oAfriwBGe0CZ+1z6arqcifiBkYBbw
sRmINmUlzLB8GLy3Ui3JLYm6lW3jmXiONyF060aNlkamtleAUiQTlWyyY/IB5PpbcTEve
+mJDl0BIpWfAtrFcqYN5RdRyh5cDwHPhMOlU0/+ovqIDF6nAeebtcQbgOlGzkC9+5SA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795509734;
h=DMARC-Filter:DKIM-Signature:Date:From:To:Cc:Subject:X-Priority:
X-Mailer:In-Reply-To:References:X-NTES-SC:Content-Transfer-Encoding:
Content-Type:MIME-Version:Message-ID:X-Coremail-Locale:X-CM-TRANSID:
X-CM-SenderInfo:X-Coremail-Antispam;
bh=yayRZDW92bf30dpBjibbBJc+yczvJ6DpFo7UtXjysZw=;
b=ZYdZCoEgYGlkGc/MetUdRf4haqUKT1+vDExYC9Mghu1jeEIH2eT9DX320VLj9fiwJrs+
g0dTi02afpNkMKAEyJJrLyVCB29H1QCarm8IB5JODqHvn9i786vSH+3pmDZLLzaq5+HUv
KUyyZY2DYJnipEuuKQyxwE9Zv40DdQhNknhjzctNPGLTLhnlJkKVEX8z8I8uPkwkwLidR
aW/9YP+f3kBd3J/h870BRXH/KaKqd39Q86HcEpI6wK0MwQbfK+N9Ld1fPlhhTE8qnYwKy
O7c0ELN1C98OllDn2/jfKFq6FnyvdsTQaHzN8IZfKj9u3X7GDSSJ6c0qwxrFZVNyRmQ==
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="L3/Y6Eh1";
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 6B364606A335
for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 08:42:11 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6B364606A335
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=Date:From:To:Subject:Content-Type:MIME-Version:
Message-ID; bh=yayRZDW92bf30dpBjibbBJc+yczvJ6DpFo7UtXjysZw=; b=L
3/Y6Eh1xs4kDKTYpkthJhOAp+1yM9ezn6rcQqIr8Rin+BT0o1IefB/w1ZcyV8WZx
+jgbTqDsoI+HoTN49xwOxrwss0b327FYsSo0xPpn0giuB1TK9cnkkcDfe/pwNLoU
Ibvi+DmGxX1xWhtnbFd6j50wBznnCsPRjmJRhMZk+k=
X-Cc: "Jakub Kicinski" <kuba@kernel.org>,
"Eugenio Perez" <eperezma@redhat.com>,
"jasowangio@gmail.com" <jasowangio@gmail.com>,
"xuanzhuo@linux.alibaba.com" <xuanzhuo@linux.alibaba.com>,
"virtualization@lists.linux.dev" <virtualization@lists.linux.dev>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"Tang Longjun" <tanglongjun@kylinos.cn>
X-Priority: 3
X-Mailer: Coremail Webmail Server Version 2023.4-cmXT build
20260511(2e539873) Copyright (c) 2002-2026 www.mailtech.cn 163com
X-In-Reply-To: <20261120124403-mutt-send-email-mst@kernel.org>
X-NTES-SC: AL_Qu2SB/mbtk8r5yCeZ+kfmUgRg+c/XsK4svUj24VVOJF8jCLp+DAKRVFkMFj68MSsEweXrCCTSQJo+MZ4UoV4b7gk/Q7RC/TvJ0wiTAZRuKXh8Q==
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-Coremail-Locale: zh_CN
X-CM-TRANSID: bCgvCgD3vwHGTQVroth0AA--.361W
X-CM-SenderInfo: 5odqwvxbwd0wi6rwjhhfrp/xtbC-QagzmsFTcZzeQAA36
X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==