Article View: linux.kernel.netdev
Article #3080Re: [PATCH net-next v3 2/4] vsock/virtio: amortize RX socket locking for stream packets
From: netdev-bot+sashiko
Date: Wed, 14 Oct 2026 06:33
Date: Wed, 14 Oct 2026 06:33
102 lines
9263 bytes
9263 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The patch is presented as a pure performance optimization
("amortize RX socket locking for stream packets").
--
vsock/virtio: amortize RX socket locking for stream packets
The virtio-vsock RX worker now keeps the socket lock and the lookup
reference held across a bounded run of STREAM/RW packets for one socket.
A batch is capped at 64 packets or 64KB of payload. It ends on control
packets, a flow change, or a change in socket state or protocol. Two new
exported functions are added, virtio_transport_recv_pkt_batch() and
virtio_transport_rx_batch_finish().
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index 8a930bc42fdc3..bfe40ecf0b2f0 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
[ ... ]
> @@ -1909,6 +1945,128 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
[ ... ]
> + if (batch->sk) {
> + vsk = vsock_sk(batch->sk);
> + if (vsock_addr_equals_addr(&src, &vsk->remote_addr) &&
> + dst.svm_port == vsk->local_addr.svm_port &&
> + vsock_net_check_mode(sock_net(batch->sk), net) &&
> + virtio_transport_recv_pkt_batchable(t, batch->sk)) {
[ ... ]
> + }
> +
> + virtio_transport_rx_batch_finish(batch);
> + }
> +
> + sk = virtio_transport_find_socket(skb, &src, &dst, net);
[ ... ]
> + lock_sock(sk);
> + /*
> + * Sockmap removal restores the native protocol under sk_callback_lock.
> + * Serialize this initial eligibility check with that update.
> + */
> + read_lock_bh(&sk->sk_callback_lock);
> + start_batch = virtio_transport_recv_pkt_batchable(t, sk);
> + read_unlock_bh(&sk->sk_callback_lock);
> +
> + free_pkt = virtio_transport_recv_pkt_locked(t, skb, sk, &src, &dst,
> + net,
> + start_batch ? &batchable : NULL);
> + if (start_batch && batchable) {
> + /* Keep the lookup reference until the batch is released. */
> + batch->sk = sk;
> + return;
> + }
[Severity: Low]
Is there data showing this is a net win? The subject says it will
"amortize RX socket locking for stream packets". The commit message
gives no throughput, latency or CPU-cost numbers.
Take interleaved RW traffic from two or more stream flows (A, B, A, B,
...). The cached-flow check above fails on every packet, so each packet
goes through:
virtio_transport_recv_pkt_batch()
virtio_transport_rx_batch_finish() /* release_sock + sock_put */
virtio_transport_find_socket()
lock_sock()
read_lock_bh(&sk->sk_callback_lock)
virtio_transport_recv_pkt_batchable()
read_unlock_bh(&sk->sk_callback_lock)
virtio_transport_recv_pkt_locked()
virtio_transport_recv_pkt_batchable()
Every step of the old per-packet path is still done. On top of that,
each packet pays for the read_lock_bh()/read_unlock_bh() pair, two
predicate checks, and the batch bookkeeping in
virtio_transport_rx_work(). No batch ever grows past one packet.
The socket lock from the previous flow also stays held while
virtio_transport_rx_work() runs virtqueue_get_buf(), tap delivery and
header parsing for the next packet.
The added cost is small next to lock_sock() and the socket lookup. Could
the commit message include measurements, and mention this
interleaved-flow trade-off?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261013063112.168321-1-physicalmtea%40gmail.com
Technical Details
Message-ID:
<179195958017.434549.14764784523092696104@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-346041-linux-kernel-netdev=dewy.ruReferences:
<20261013063112.168321-3-physicalmtea@gmail.com>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-346041-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v3 2/4] vsock/virtio: amortize RX socket locking for stream packets Date: Wed, 14 Oct 2026 06:33:00 +0000 Organization: Usenet Network Message-ID: <179195958017.434549.14764784523092696104@kernel.org> References: <20261013063112.168321-3-physicalmtea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2233899"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:B+QRPuNXgJzSsoGhNwDTdpb3prM= sha256:jVC86kN9/dKf7yF/mCDEihCcSDpDjLOG3Uj0jxoUzCg= sha1:dxnEuyjjGCNygjZtXyYQ3Vvca0U= sha256:GAHCj72E6FP2QpjXeDSkEWU4BRbTwiy+j4lD5VC9p+k= 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 5E713110039; Wed, 14 Oct 2026 09:37:12 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -1.339 X-Spam-Status: No, score=-1.339 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=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 pXaRovvsLD_M; Wed, 14 Oct 2026 09:37:08 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-346041-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 07B0A10FFE9; Wed, 14 Oct 2026 09:36:58 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id E0B37408BC; Wed, 14 Oct 2026 06:33:39 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8B4343F4A9; Wed, 14 Oct 2026 06:33:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SAdv62mk" X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 309142EEE90; Wed, 14 Oct 2026 06:33:01 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791959588; cv=none; b=VvaDQMFeRq2YUmzLLCcVhqcnNo7MobI61wYt3ROXWcb3cdWt2RoipgA1mVTM530kfB7Epm/zrC+iCLrVTccReVNidBQpTqP8J5PGjpbp83NGFmqtpb3kStTxcwYeDMMBcBpNDu78VxtlVFYpkNKCNYyY1QeALrMT73OJba4x6tY= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791959588; c=relaxed/simple; bh=hZnXdS8AanEZIIEST8OIJ05dTsAd0Sx5h8VsoTQYJy8=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=G1PvfL/93JB/Wet2CutIE+c8TQqcxZ3Z8hGIv6kYk1KDvuM126x+F+chxytYDk4KbYIttYKwSPzzzJ6/iZbsTIRl+4SGT07DiBMY8locxV61/TRCk9P4hltqSDcBK4+6mFGZu97RT2Kt5CpCBmNxIV1mqWDXCUxrUlYBuQqJFNA= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SAdv62mk; arc=none smtp.client-ip=100.103.45.18 X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A051F1F000FF; Wed, 14 Oct 2026 06:33:00 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791959581; bh=bz7UsijxJT419pdB7TAHe5DRpQqHR9oPLis11GxsW8A=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SAdv62mk3hJ0WgjjHtxTuAcC5tvg06ypH1BURi+MjJZw8A6JV4dCdRfdmhMY8sL/f lxF8TgAbAqwrb4psqcRkaq7y45KlGzNthUwyYTuMcIUFpDvufRDikUPYV3nad/tqrg bM1fvLp4aPKRWx+PzdJAZWe5oalGqNC2T7BzHAg2HMGFoQXTOoPOcxaqbQq8LaLf77 j0qsCcj4J2tpGBqbkJk+nKSXLcHYWnKD0/aQpKlBfbGdwSLm+hTvmHZYEor9IGQFFA dSBWE9xwK0vBt1hjvvcCz9sCr9cngfNIRmjxINZDQMJJKW/Q2TPRMSSsppDRGeuBTt lrGHLnEPQa//Q== X-Cc: stefanha@redhat.com, sgarzare@redhat.com, mst@redhat.com, jasowangio@gmail.com, eperezma@redhat.com, xuanzhuo@linux.alibaba.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261013063112.168321-3-physicalmtea@gmail.com> X-sashiko-severity: Low X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>