mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: physicalmtea@gmail.com
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
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	[thread overview]
Message-ID: <179195958017.434549.14764784523092696104@kernel.org> (raw)
In-Reply-To: <20261013063112.168321-3-physicalmtea@gmail.com>

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

  reply	other threads:[~2026-10-14  6:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  6:31 [PATCH net-next v3 0/4] vsock/virtio: reduce RX per-packet socket overhead Jia Jia
2026-10-13  6:31 ` [PATCH net-next v3 1/4] vsock/virtio: split socket lookup from locked RX processing Jia Jia
2026-10-13  6:31 ` [PATCH net-next v3 2/4] vsock/virtio: amortize RX socket locking for stream packets Jia Jia
2026-10-14  6:33   ` netdev-bot+sashiko [this message]
2026-10-13  6:31 ` [PATCH net-next v3 3/4] vsock/virtio: coalesce RX write-space notifications in lock batches Jia Jia
2026-10-14  6:33   ` netdev-bot+sashiko
2026-10-13  6:31 ` [PATCH net-next v3 4/4] vsock/virtio: defer RX readable notifications until batch unlock Jia Jia
2026-10-14  6:33   ` netdev-bot+sashiko

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=179195958017.434549.14764784523092696104@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=horms@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=physicalmtea@gmail.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --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

all inboxes | Powered by JetHome®