[Devel] [PATCH RH9 14/23] ms/memcg: enable accounting for fasync_cache

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


fasync_struct is used by almost all character device drivers to set up the
fasync queue, and for regular files by the file lease code.  This
structure is quite small but long-living and it can be assigned for any
open file.

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

Link: https://lkml.kernel.org/r/1b408625-d71c-0b26-b0b6-9baf00f93e69@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 839d68206de869b8cb4272c5ea10da2ef7ec34cb)
https://jira.sw.ru/browse/PSBM-133990
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 fs/fcntl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index f946bec8f1f1..714e7c9a5fc4 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -1049,7 +1049,8 @@ static int __init fcntl_init(void)
 			__FMODE_EXEC | __FMODE_NONOTIFY));
 
 	fasync_cache = kmem_cache_create("fasync_cache",
-		sizeof(struct fasync_struct), 0, SLAB_PANIC, NULL);
+					 sizeof(struct fasync_struct), 0,
+					 SLAB_PANIC | SLAB_ACCOUNT, NULL);
 	return 0;
 }
 
-- 
2.25.1



More information about the Devel mailing list