From patchwork Thu Sep 2 21:55:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12473033 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 8CBC4C433F5 for ; Thu, 2 Sep 2021 21:55:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4BD48610CF for ; Thu, 2 Sep 2021 21:55:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4BD48610CF 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 D82AA6B00F1; Thu, 2 Sep 2021 17:55:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D31636B00F2; Thu, 2 Sep 2021 17:55:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD1FC6B00F3; Thu, 2 Sep 2021 17:55:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id AEF6A6B00F1 for ; Thu, 2 Sep 2021 17:55:25 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 770FA1802F4B9 for ; Thu, 2 Sep 2021 21:55:25 +0000 (UTC) X-FDA: 78543990210.28.E4E496A Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf16.hostedemail.com (Postfix) with ESMTP id 309A4F00008F for ; Thu, 2 Sep 2021 21:55:25 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 73EFB610CE; Thu, 2 Sep 2021 21:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1630619724; bh=oSP6LUWydAcW9pqliev4AkkC3hbKhQQj+TBNLLjTL7o=; h=Date:From:To:Subject:In-Reply-To:From; b=ciNlaRWqT4QJLwfQgAIe9scTR6LhaEH4JACR/S5yVlQlfAk8IrRreA/bT5uHjETLE eqdXDV/QWIKrCF9rKqsj055iOPM8+bgb4Zf/BCzjwpu7GFcqSxHVtuAWgOvnGJlEd9 pKwUpxdOLfl6ogMszBWBVJT3geSzAgnXWCTrGlf4= Date: Thu, 02 Sep 2021 14:55:23 -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 102/212] memcg: enable accounting for fasync_cache Message-ID: <20210902215523.0hTms4iNk%akpm@linux-foundation.org> In-Reply-To: <20210902144820.78957dff93d7bea620d55a89@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 309A4F00008F Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=ciNlaRWq; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam01 X-Stat-Signature: ze3dgcciuidjzdakjab4t4hwsdrhp86i X-HE-Tag: 1630619725-855121 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 fasync_cache 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 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 --- fs/fcntl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/fcntl.c~memcg-enable-accounting-for-fasync_cache +++ a/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; }