diff options
author | Shakeel Butt <shakeelb@google.com> | 2018-06-27 18:16:42 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-06-29 08:56:27 -0400 |
commit | e699e2c6a654ff8d7303f5297ab5dd83da7b23e0 (patch) | |
tree | 6208cad6013a78ff37495cd6080610ebbadcd6ba | |
parent | 4205c88eaf17b5f3ee30032d68df55cd5d9077a1 (diff) |
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.
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Suggested-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/sock.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index bcc41829a16d..9e8f65585b81 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -3243,7 +3243,8 @@ static int req_prot_init(const struct proto *prot) | |||
3243 | 3243 | ||
3244 | rsk_prot->slab = kmem_cache_create(rsk_prot->slab_name, | 3244 | rsk_prot->slab = kmem_cache_create(rsk_prot->slab_name, |
3245 | rsk_prot->obj_size, 0, | 3245 | rsk_prot->obj_size, 0, |
3246 | prot->slab_flags, NULL); | 3246 | SLAB_ACCOUNT | prot->slab_flags, |
3247 | NULL); | ||
3247 | 3248 | ||
3248 | if (!rsk_prot->slab) { | 3249 | if (!rsk_prot->slab) { |
3249 | pr_crit("%s: Can't create request sock SLAB cache!\n", | 3250 | pr_crit("%s: Can't create request sock SLAB cache!\n", |
@@ -3258,7 +3259,8 @@ int proto_register(struct proto *prot, int alloc_slab) | |||
3258 | if (alloc_slab) { | 3259 | if (alloc_slab) { |
3259 | prot->slab = kmem_cache_create_usercopy(prot->name, | 3260 | prot->slab = kmem_cache_create_usercopy(prot->name, |
3260 | prot->obj_size, 0, | 3261 | prot->obj_size, 0, |
3261 | SLAB_HWCACHE_ALIGN | prot->slab_flags, | 3262 | SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT | |
3263 | prot->slab_flags, | ||
3262 | prot->useroffset, prot->usersize, | 3264 | prot->useroffset, prot->usersize, |
3263 | NULL); | 3265 | NULL); |
3264 | 3266 | ||
@@ -3281,6 +3283,7 @@ int proto_register(struct proto *prot, int alloc_slab) | |||
3281 | kmem_cache_create(prot->twsk_prot->twsk_slab_name, | 3283 | kmem_cache_create(prot->twsk_prot->twsk_slab_name, |
3282 | prot->twsk_prot->twsk_obj_size, | 3284 | prot->twsk_prot->twsk_obj_size, |
3283 | 0, | 3285 | 0, |
3286 | SLAB_ACCOUNT | | ||
3284 | prot->slab_flags, | 3287 | prot->slab_flags, |
3285 | NULL); | 3288 | NULL); |
3286 | if (prot->twsk_prot->twsk_slab == NULL) | 3289 | if (prot->twsk_prot->twsk_slab == NULL) |