From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vasily Averin Subject: [PATCH v3 15/16] memcg: enable accounting for tty-related objects Date: Thu, 22 Apr 2021 13:37:53 +0300 Message-ID: References: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:Subject :From; bh=QoFMKA5kGxcmV30QXvEFU0GgjyF2++XgzGxYWtiP1xY=; b=AXrkdEV1/cPzyh3/y1/ tuapRTjZUyRAWAZcOT6tRqKEtAXVFqLEu27UWue1f6xywfCrB73zpEHwaaM6Xx523XUTCx0CkVjZj 6SsZ5CXVrP8Ch3DQV1f1DAhD3VGd2G6AMpzdSSGh3cgDNoozk+z+CR+wZCSoLveojV/YRNccSYg= In-Reply-To: Content-Language: en-US List-ID: Content-Type: text/plain; charset="us-ascii" To: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Michal Hocko , Shakeel Butt , Johannes Weiner , Vladimir Davydov Cc: Roman Gushchin , Greg Kroah-Hartman , Jiri Slaby At each login the user forces the kernel to create a new terminal and allocate up to ~1Kb memory for the tty-related structures. It makes sense to account for them to restrict the host's memory consumption from inside the memcg-limited container. Signed-off-by: Vasily Averin --- drivers/tty/tty_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 391bada..e613b8e 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1502,7 +1502,7 @@ void tty_save_termios(struct tty_struct *tty) /* Stash the termios data */ tp = tty->driver->termios[idx]; if (tp == NULL) { - tp = kmalloc(sizeof(*tp), GFP_KERNEL); + tp = kmalloc(sizeof(*tp), GFP_KERNEL_ACCOUNT); if (tp == NULL) return; tty->driver->termios[idx] = tp; @@ -3127,7 +3127,7 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx) { struct tty_struct *tty; - tty = kzalloc(sizeof(*tty), GFP_KERNEL); + tty = kzalloc(sizeof(*tty), GFP_KERNEL_ACCOUNT); if (!tty) return NULL; -- 1.8.3.1