Re: [PATCH rfc 1/5] mm: introduce sysfs interface for debugging kernel shrinker

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 15 Apr 2022 17:27:52 -0700 Roman Gushchin wrote:
> This commit introduces the /sys/kernel/shrinker sysfs 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).
> 
> To simplify the code, kobjects are not embedded into shrinkers
> objects, but are created, linked and unlinked dynamically.
> 
> This commit introduces basic "count" and "scan" interfaces.
> Basic usage:
>   $ cat count                   : get the number of objects
>   $ echo "500" > scan           : try to reclaim 500 objects
>   $ cat scan                    : get the number of objects reclaimed

What is nice in design is the window opened for scanning individual shrinker
without bothering wakeup of kswapd, thus this is good work from the drawing
board.

> +
> +static ssize_t scan_store(struct shrinker_kobj *skobj,
> +			  struct shrinker_attribute *attr,
> +			  const char *buf, size_t size)
> +{
> +	unsigned long nr, total = 0, nr_to_scan = 0, freed = 0;
> +	unsigned long *count_per_node = NULL;
> +	struct shrinker *shrinker;
> +	ssize_t ret = size;
> +	int nid;
> +
> +	if (kstrtoul(buf, 10, &nr_to_scan))
> +		return -EINVAL;
> +
> +	down_read(&shrinker_rwsem);

Nit, use down_read_killable instead to allow the CAP_SYS_ADMIN guy to
change mind on cmdline.

Hillf




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux