net: more accurate skb truesize
skb truesize currently accounts for sk_buff struct and part of skb head. kmalloc() roundings are also ignored. Considering that skb_shared_info is larger than sk_buff, its time to take it into account for better memory accounting. This patch introduces SKB_TRUESIZE(X) macro to centralize various assumptions into a single place. At skb alloc phase, we put skb_shared_info struct at the exact end of skb head, to allow a better use of memory (lowering number of reallocations), since kmalloc() gives us power-of-two memory blocks. Unless SLUB/SLUB debug is active, both skb->head and skb_shared_info are aligned to cache lines, as before. Note: This patch might trigger performance regressions because of misconfigured protocol stacks, hitting per socket or global memory limits that were previously not reached. But its a necessary step for a more accurate memory accounting. Signed-off-by:Eric Dumazet <eric.dumazet@gmail.com> CC: Andi Kleen <ak@linux.intel.com> CC: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by:
David S. Miller <davem@davemloft.net>
Showing
- include/linux/skbuff.h 5 additions, 0 deletionsinclude/linux/skbuff.h
- net/core/skbuff.c 14 additions, 4 deletionsnet/core/skbuff.c
- net/core/sock.c 1 addition, 1 deletionnet/core/sock.c
- net/ipv4/icmp.c 2 additions, 3 deletionsnet/ipv4/icmp.c
- net/ipv4/tcp_input.c 7 additions, 7 deletionsnet/ipv4/tcp_input.c
- net/ipv6/icmp.c 1 addition, 2 deletionsnet/ipv6/icmp.c
- net/iucv/af_iucv.c 1 addition, 1 deletionnet/iucv/af_iucv.c
- net/sctp/protocol.c 1 addition, 1 deletionnet/sctp/protocol.c
Please register or sign in to comment