All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Gushchin <roman.gushchin@linux.dev>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Dave Chinner <dchinner@redhat.com>,
	linux-kernel@vger.kernel.org,
	Kent Overstreet <kent.overstreet@gmail.com>,
	Hillf Danton <hdanton@sina.com>
Subject: Re: [PATCH v3 2/6] mm: shrinkers: introduce debugfs interface for memory shrinkers
Date: Fri, 20 May 2022 17:27:04 -0700	[thread overview]
Message-ID: <Yogx2BzID3JXm8sn@carbon> (raw)
In-Reply-To: <d938e52e-3704-d095-cafe-a6218701896a@wanadoo.fr>

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:
> > <cgroup inode id> <nr of objects on node 0> <nr of objects on node 1>...
> > <cgroup inode id> <nr of objects on node 0> <nr of objects on node 1>...
> > ...
> > 
> > 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 <roman.gushchin@linux.dev>
> > ---
> >   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!

  parent reply	other threads:[~2022-05-21  0:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09 18:38 [PATCH v3 0/6] mm: introduce shrinker debugfs interface Roman Gushchin
2022-05-09 18:38 ` [PATCH v3 1/6] mm: memcontrol: introduce mem_cgroup_ino() and mem_cgroup_get_from_ino() Roman Gushchin
2022-05-22  7:05   ` Muchun Song
2022-05-23 18:12     ` Roman Gushchin
2022-05-24  2:00       ` Muchun Song
2022-05-09 18:38 ` [PATCH v3 2/6] mm: shrinkers: introduce debugfs interface for memory shrinkers Roman Gushchin
2022-05-20 16:45   ` Kent Overstreet
2022-05-21  0:27     ` Roman Gushchin
2022-05-20 16:58   ` Christophe JAILLET
2022-05-20 17:00     ` Kent Overstreet
2022-05-21  0:27     ` Roman Gushchin [this message]
2022-05-22 10:36   ` Muchun Song
2022-05-23 18:24     ` Roman Gushchin
2022-05-24  2:06       ` Muchun Song
2022-05-09 18:38 ` [PATCH v3 3/6] mm: shrinkers: provide shrinkers with names Roman Gushchin
2022-05-20 16:41   ` Kent Overstreet
2022-05-21  0:31     ` Roman Gushchin
2022-05-22 11:08   ` Muchun Song
2022-05-23 22:06     ` Roman Gushchin
2022-05-24  9:12       ` Muchun Song
2022-05-22 22:13   ` Dave Chinner
2022-05-24  2:18     ` Roman Gushchin
2022-05-24 23:54       ` Roman Gushchin
2022-05-09 18:38 ` [PATCH v3 4/6] mm: docs: document shrinker debugfs Roman Gushchin
2022-05-09 18:38 ` [PATCH v3 5/6] tools: add memcg_shrinker.py Roman Gushchin
2022-05-09 18:38 ` [PATCH v3 6/6] mm: shrinkers: add scan interface for shrinker debugfs Roman Gushchin
2022-05-22 11:35   ` Muchun Song
2022-05-23 20:54     ` Roman Gushchin
2022-05-24  2:23       ` Muchun Song
2022-05-19 17:15 ` [PATCH v3 0/6] mm: introduce shrinker debugfs interface Roman Gushchin
2022-05-20  4:33   ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yogx2BzID3JXm8sn@carbon \
    --to=roman.gushchin@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dchinner@redhat.com \
    --cc=hdanton@sina.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.