From patchwork Thu Sep 2 21:55:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12473039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A977EC433F5 for ; Thu, 2 Sep 2021 21:55:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 59EC7610E6 for ; Thu, 2 Sep 2021 21:55:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 59EC7610E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0B0226B00F7; Thu, 2 Sep 2021 17:55:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0603E6B00F8; Thu, 2 Sep 2021 17:55:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E91328D0001; Thu, 2 Sep 2021 17:55:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id D90836B00F7 for ; Thu, 2 Sep 2021 17:55:37 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A41038080CD6 for ; Thu, 2 Sep 2021 21:55:37 +0000 (UTC) X-FDA: 78543990714.33.0C1D38C Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf24.hostedemail.com (Postfix) with ESMTP id 4E32BB00009F for ; Thu, 2 Sep 2021 21:55:37 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 937D1610A0; Thu, 2 Sep 2021 21:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1630619736; bh=FvpoNv3okN1vKXiQ2X+xRY9ipNWNr950Jx344FsQ89c=; h=Date:From:To:Subject:In-Reply-To:From; b=BwVfug+Ll5cmpk49Yzcl2D8Uf2uVRetk1qcJedyKNksNtqYUZJ0EXknVxsmfChraX w48PnfVjAb7jkUljjirTasV3h1dlThgFhwV+hLVZdSGpPp1K3aUkK639omAor6gQBe 5c0xcDYUnYrV7AVtvYfhVReFyIxECXwyeSeR3qmI= Date: Thu, 02 Sep 2021 14:55:35 -0700 From: Andrew Morton To: 0x7f454c46@gmail.com, adobriyan@gmail.com, akpm@linux-foundation.org, avagin@gmail.com, axboe@kernel.dk, bfields@fieldses.org, bp@alien8.de, bp@suse.de, christian.brauner@ubuntu.com, ebiederm@xmission.com, gregkh@linuxfoundation.org, guro@fb.com, hannes@cmpxchg.org, hpa@zytor.com, jirislaby@kernel.org, jlayton@kernel.org, ktkhai@virtuozzo.com, linux-mm@kvack.org, lizefan.x@bytedance.com, mhocko@kernel.org, mingo@redhat.com, mm-commits@vger.kernel.org, nglaive@gmail.com, oleg@redhat.com, serge@hallyn.com, shakeelb@google.com, tglx@linutronix.de, tj@kernel.org, torvalds@linux-foundation.org, vdavydov.dev@gmail.com, viro@zeniv.linux.org.uk, vvs@virtuozzo.com Subject: [patch 105/212] memcg: enable accounting for signals Message-ID: <20210902215535.KL9kIhN7S%akpm@linux-foundation.org> In-Reply-To: <20210902144820.78957dff93d7bea620d55a89@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=BwVfug+L; spf=pass (imf24.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: u8f5bztxt1crfnygzeqrzzshn8zu8qip X-Rspamd-Queue-Id: 4E32BB00009F X-Rspamd-Server: rspam04 X-HE-Tag: 1630619737-403162 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Vasily Averin Subject: memcg: enable accounting for signals 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 Reviewed-by: Shakeel Butt Cc: Alexander Viro Cc: Alexey Dobriyan Cc: Andrei Vagin Cc: Borislav Petkov Cc: Borislav Petkov Cc: Christian Brauner Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: "Eric W. Biederman" Cc: Greg Kroah-Hartman Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: "J. Bruce Fields" Cc: Jeff Layton Cc: Jens Axboe Cc: Jiri Slaby Cc: Johannes Weiner Cc: Kirill Tkhai Cc: Michal Hocko Cc: Oleg Nesterov Cc: Roman Gushchin Cc: Serge Hallyn Cc: Tejun Heo Cc: Thomas Gleixner Cc: Vladimir Davydov Cc: Yutian Yang Cc: Zefan Li Signed-off-by: Andrew Morton --- kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/signal.c~memcg-enable-accounting-for-signals +++ a/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