net, mm: account sock objects to kmemcg
Subsystems (4)
PATCH v2 1/1 net, mm: account sock objects to kmemcg
Currently the kernel accounts the memory for network traffic through mem_cgroup_[un]charge_skmem() interface. However the memory accounted only includes the truesize of sk_buff which does not include the size of sock objects. In our production environment, with opt-out kmem accounting, the sock kmem caches (TCP[v6], UDP[v6], RAW[v6], UNIX) are among the top most charged kmem caches and consume a significant amount of memory which can not be left as system overhead. So, this patch converts the kmem caches of all sock objects to SLAB_ACCOUNT.
---
Changelog since v1:
- Instead of specific sock kmem_caches, convert all sock kmem_caches to use SLAB_ACCOUNT.
net/core/sock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/core/sock.c +5 -2
@@ -3243,7 +3243,8 @@ static int req_prot_init(const struct proto *prot) rsk_prot->slab =kmem_cache_create (rsk_prot->slab_name, rsk_prot->obj_size,0 , - prot->slab_flags,NULL ); +SLAB_ACCOUNT | prot->slab_flags, +NULL );if (!rsk_prot->slab) { pr_crit("%s: Can't create request sock SLAB cache!\n",
@@ -3258,7 +3259,8 @@ int proto_register(struct proto *prot, int alloc_slab)if (alloc_slab) { prot->slab =kmem_cache_create_usercopy (prot->name, prot->obj_size,0 , -SLAB_HWCACHE_ALIGN | prot->slab_flags, +SLAB_HWCACHE_ALIGN |SLAB_ACCOUNT | + prot->slab_flags, prot->useroffset, prot->usersize,NULL );
@@ -3281,6 +3283,7 @@ int proto_register(struct proto *prot, int alloc_slab)kmem_cache_create (prot->twsk_prot->twsk_slab_name, prot->twsk_prot->twsk_obj_size,0 , +SLAB_ACCOUNT | prot->slab_flags,NULL );if (prot->twsk_prot->twsk_slab ==NULL )
Signature · 1 line
2.18.0.rc2.346.g013aa6912e-goog
Quoted 11 lines · Shakeel Butt
Currently the kernel accounts the memory for network traffic through mem_cgroup_[un]charge_skmem() interface. However the memory accounted only includes the truesize of
sk_buffwhich does not include the size of sock objects. In our production environment, with opt-out kmem accounting, the sock kmem caches (TCP[v6], UDP[v6], RAW[v6], UNIX) are among the top most charged kmem caches and consume a significant amount of memory which can not be left as system overhead. So, this patch converts the kmem caches of all sock objects toSLAB_ACCOUNT.Signed-off-by Shakeel Butt <[email protected]>Suggested-by Eric Dumazet <[email protected]>
Looks good for me.
Quoted 41 lines
---
Changelog since v1:
- Instead of specific sockkmem_caches, convert all sockkmem_cachesto useSLAB_ACCOUNT.net/core/sock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)net/core/sock.c +5
-2@@ -3243,7 +3243,8 @@ static int req_prot_init(const struct proto *prot) rsk_prot->slab =kmem_cache_create (rsk_prot->slab_name, rsk_prot->obj_size,0 , - prot->slab_flags,NULL ); +SLAB_ACCOUNT | prot->slab_flags, +NULL );if (!rsk_prot->slab) { pr_crit("%s: Can't create request sock SLAB cache!\n",@@ -3258,7 +3259,8 @@ int proto_register(struct proto *prot, int alloc_slab)if (alloc_slab) { prot->slab =kmem_cache_create_usercopy (prot->name, prot->obj_size,0 , -SLAB_HWCACHE_ALIGN | prot->slab_flags, +SLAB_HWCACHE_ALIGN |SLAB_ACCOUNT | + prot->slab_flags, prot->useroffset, prot->usersize,NULL );@@ -3281,6 +3283,7 @@ int proto_register(struct proto *prot, int alloc_slab)kmem_cache_create (prot->twsk_prot->twsk_slab_name, prot->twsk_prot->twsk_obj_size,0 , +SLAB_ACCOUNT | prot->slab_flags,NULL );if (prot->twsk_prot->twsk_slab ==NULL )
Quoted 9 lines · Shakeel Butt
Currently the kernel accounts the memory for network traffic through mem_cgroup_[un]charge_skmem() interface. However the memory accounted only includes the truesize of
sk_buffwhich does not include the size of sock objects. In our production environment, with opt-out kmem accounting, the sock kmem caches (TCP[v6], UDP[v6], RAW[v6], UNIX) are among the top most charged kmem caches and consume a significant amount of memory which can not be left as system overhead. So, this patch converts the kmem caches of all sock objects toSLAB_ACCOUNT.
Quoted 3 lines
Signed-off-by Shakeel Butt <[email protected]>Suggested-by Eric Dumazet <[email protected]>---
Thanks !
From: Shakeel Butt <[email protected]>
Date: Wed, 27 Jun 2018 15:16:42 -0700
Quoted 9 lines
Currently the kernel accounts the memory for network traffic through mem_cgroup_[un]charge_skmem() interface. However the memory accounted only includes the truesize of
sk_buffwhich does not include the size of sock objects. In our production environment, with opt-out kmem accounting, the sock kmem caches (TCP[v6], UDP[v6], RAW[v6], UNIX) are among the top most charged kmem caches and consume a significant amount of memory which can not be left as system overhead. So, this patch converts the kmem caches of all sock objects toSLAB_ACCOUNT.
Quoted 6 lines
Signed-off-by Shakeel Butt <[email protected]>Suggested-by Eric Dumazet <[email protected]>---
Changelog since v1:
- Instead of specific sockkmem_caches, convert all sockkmem_cachesto useSLAB_ACCOUNT.
Applied, thank you.