From: Eric Dumazet > Sent: 27 January 2017 14:44 ... > > I'm also guessing that extra headroom can be generated by stealing unused > > tailroom. > > This is already done. > > Quoting > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=87fb4b7b533073eeeaed0b6bf7c > 2328995f6c075 > > 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.
Does that actually have the expected effect? Allocate an skb for 512 bytes, copy in some data with 64 bytes of headroom. This is (probably) a 1k memory block with skb_shared_info at the end. Some code needs to add a header that doesn't fit, calls pskb_expand_head() to get another 4 bytes. Since the existing amount of 'tailroom' must be kept kmalloc(1024+4) is called. This allocates a 2k memory block, again skb_shared_info is put at the end. So the headroom has been increased by 4 bytes and the tailroom by 1020. Another layer needs to add another header. The memory block becomes 4k large. What have I missed? David