Re: [PATCH net-next v5 4/5] vsock/virtio: coalesce native RX write-space notifications
From: Stefano Garzarella
Date: Thu Nov 26 2026 - 05:14:48 EST
On Fri, Nov 06, 2026 at 08:49:17PM +0800, Jia Jia wrote:
> >
> > On Tue, Nov 03, 2026 at 12:11:33PM +0800, Jia Jia wrote:
> > >Each received packet can update peer credit and call sk_write_space(). A
> > >writer cannot consume that credit while the virtio RX worker retains the
> > >socket lock, so repeated native write-space notifications in one RX batch
> > >are unnecessary.
> > >
> > >This patch coalesces write-space notifications on the native AF_VSOCK path;
> > >data-ready remains per-packet here.
> > >
> > >The batching patch establishes batch ownership before its first packet.
> > >This lets this patch record a pending notification for that packet and
> > >flush it even if the packet immediately ends the batch. Deliver it while
> > >holding the socket lock to preserve the callback context of the existing
> > >receive path. A following patch changes that timing together with
> > >data-ready handling.
> >
> > Can you report performance data related to this patch also here?
> >
> > IIUC this is not giving a lot of advantage, so my question is if this
> > more complexity really add a value for us.
> >
>
> Sure. The performance tests currently cover patches 4 and 5 together,
> so I will include those results here.
>
> They do not add another broad throughput improvement. I kept the
> combined notification change because of the cycles/byte results.
>
> With P1-P3 only, against baseline:
>
> Buffer size baseline cycles/B PATCH cycles/B cycles change (95% CI)
> 64B 66.728 61.220 -8.25% [-18.99%, +3.91%]
> 256B 14.363 14.515 +1.06% [ -4.22%, +6.64%]
> 512B 7.792 7.578 -2.74% [ -6.55%, +1.23%]
> 1K 3.988 4.032 +1.09% [ -1.64%, +3.88%]
> 4K 2.063 1.973 -4.38% [ -8.23%, -0.37%]
> 8K 1.702 1.667 -2.06% [ -7.99%, +4.25%]
> 16K 1.473 1.475 +0.17% [ -5.06%, +5.68%]
> 64K 1.385 1.358 -1.96% [-10.61%, +7.53%]
>
> Only the 4K interval excluded zero. With the full series, against
> baseline:
>
> Buffer size baseline cycles/B PATCH cycles/B cycles change (95% CI)
> 64B 65.282 57.843 -11.40% [-13.77%, -8.95%]
> 256B 14.710 13.813 -6.10% [ -7.89%, -4.28%]
> 512B 7.709 7.188 -6.75% [ -8.79%, -4.66%]
> 1K 4.075 3.862 -5.23% [ -6.80%, -3.63%]
> 4K 2.034 1.887 -7.21% [ -8.67%, -5.72%]
> 8K 1.664 1.568 -5.78% [ -7.83%, -3.69%]
> 16K 1.450 1.385 -4.48% [ -6.08%, -2.86%]
> 64K 1.338 1.317 -1.51% [ -3.21%, +0.22%]
>
> From 64B through 16K those intervals stay below zero. 64B through 1K
> did not show that in the P1-P3 run.
>
> This is also why I spent the time making this work with sockmap.
>
> The value I see is lower RX CPU cost, not another large throughput
> gain. I am still unsure the extra code is worth it, and I would like
> your opinion.
Thanks for the numbers!
Both tables are against baseline, but the two baselines are a bit
different (e.g. 66.728 vs 65.282 for 64B), so it's not easy to see the
real contribution of P4/P5. Can you compare the full series directly
against P1-P3?
Anyway, IMO the big win of this series is P1-P3 (throughput), while
P4/P5 add a lot of complexity (saved native callbacks, new af_vsock
helpers, sk_callback_lock, sockmap corner cases) for a ~5% of CPU
cost, without throughput improvement.
So my suggestion is to split the series: send P1-P3 first, so we can
focus the review on them and merge them, and then send P4/P5 (squashed)
as a separate series. That way we can also evaluate the direction
suggested by Bobby (batching in read_skb() + coalesced sk_data_ready(),
like TCP), that may allow us to avoid saving the native callbacks at
all.
WDYT?
Thanks,
Stefano