Commit 8c8d4d45 authored by Aristeu Rozanski's avatar Aristeu Rozanski Committed by Linus Torvalds

ipc: account for kmem usage on mqueue and msg

When kmem accounting switched from account by default to only account if
flagged by __GFP_ACCOUNT, IPC mqueue and messages was left out.

The production use case at hand is that mqueues should be customizable
via sysctls in Docker containers in a Kubernetes cluster.  This can only
be safely allowed to the users of the cluster (without the risk that
they can cause resource shortage on a node, influencing other users'
containers) if all resources they control are bounded, i.e.  accounted
for.

Link: http://lkml.kernel.org/r/1476806075-1210-1-git-send-email-arozansk@redhat.comSigned-off-by: default avatarAristeu Rozanski <arozansk@redhat.com>
Reported-by: default avatarStefan Schimanski <sttts@redhat.com>
Acked-by: default avatarDavidlohr Bueso <dave@stgolabs.net>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Stefan Schimanski <sttts@redhat.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 07a63c41
...@@ -53,7 +53,7 @@ static struct msg_msg *alloc_msg(size_t len) ...@@ -53,7 +53,7 @@ static struct msg_msg *alloc_msg(size_t len)
size_t alen; size_t alen;
alen = min(len, DATALEN_MSG); alen = min(len, DATALEN_MSG);
msg = kmalloc(sizeof(*msg) + alen, GFP_KERNEL); msg = kmalloc(sizeof(*msg) + alen, GFP_KERNEL_ACCOUNT);
if (msg == NULL) if (msg == NULL)
return NULL; return NULL;
...@@ -65,7 +65,7 @@ static struct msg_msg *alloc_msg(size_t len) ...@@ -65,7 +65,7 @@ static struct msg_msg *alloc_msg(size_t len)
while (len > 0) { while (len > 0) {
struct msg_msgseg *seg; struct msg_msgseg *seg;
alen = min(len, DATALEN_SEG); alen = min(len, DATALEN_SEG);
seg = kmalloc(sizeof(*seg) + alen, GFP_KERNEL); seg = kmalloc(sizeof(*seg) + alen, GFP_KERNEL_ACCOUNT);
if (seg == NULL) if (seg == NULL)
goto out_err; goto out_err;
*pseg = seg; *pseg = seg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment