[Devel] [PATCH RH9 17/23] ms/memcg: enable accounting for signals

Vasily Averin vvs at virtuozzo.com
Sun Sep 26 13:30:13 MSK 2021


When a user send a signal to any another processes it forces the kernel to
allocate memory for 'struct sigqueue' objects.  The number of signals is
limited by RLIMIT_SIGPENDING resource limit, but even the default settings
allow each user to consume up to several megabytes of memory.

It makes sense to account for these allocations to restrict the host's
memory consumption from inside the memcg-limited container.

Link: https://lkml.kernel.org/r/e34e958c-e785-712e-a62a-2c7b66c646c7@virtuozzo.com
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
Reviewed-by: Shakeel Butt <shakeelb at google.com>
Cc: Alexander Viro <viro at zeniv.linux.org.uk>
Cc: Alexey Dobriyan <adobriyan at gmail.com>
Cc: Andrei Vagin <avagin at gmail.com>
Cc: Borislav Petkov <bp at alien8.de>
Cc: Borislav Petkov <bp at suse.de>
Cc: Christian Brauner <christian.brauner at ubuntu.com>
Cc: Dmitry Safonov <0x7f454c46 at gmail.com>
Cc: "Eric W. Biederman" <ebiederm at xmission.com>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Cc: "H. Peter Anvin" <hpa at zytor.com>
Cc: Ingo Molnar <mingo at redhat.com>
Cc: "J. Bruce Fields" <bfields at fieldses.org>
Cc: Jeff Layton <jlayton at kernel.org>
Cc: Jens Axboe <axboe at kernel.dk>
Cc: Jiri Slaby <jirislaby at kernel.org>
Cc: Johannes Weiner <hannes at cmpxchg.org>
Cc: Kirill Tkhai <ktkhai at virtuozzo.com>
Cc: Michal Hocko <mhocko at kernel.org>
Cc: Oleg Nesterov <oleg at redhat.com>
Cc: Roman Gushchin <guro at fb.com>
Cc: Serge Hallyn <serge at hallyn.com>
Cc: Tejun Heo <tj at kernel.org>
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: Vladimir Davydov <vdavydov.dev at gmail.com>
Cc: Yutian Yang <nglaive at gmail.com>
Cc: Zefan Li <lizefan.x at bytedance.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
(cherry picked from commit 5f58c39819ff78ca5ddbba2b3cd8ff4779b19bb5)
https://jira.sw.ru/browse/PSBM-133990
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 kernel/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index a3229add4455..8921c4a8419f 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -4663,7 +4663,7 @@ void __init signals_init(void)
 {
 	siginfo_buildtime_checks();
 
-	sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);
+	sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC | SLAB_ACCOUNT);
 }
 
 #ifdef CONFIG_KGDB_KDB
-- 
2.25.1



More information about the Devel mailing list