Subject: Re: [PATCH v2 net-next 07/15] udp: Remove partial csum code in RX.

From: David Laight <[email-masked]>
Date: Tue, 10 Mar 2026 20:00:02 +0000

On Thu,  5 Mar 2026 21:49:53 +0000
Kuniyuki Iwashima <[email-masked]> wrote:

> UDP-Lite supports the partial checksum and the coverage is
> stored in the position of the length field of struct udphdr.
> 
> In RX paths, udp4_csum_init() / udp6_csum_init() save the value
> in UDP_SKB_CB(skb)->cscov and set UDP_SKB_CB(skb)->partial_cov
> to 1 if the coverage is not full.
> 

Is it worth completely removing the code that defers the udp RX checksum
until the copy_to_user() and the corresponding TX side code that checksums
the data being sent.

I'm not sure what the 'killer application' was for the RX side.
I'd guess the userspace NFS daemon - long since dead.

With most modern 'performance' NICs doing checksum offload you don't
want to 'waste' cycles doing a checksum during transmit that won't
be needed - and you don't know the interface until much later.

I also recall that pretty much only x86 actually tries to do the
checksum and copy together - most architectures checksum the buffer
fragments (of the iov[]) as they are copied - even though the kernel
buffer is linear; so has to handle more fragments.
ISTR there is a bug where 0 and ~0 get swapped.

Even for x86-64 the fastest IP checksum does 12-16 bytes/clock (I think
you can get 12 on Intel and 16 on AMD), and the copy will do 64 bytes
per clock (on recent enough cpu and once it is started and with an
aligned destination).
So even there separate copy and checksum may be faster.
The only time copy+checksum really helps is for buffers that spill
the L1-cache - which is why I think NFS's 8k UDP datagrams are why
the code was added at all.
(Last time I asked about this Linus couldn't remember.)

	David