aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ip6_output.c
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2018-04-04 14:30:01 +0200
committerDavid S. Miller <davem@davemloft.net>2018-04-04 11:53:08 -0400
commit9e8445a56c253f01f6716ac14526a7dae6bc0d46 (patch)
tree8ebe5055cb50b610f373a711c9198ac2ffe392aa /net/ipv6/ip6_output.c
parentnvmem: disallow modular CONFIG_NVMEM (diff)
downloadlinux-dev-9e8445a56c253f01f6716ac14526a7dae6bc0d46.tar.xz
linux-dev-9e8445a56c253f01f6716ac14526a7dae6bc0d46.zip
net: avoid unneeded atomic operation in ip*_append_data()
After commit 694aba690de0 ("ipv4: factorize sk_wmem_alloc updates done by __ip_append_data()") and commit 1f4c6eb24029 ("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: 694aba690de0 ("ipv4: factorize sk_wmem_alloc updates done by __ip_append_data()") Fixes: 1f4c6eb24029 ("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>
Diffstat (limited to 'net/ipv6/ip6_output.c')
-rw-r--r--net/ipv6/ip6_output.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 66a768b7b8fb..b8ee50e94af3 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -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: