mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 13:11:40 +00:00
net: avoid unneeded atomic operation in ip*_append_data()
After commit694aba690d
("ipv4: factorize sk_wmem_alloc updates done by __ip_append_data()") and commit1f4c6eb240
("ipv6: factorize sk_wmem_alloc updates done by __ip6_append_data()"), when transmitting sub MTU datagram, an addtional, unneeded atomic operation is performed in ip*_append_data() to update wmem_alloc: in the above condition the delta is 0. The above cause small but measurable performance regression in UDP xmit tput test with packet size below MTU. This change avoids such overhead updating wmem_alloc only if wmem_alloc_delta is non zero. The error path is left intentionally unmodified: it's a slow path and simplicity is preferred to performances. Fixes:694aba690d
("ipv4: factorize sk_wmem_alloc updates done by __ip_append_data()") Fixes:1f4c6eb240
("ipv6: factorize sk_wmem_alloc updates done by __ip6_append_data()") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
2a37ce25d9
commit
9e8445a56c
@ -1090,7 +1090,8 @@ alloc_new_skb:
|
||||
length -= copy;
|
||||
}
|
||||
|
||||
refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc);
|
||||
if (wmem_alloc_delta)
|
||||
refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc);
|
||||
return 0;
|
||||
|
||||
error_efault:
|
||||
|
@ -1545,7 +1545,8 @@ alloc_new_skb:
|
||||
length -= copy;
|
||||
}
|
||||
|
||||
refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc);
|
||||
if (wmem_alloc_delta)
|
||||
refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc);
|
||||
return 0;
|
||||
|
||||
error_efault:
|
||||
|
Loading…
Reference in New Issue
Block a user