]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
xfrm: use a dedicated slab cache for struct xfrm_state
authorMathias Krause <minipli@googlemail.com>
Thu, 3 May 2018 08:55:07 +0000 (10:55 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 4 May 2018 08:14:00 +0000 (10:14 +0200)
commit565f0fa902b64020d5d147ff1708567e9e0b6e49
treed9b201aa8f3eec09b02e5ff476f30ae658b661bd
parent154a8c46bad2aae171fa25d5fa1d04165ef69650
xfrm: use a dedicated slab cache for struct xfrm_state

struct xfrm_state is rather large (768 bytes here) and therefore wastes
quite a lot of memory as it falls into the kmalloc-1024 slab cache,
leaving 256 bytes of unused memory per XFRM state object -- a net waste
of 25%.

Using a dedicated slab cache for struct xfrm_state reduces the level of
internal fragmentation to a minimum.

On my configuration SLUB chooses to create a slab cache covering 4
pages holding 21 objects, resulting in an average memory waste of ~13
bytes per object -- a net waste of only 1.6%.

In my tests this led to memory savings of roughly 2.3MB for 10k XFRM
states.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_state.c