Article View: linux.kernel.netdev
Article #12899Re: [PATCH net 3/3] vsock/virtio: queue at most one credit update per socket
From: netdev-bot+sashiko
Date: Mon, 09 Nov 2026 00:36
Date: Mon, 09 Nov 2026 00:36
136 lines
12729 bytes
12729 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] Both the guest and vhost transports call
virtio_transport_credit_update_xmit() before the packet is actually…
--
vsock/virtio: queue at most one credit update per socket
This patch limits how many credit update packets each virtio vsock socket
can have queued. It tracks the last queued credit update skb in
virtio_vsock_sock and suppresses new ones while that skb is pending.
Transports call a new virtio_transport_credit_update_xmit() hook to
refresh fwd_cnt/buf_alloc on the tracked skb and release tracking when it
is sent. A tracked skb holds a refcount on virtio_vsock_sock to keep it
alive.
[ ... ]
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index 74a8fdf825d50..65d6e0790e724 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
> @@ -604,18 +604,68 @@ static void virtio_transport_dec_rx_pkt(struct virtio_vsock_sock *vvs,
[ ... ]
> +/* Called by the transports when @skb is put on the wire. */
> +void virtio_transport_credit_update_xmit(struct sk_buff *skb)
> +{
> + struct virtio_vsock_sock *vvs = VIRTIO_VSOCK_SKB_CB(skb)->vvs;
> + struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb);
> +
> + if (!vvs)
> + return;
> +
> + spin_lock_bh(&vvs->rx_lock);
> + /* Still the socket's last packet: carry what was suppressed. */
> + if (vvs->credit_update == skb) {
> + vvs->credit_update = NULL;
> + vvs->last_fwd_cnt = vvs->fwd_cnt;
> + hdr->fwd_cnt = cpu_to_le32(vvs->fwd_cnt);
> + hdr->buf_alloc = cpu_to_le32(vvs->buf_alloc);
> + }
> + spin_unlock_bh(&vvs->rx_lock);
> +}
> +EXPORT_SYMBOL_GPL(virtio_transport_credit_update_xmit);
[Severity: Medium]
This hook can't be undone once it has run. It clears vvs->credit_update,
advances vvs->last_fwd_cnt and rewrites the header. Do the guest and vhost
transports call it before the packet is actually committed?
In the guest driver, virtio_transport_send_skb() calls it before
virtqueue_add_sgs(), and that call fails when the tx vq is full:
net/vmw_vsock/virtio_transport.c:virtio_transport_send_skb() {
virtio_transport_credit_update_xmit(skb);
...
ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, skb, gfp);
if (ret < 0)
return ret;
...
}
virtio_transport_send_pkt_work() then puts the skb back at the head:
ret = virtio_transport_send_skb(skb, vq, vsock, GFP_KERNEL);
if (ret < 0) {
virtio_vsock_skb_queue_head(&vsock->send_pkt_queue, skb);
break;
}
When the fast path fails, virtio_transport_send_pkt() queues it at the
tail instead.
The requeued skb is no longer tracked. So the next
virtio_transport_send_credit_update() is not suppressed, and it queues a
second, tracked credit update behind the first.
Doesn't that make the per-socket bound two, rather than the "at most one
credit update" the commit message describes? Any later updates are still
suppressed by the second tracked one, so the unbounded queuing stays
fixed.
In vhost, vhost_transport_do_send_pkt() calls the hook right after it
gets a descriptor, before the checks that drop the skb:
virtio_transport_credit_update_xmit(skb);
if (out) {
restart_tx |= vhost_vsock_drop_skb(vsock, skb);
...
}
iov_len = iov_length(&vq->iov[out], in);
if (iov_len < sizeof(*hdr)) {
restart_tx |= vhost_vsock_drop_skb(vsock, skb);
...
The copy_to_iter() and skb_copy_datagram_iter() fault paths drop the skb
in the same way.
Suppose updates were suppressed while this one was queued. Their fwd_cnt
has been merged into this skb and recorded in last_fwd_cnt, but the
guest never receives this skb.
Before this patch, the suppressed update would have been a separate skb,
delivered on the next descriptor. Now nothing resends it until more local
reads happen. Could the guest-side sender then stall waiting for credit?
Moving the hook after these checks would not be enough by itself, since
the suppressed state is lost whenever a tracked update is dropped.
The commit message says:
So a suppressed update always reaches the
peer, either in the queued one or in a later packet, and the fwd_cnt
the peer sees never goes back.
Is that still true on these drop paths?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261105000141.3617241-1-green%40linuxhacker.ru
Technical Details
Message-ID:
<179418457356.994134.15621990093990477357@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358929-linux-kernel-netdev=dewy.ruReferences:
<20261105000141.3617241-4-green@linuxhacker.ru>Show 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-358929-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 3/3] vsock/virtio: queue at most one credit update per socket Date: Mon, 09 Nov 2026 00:36:13 +0000 Organization: Usenet Network Message-ID: <179418457356.994134.15621990093990477357@kernel.org> References: <20261105000141.3617241-4-green@linuxhacker.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="238316"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:OKBzbrhm8VbvomE0VWj5X0So6Ro= sha256:wNoh/F0MupKiHq10dP6hb019hed466nRlkw8uKJQbdc= sha1:S7HfTdNd0aVweNjmFx1/4UHEnsM= sha256:peim7dL55gljzoXUPakrNJk66l1bsOQHQGtIlJjbRfw= 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 D9E67113670; Mon, 9 Nov 2026 03:41:35 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 (2048-bit key) header.d=kernel.org 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 UkU1hdc5x7Ol; Mon, 9 Nov 2026 03:41:27 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-358929-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 0DD8E11364F; Mon, 9 Nov 2026 03:41:17 +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 408EF61D0C4; Mon, 9 Nov 2026 00:37:20 +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=1794184598; b=tVOhHKyMymGt5BElu1iznpiE0o7DrhU+9mx1ZFOTUS40W1JfFwEAVqawqcz4KA9lo57C Q6wQVNzIs++PshxdTUawvWXNwiQhHhL0VXLMfkmkeiTSxt10UYrorw5z31vOBwzroaMEM SCiPCKedVAL/Y5LIZhSbI9Z4r7akAK2+DKghTarD4v/bG3R6mtsr01ke9UQQz0Cj3Xiew bYngf2v1uPkx0YV5X4WViNjWjKlRy7K7FSUoU4umweEYim4tKlUj+YkQmIoxGvEtBLsMS r/To5kPZXKVMyBLCmDpzG/bkLAdZ2JsrHXyfAqmGIwGK9Q3AweVI0lp+/DgPCll/8iA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794184598; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=MrgV9fXwBYVj4uLezFVa59Hg+/XXAINskq6Fghy76zs=; b=BdKQEpQvUe3hhKiPKxKY7BXZkNzoGOCvQvdJTofsjOMbLrdHDppuptc8pNwSkLYT78tV fsyKLbwLM2wDPQB39Ve697Tz0e5bAkJrICWpeklxDa1jvnvyySlY5iJyD0G4hd8ckzb+W DbXdYFp3HKWfn2Ayd+/wgQ/+K4Gjk8y9X02y4d+xWYVAAINexmedwsPg8xT08llSkCuW3 3KdPR24++iBkiB+ER9IxAdQz3GvhtAbLSX6LewOxqFPi6rwZk5090vWJTdTHbk37rd0md L2x9YRzCUpzKlXlduhZwXMyX7OeZjI3p45Emc7dG3n5PvzrvKEZy3iskdpNZt5sPOhA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FcaNjP8t; 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 C01A9606D81B; Mon, 9 Nov 2026 00:36:38 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FcaNjP8t X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794184575; b=LlcjF416JmG1z6ONcdvz/xN15oTng7qw8tH8lxFAMRhp3joOSCj2GDXA54Ql2aZRRMU8 yvtm9Eml8LCd6DQ0XHKJjmkNl/t3n/J2DnhOgFPfkwgXfl5a2rpY8NgfrNDdFa9DHZYVH yBkKAX6I0la2rggFobvRnrU4p7t/+xyTt1l08WemJsGKpbOYqhqDFVyJB8yIIJmhiQJrG fZYNnSh7ZJgVcaocZGpB8YbrHxXO6vbVDCZaazdcwZf9P+78ChTK/wY7geAuEO5bV3qKl OliGCE6q12HkyOsvfQzN+o7PEcRqsUoXdLxdN9yskk7NhKYREHz0tsadSnIJ26WdqyQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794184575; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=MrgV9fXwBYVj4uLezFVa59Hg+/XXAINskq6Fghy76zs=; b=Y3QEe9UDXU0sDI1lJOXCIsjy/rr8+8gCM3hQ6DkdoVv61vehcj608GYkjHDEo2XHNoN6 BQ7n8EsBUISgzKosUxj8oE9ImGkvlDBdFkx5FUv+ofpEliSgFdAXQcQnqfQ8cQNkDoku5 CRvgJ6Czh2RUxN9LWc7q9CJefhxZgvuogd0U41kizGHt0q17ESS+nxIfV8gUjYGUMXQ2L IAptQNcezbNK5rEobLQzQfMCKP9aatyWNgqgClUyY0IWpEic7qTlnk+K8dFanNmytdRTE oSvoEgiuwBRsvHkbeJjMruxvXE5dQ/yJw8DzFDF+MNA0+YoWA0K20B5HIYxmP9CqdmA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FcaNjP8t; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40173606A31C; Mon, 9 Nov 2026 00:36:15 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B21E1F008A2; Mon, 9 Nov 2026 00:36:14 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794184575; bh=MrgV9fXwBYVj4uLezFVa59Hg+/XXAINskq6Fghy76zs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=FcaNjP8t3uYt8wwOigY7Jj/L+2eMml7Pwt9+M+mSCd1uTIiJ83mLqNitjPNkzxUnX TsKJW2EWvaOxz/qgCVLIwh0jhIWJlg9k+SYK8XoJxUcsnlcuFTIt7jL2qPnzYMIA8R 6krCikJbxLI2mJdOEGp8WOzf4MMc9CDjLNnKTzeThgGr2tyouFKgK4intwgZGpiLoS /x/DQo3vqldDdcI0gSz57AHQb/FWFeohWbWHnzN9xNdZkMLb9NPkjyHrUc8n1aNzeS pvAZYnTMqKbllCvLgeWkhpc5ZQPor3KR9NYmKlgR8QYkjl84Eob3FSR3nH53DNfCK2 7LikZBOQtZ2/w== X-Cc: sgarzare@redhat.com, stefanha@redhat.com, mst@redhat.com, jasowangio@gmail.com, eperezma@redhat.com, xuanzhuo@linux.alibaba.com, bobbyeshleman@meta.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261105000141.3617241-4-green@linuxhacker.ru> X-sashiko-severity: Medium 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