mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
memcg: enable accounting of ipc resources
When user creates IPC objects it forces kernel to allocate memory for these long-living objects. It makes sense to account them to restrict the host's memory consumption from inside the memcg-limited container. This patch enables accounting for IPC shared memory segments, messages semaphores and semaphore's undo lists. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Vasily Averin <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Andrei Vagin <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Dmitry Safonov <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: "J. Bruce Fields" <[email protected]> Cc: Jeff Layton <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Kirill Tkhai <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Serge Hallyn <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: Yutian Yang <[email protected]> Cc: Zefan Li <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
30acd0bdfb
commit
18319498fd
3 files changed
+7
-6
No files matched your search
@@ -147,7 +147,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
|
||||
key_t key = params->key;
|
||||
int msgflg = params->flg;
|
||||
|
||||
msq = kmalloc(sizeof(*msq), GFP_KERNEL);
|
||||
msq = kmalloc(sizeof(*msq), GFP_KERNEL_ACCOUNT);
|
||||
if (unlikely(!msq))
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -514,7 +514,7 @@ static struct sem_array *sem_alloc(size_t nsems)
|
||||
if (nsems > (INT_MAX - sizeof(*sma)) / sizeof(sma->sems[0]))
|
||||
return NULL;
|
||||
|
||||
sma = kvzalloc(struct_size(sma, sems, nsems), GFP_KERNEL);
|
||||
sma = kvzalloc(struct_size(sma, sems, nsems), GFP_KERNEL_ACCOUNT);
|
||||
if (unlikely(!sma))
|
||||
return NULL;
|
||||
|
||||
@@ -1855,7 +1855,7 @@ static inline int get_undo_list(struct sem_undo_list **undo_listp)
|
||||
|
||||
undo_list = current->sysvsem.undo_list;
|
||||
if (!undo_list) {
|
||||
undo_list = kzalloc(sizeof(*undo_list), GFP_KERNEL);
|
||||
undo_list = kzalloc(sizeof(*undo_list), GFP_KERNEL_ACCOUNT);
|
||||
if (undo_list == NULL)
|
||||
return -ENOMEM;
|
||||
spin_lock_init(&undo_list->lock);
|
||||
@@ -1941,7 +1941,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
|
||||
|
||||
/* step 2: allocate new undo structure */
|
||||
new = kvzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems,
|
||||
GFP_KERNEL);
|
||||
GFP_KERNEL_ACCOUNT);
|
||||
if (!new) {
|
||||
ipc_rcu_putref(&sma->sem_perm, sem_rcu_free);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
@@ -2005,7 +2005,8 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
|
||||
if (nsops > ns->sc_semopm)
|
||||
return -E2BIG;
|
||||
if (nsops > SEMOPM_FAST) {
|
||||
sops = kvmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
|
||||
sops = kvmalloc_array(nsops, sizeof(*sops),
|
||||
GFP_KERNEL_ACCOUNT);
|
||||
if (sops == NULL)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user