diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-10-13 03:28:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-10-13 16:05:07 -0400 |
commit | 87fb4b7b533073eeeaed0b6bf7c2328995f6c075 (patch) | |
tree | be4b37f08d7fe2d018ae68bae4577b1b2bafd0fc /include/linux/skbuff.h | |
parent | 97ba0eb64ca690165f945a83e609102fcefa99cb (diff) |
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>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index ac6b05a325cc..64f86951ef74 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -46,6 +46,11 @@ | |||
46 | #define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0)) | 46 | #define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0)) |
47 | #define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) | 47 | #define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2)) |
48 | 48 | ||
49 | /* return minimum truesize of one skb containing X bytes of data */ | ||
50 | #define SKB_TRUESIZE(X) ((X) + \ | ||
51 | SKB_DATA_ALIGN(sizeof(struct sk_buff)) + \ | ||
52 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) | ||
53 | |||
49 | /* A. Checksumming of received packets by device. | 54 | /* A. Checksumming of received packets by device. |
50 | * | 55 | * |
51 | * NONE: device failed to checksum this packet. | 56 | * NONE: device failed to checksum this packet. |