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 08FE7C433F5 for ; Sat, 21 May 2022 00:27:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6062C6B0071; Fri, 20 May 2022 20:27:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B5526B0072; Fri, 20 May 2022 20:27:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47D6A6B0073; Fri, 20 May 2022 20:27:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 346F76B0071 for ; Fri, 20 May 2022 20:27:12 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F162032B3C for ; Sat, 21 May 2022 00:27:11 +0000 (UTC) X-FDA: 79487860662.29.2A1D899 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf26.hostedemail.com (Postfix) with ESMTP id A970C1400D9 for ; Sat, 21 May 2022 00:27:07 +0000 (UTC) Date: Fri, 20 May 2022 17:27:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1653092828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y1FEu8HyQRjr/eREuqJXaUmbStCzspnGbiQi4WtGL3w=; b=qKSKeHCl6hkSBNjsqCznu21xVrYZJ0XVtlXQHrL8SApWHg+Gg+2YyVIem9SHmVww3pjnYk hRFZe3JS97iQjr+WB1JD9TPzBfW5Qyke4oBGQ4GhSQSvV1jXDjOtuHnzzVoK/eSu7XFufG 6dMrln8QIXI9i7ie2PfornX+LlV/OPk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Christophe JAILLET Cc: Andrew Morton , linux-mm@kvack.org, Dave Chinner , linux-kernel@vger.kernel.org, Kent Overstreet , Hillf Danton Subject: Re: [PATCH v3 2/6] mm: shrinkers: introduce debugfs interface for memory shrinkers Message-ID: References: <20220509183820.573666-1-roman.gushchin@linux.dev> <20220509183820.573666-3-roman.gushchin@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A970C1400D9 X-Stat-Signature: ezf9xkgjckgkd6ft1c5zsztai3qwxzaf Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=qKSKeHCl; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf26.hostedemail.com: domain of roman.gushchin@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev X-Rspam-User: X-HE-Tag: 1653092827-497220 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: On Fri, May 20, 2022 at 06:58:12PM +0200, Christophe JAILLET wrote: > Le 09/05/2022 à 20:38, Roman Gushchin a écrit : > > This commit introduces the /sys/kernel/debug/shrinker debugfs > > interface which provides an ability to observe the state of > > individual kernel memory shrinkers. > > > > Because the feature 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 (enabled by default). > > > > This commit introduces the "count" interface for each shrinker > > registered in the system. > > > > The output is in the following format: > > ... > > ... > > ... > > > > To reduce the size of output on machines with many thousands cgroups, > > if the total number of objects on all nodes is 0, the line is omitted. > > > > If the shrinker is not memcg-aware or CONFIG_MEMCG is off, 0 is > > printed as cgroup inode id. If the shrinker is not numa-aware, 0's are > > printed for all nodes except the first one. > > > > 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 | 171 +++++++++++++++++++++++++++++++++++++++ > > mm/vmscan.c | 6 +- > > 5 files changed, 203 insertions(+), 3 deletions(-) > > create mode 100644 mm/shrinker_debug.c > > > > diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h > > index 76fbf92b04d9..2ced8149c513 100644 > > --- a/include/linux/shrinker.h > > +++ b/include/linux/shrinker.h > > @@ -72,6 +72,10 @@ struct shrinker { > > #ifdef CONFIG_MEMCG > > /* ID in shrinker_idr */ > > int id; > > +#endif > > +#ifdef CONFIG_SHRINKER_DEBUG > > + int debugfs_id; > > + struct dentry *debugfs_entry; > > #endif > > /* objs pending delete, per node */ > > atomic_long_t *nr_deferred; > > @@ -94,4 +98,17 @@ extern int register_shrinker(struct shrinker *shrinker); > > extern void unregister_shrinker(struct shrinker *shrinker); > > extern void free_prealloced_shrinker(struct shrinker *shrinker); > > extern void synchronize_shrinkers(void); > > -#endif > > + > > +#ifdef CONFIG_SHRINKER_DEBUG > > +extern int shrinker_debugfs_add(struct shrinker *shrinker); > > +extern void shrinker_debugfs_remove(struct shrinker *shrinker); > > +#else /* CONFIG_SHRINKER_DEBUG */ > > +static inline int shrinker_debugfs_add(struct shrinker *shrinker) > > +{ > > + return 0; > > +} > > +static inline void shrinker_debugfs_remove(struct shrinker *shrinker) > > +{ > > +} > > +#endif /* CONFIG_SHRINKER_DEBUG */ > > +#endif /* _LINUX_SHRINKER_H */ > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > > index 3fd7a2e9eaf1..5fa65a649798 100644 > > --- a/lib/Kconfig.debug > > +++ b/lib/Kconfig.debug > > @@ -733,6 +733,15 @@ config SLUB_STATS > > out which slabs are relevant to a particular load. > > Try running: slabinfo -DA > > +config SHRINKER_DEBUG > > + default y > > The previous version of the serie had default 'n'. > Is it intentional to have it now activated by default? It looked more like a > tuning functionality when fine grained mangement of shrinker is needed. Yes, it is intentional. The overhead is small, so I don't think we have a good reason to hide it by default behind a config option. In my opinion, enabling it be default will increase the chances to gather a useful data. It was the feedback I've received for one of the previous versions of the patchset, and I think it's totally valid. And preserving the config option allows to have a zero overhead for really constrained systems. Thanks!