From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Roman Gushchin <roman.gushchin@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Cc: Dave Chinner <dchinner@redhat.com>,
linux-kernel@vger.kernel.org, Yang Shi <shy828301@gmail.com>,
Kent Overstreet <kent.overstreet@gmail.com>,
Hillf Danton <hdanton@sina.com>
Subject: Re: [PATCH v2 1/7] mm: introduce debugfs interface for kernel memory shrinkers
Date: Sat, 23 Apr 2022 09:51:31 +0200 [thread overview]
Message-ID: <0c64fd49-4ca3-1f5e-a69c-bb1d65f2263c@wanadoo.fr> (raw)
In-Reply-To: <20220422202644.799732-2-roman.gushchin@linux.dev>
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 <roman.gushchin@linux.dev>
> ---
> 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);
> + }
[...]
next prev parent reply other threads:[~2022-04-23 7:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 20:26 [PATCH v2 0/7] mm: introduce shrinker debugfs interface Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 1/7] mm: introduce debugfs interface for kernel memory shrinkers Roman Gushchin
2022-04-23 7:51 ` Christophe JAILLET [this message]
2022-04-22 20:26 ` [PATCH v2 2/7] mm: memcontrol: introduce mem_cgroup_ino() and mem_cgroup_get_from_ino() Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 3/7] mm: introduce memcg interfaces for shrinker debugfs Roman Gushchin
2022-04-23 0:35 ` Hillf Danton
2022-04-23 1:29 ` Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 4/7] mm: introduce numa " Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 5/7] mm: provide shrinkers with names Roman Gushchin
2022-04-23 7:46 ` Christophe JAILLET
2022-04-28 0:25 ` Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 6/7] docs: document shrinker debugfs Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 7/7] tools: add memcg_shrinker.py Roman Gushchin
2022-04-26 6:02 ` [PATCH v2 0/7] mm: introduce shrinker debugfs interface Dave Chinner
2022-04-26 6:45 ` Kent Overstreet
2022-04-26 8:45 ` Hillf Danton
2022-04-26 16:41 ` Roman Gushchin
2022-04-26 18:37 ` Kent Overstreet
2022-04-27 1:22 ` Dave Chinner
2022-04-27 2:18 ` Roman Gushchin
2022-04-26 19:05 ` Roman Gushchin
2022-04-27 1:02 ` 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=0c64fd49-4ca3-1f5e-a69c-bb1d65f2263c@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=akpm@linux-foundation.org \
--cc=dchinner@redhat.com \
--cc=hdanton@sina.com \
--cc=kent.overstreet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=roman.gushchin@linux.dev \
--cc=shy828301@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).