From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48CC2C433F5 for ; Sat, 23 Apr 2022 07:51:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9781F6B0073; Sat, 23 Apr 2022 03:51:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 926D56B0074; Sat, 23 Apr 2022 03:51:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8155C6B0075; Sat, 23 Apr 2022 03:51:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 73D346B0073 for ; Sat, 23 Apr 2022 03:51:35 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 3C979121037 for ; Sat, 23 Apr 2022 07:51:35 +0000 (UTC) X-FDA: 79387374150.02.B1C739E Received: from smtp.smtpout.orange.fr (smtp09.smtpout.orange.fr [80.12.242.131]) by imf13.hostedemail.com (Postfix) with ESMTP id F186720034 for ; Sat, 23 Apr 2022 07:51:30 +0000 (UTC) Received: from [192.168.1.18] ([86.243.180.246]) by smtp.orange.fr with ESMTPA id iAYGnxejTKpuHiAYGn1Uqr; Sat, 23 Apr 2022 09:51:33 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 23 Apr 2022 09:51:33 +0200 X-ME-IP: 86.243.180.246 Message-ID: <0c64fd49-4ca3-1f5e-a69c-bb1d65f2263c@wanadoo.fr> Date: Sat, 23 Apr 2022 09:51:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2 1/7] mm: introduce debugfs interface for kernel memory shrinkers Content-Language: fr To: Roman Gushchin , Andrew Morton , linux-mm@kvack.org Cc: Dave Chinner , linux-kernel@vger.kernel.org, Yang Shi , Kent Overstreet , Hillf Danton Newsgroups: gmane.linux.kernel,gmane.linux.kernel.mm References: <20220422202644.799732-1-roman.gushchin@linux.dev> <20220422202644.799732-2-roman.gushchin@linux.dev> From: Christophe JAILLET In-Reply-To: <20220422202644.799732-2-roman.gushchin@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: F186720034 X-Stat-Signature: zeae49hmhcgf8mmx1bwi4ucurcwfu4ne X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf13.hostedemail.com: domain of christophe.jaillet@wanadoo.fr designates 80.12.242.131 as permitted sender) smtp.mailfrom=christophe.jaillet@wanadoo.fr X-Rspamd-Server: rspam09 X-HE-Tag: 1650700290-327521 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: Le 22/04/2022 à 22:26, Roman Gushchin a écrit : > This commit introduces the /sys/kernel/debug/shrinker debugfs > interface which provides an ability to observe the state and interact > with individual kernel memory shrinkers. > > Because the feature is oriented on kernel developers and adds some > memory overhead (which shouldn't be large unless there is a huge > amount of registered shrinkers), it's guarded by a config option > (disabled by default). > > This commit introduces "count" and "scan" interfaces for each > shrinker registered in the system. > > Basic usage: > 1) Get the number of objects > $ cat count > > 2) Try to reclaim 500 objects > $ echo "500" > scan > > Following commits in the series will add memcg- and numa-specific > features. > > This commit gives debugfs entries simple numeric names, which are not > very convenient. The following commit in the series will provide > shrinkers with more meaningful names. > > Signed-off-by: Roman Gushchin > --- > include/linux/shrinker.h | 19 +++- > lib/Kconfig.debug | 9 ++ > mm/Makefile | 1 + > mm/shrinker_debug.c | 214 +++++++++++++++++++++++++++++++++++++++ > mm/vmscan.c | 6 +- > 5 files changed, 246 insertions(+), 3 deletions(-) > create mode 100644 mm/shrinker_debug.c [...] > diff --git a/mm/shrinker_debug.c b/mm/shrinker_debug.c > new file mode 100644 > index 000000000000..4df7382a0737 > --- /dev/null > +++ b/mm/shrinker_debug.c [...] > +int shrinker_debugfs_add(struct shrinker *shrinker) > +{ > + struct dentry *entry; > + char buf[256]; Later, this buffer is filled with a "%s-%d". (patch 5/7) The %s is generated out of a max 64 bytes long string. To be consistent with the 2 buffers sizes, maybe this one could be reduced a bit to save some stack? CJ > + int id; > + > + lockdep_assert_held(&shrinker_rwsem); > + > + /* debugfs isn't initialized yet, add debugfs entries later. */ > + if (!shrinker_debugfs_root) > + return 0; > + > + id = ida_alloc(&shrinker_debugfs_ida, GFP_KERNEL); > + if (id < 0) > + return id; > + shrinker->debugfs_id = id; > + > + snprintf(buf, sizeof(buf), "%d", id); > + > + /* create debugfs entry */ > + entry = debugfs_create_dir(buf, shrinker_debugfs_root); > + if (IS_ERR(entry)) { > + ida_free(&shrinker_debugfs_ida, id); > + return PTR_ERR(entry); > + } [...]