lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c64fd49-4ca3-1f5e-a69c-bb1d65f2263c@wanadoo.fr>
Date:   Sat, 23 Apr 2022 09:51:31 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Roman Gushchin <roman.gushchin@...ux.dev>,
        Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org
Cc:     Dave Chinner <dchinner@...hat.com>, linux-kernel@...r.kernel.org,
        Yang Shi <shy828301@...il.com>,
        Kent Overstreet <kent.overstreet@...il.com>,
        Hillf Danton <hdanton@...a.com>
Subject: Re: [PATCH v2 1/7] mm: introduce debugfs interface for kernel memory
 shrinkers

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@...ux.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);
> +	}

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ