Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-small-csum-optimizations'

Eric Dumazet says:

====================
net: small csum optimizations

After recent x86 csum_partial() optimizations, we can more easily
see in kernel profiles costs of add/adc operations that could
be avoided, by feeding a non zero third argument to csum_partial()
====================

Link: https://lore.kernel.org/r/20211124202446.2917972-1-eric.dumazet@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+7 -3
+5 -1
include/linux/skbuff.h
··· 3485 3485 static inline void skb_postpull_rcsum(struct sk_buff *skb, 3486 3486 const void *start, unsigned int len) 3487 3487 { 3488 - __skb_postpull_rcsum(skb, start, len, 0); 3488 + if (skb->ip_summed == CHECKSUM_COMPLETE) 3489 + skb->csum = ~csum_partial(start, len, ~skb->csum); 3490 + else if (skb->ip_summed == CHECKSUM_PARTIAL && 3491 + skb_checksum_start_offset(skb) < 0) 3492 + skb->ip_summed = CHECKSUM_NONE; 3489 3493 } 3490 3494 3491 3495 static __always_inline void
+2 -2
include/net/gro.h
··· 173 173 const void *start, unsigned int len) 174 174 { 175 175 if (NAPI_GRO_CB(skb)->csum_valid) 176 - NAPI_GRO_CB(skb)->csum = csum_sub(NAPI_GRO_CB(skb)->csum, 177 - csum_partial(start, len, 0)); 176 + NAPI_GRO_CB(skb)->csum = ~csum_partial(start, len, 177 + ~NAPI_GRO_CB(skb)->csum); 178 178 } 179 179 180 180 /* GRO checksum functions. These are logical equivalents of the normal