Re: [PATCH net-next v3 2/9] net: devmem: charge the frag length to TX skb truesize

From: Breno Leitao

Date: Mon Nov 09 2026 - 06:03:23 EST


On Thu, Nov 05, 2026 at 02:20:51PM -0800, Stanislav Fomichev wrote:
> Devmem TX charges each frag the net_iov size, PAGE_SIZE today:
> zerocopy_fill_skb_from_devmem() adds PAGE_SIZE to skb->truesize per
> frag and __zerocopy_sg_from_iter() charges it to sk_wmem_queued. TCP
> uncharges in bytes as acked data is trimmed from the skb
> (tcp_trim_head()) and uncharges the rest when the skb is freed. A frag
> shorter than a page leaves the difference charged until then, which is
> small with PAGE_SIZE net_iovs.
>
> TX net_iovs are about to grow up to 2MB, while frags stay bounded by
> the skb and many frags share a net_iov. Charging the net_iov size would
> charge up to 2MB per frag: a 64KB skb with two frags would charge 4MB
> and fill the default 4MB send buffer on its own.
>
> Charge the frag length instead, which also matches what TCP uncharges.
>
> Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxxx>
> Reviewed-by: Mina Almasry <almasrymina@xxxxxxxxxx>
> Reviewed-by: Dragos Tatulea <dtatulea@xxxxxxxxxx>

Reviewed-by: Breno Leitao <leitao@xxxxxxxxxx>