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: <20220920165238.59328-1-sj@kernel.org>
Date:   Tue, 20 Sep 2022 16:52:38 +0000
From:   SeongJae Park <sj@...nel.org>
To:     xiakaixu1987@...il.com
Cc:     sj@...nel.org, akpm@...ux-foundation.org, damon@...ts.linux.dev,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Kaixu Xia <kaixuxia@...cent.com>
Subject: Re: [PATCH v2] mm/damon: deduplicate damon_{reclaim,lru_sort}_apply_parameters()

On Tue, 20 Sep 2022 11:44:21 +0800 xiakaixu1987@...il.com wrote:

> From: Kaixu Xia <kaixuxia@...cent.com>
> 
> The bodies of damon_{reclaim,lru_sort}_apply_parameters() contain
> duplicates. This commit add a common function
> damon_set_region_biggest_system_ram_default() to removes the
> duplicates.
> 
> Signed-off-by: Kaixu Xia <kaixuxia@...cent.com>
> Suggested-by: SeongJae Park <sj@...nel.org>
> ---
> v2:
>  -change the common function name and add kernel comment.
> 
>  include/linux/damon.h |  3 ++-
>  mm/damon/core.c       | 35 ++++++++++++++++++++++++++++++++++-
>  mm/damon/lru_sort.c   | 13 +++----------
>  mm/damon/reclaim.c    | 13 +++----------
>  4 files changed, 42 insertions(+), 22 deletions(-)
> 
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index e7808a84675f..ed5470f50bab 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -557,7 +557,8 @@ static inline bool damon_target_has_pid(const struct damon_ctx *ctx)
>  int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive);
>  int damon_stop(struct damon_ctx **ctxs, int nr_ctxs);
>  
> -bool damon_find_biggest_system_ram(unsigned long *start, unsigned long *end);
> +int damon_set_region_biggest_system_ram_default(struct damon_target *t,
> +				unsigned long *start, unsigned long *end);
>  
>  #endif	/* CONFIG_DAMON */
>  
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 9c80c6eb00c2..9e96cb9fb5db 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -1245,7 +1245,8 @@ static int walk_system_ram(struct resource *res, void *arg)
>   * Find biggest 'System RAM' resource and store its start and end address in
>   * @start and @end, respectively.  If no System RAM is found, returns false.
>   */
> -bool damon_find_biggest_system_ram(unsigned long *start, unsigned long *end)
> +static bool damon_find_biggest_system_ram(unsigned long *start,
> +						unsigned long *end)
>  
>  {
>  	struct damon_system_ram_region arg = {};
> @@ -1259,6 +1260,38 @@ bool damon_find_biggest_system_ram(unsigned long *start, unsigned long *end)
>  	return true;
>  }
>  
> +/*

We also need to add one more asterisk here to make this a valid kerneldoc
comment.

> + * damon_set_region_biggest_system_ram_default() - Set the region of the given
> + * monitoring target as requested, or biggest 'System RAM'.
> + * @t:		The monitoring target to set the region.
> + * @start:	The pointer to the start address of the region.
> + * @end:	The pointer to the end address of the region.
> + *
> + * This function sets the region of @t as requested by @start and @end.  If the
> + * values of the two pointers are pointing to are zero, however, this function
> + * finds the biggest 'System RAM' resource and set the region to cover the
> + * resource.  In the latter case, this function saves the start and end address
> + * of the resource in @start and @end, respectively.
> + *
> + * Return: 0 on success, negative error code otherwise.
> + */
> +int damon_set_region_biggest_system_ram_default(struct damon_target *t,
> +			unsigned long *start, unsigned long *end)
> +{
> +	struct damon_addr_range addr_range;
> +
> +	if (*start > *end)
> +		return -EINVAL;
> +
> +	if (!*start && !*end &&
> +		!damon_find_biggest_system_ram(start, end))
> +		return -EINVAL;
> +
> +	addr_range.start = *start;
> +	addr_range.end = *end;
> +	return damon_set_regions(t, &addr_range, 1);
> +}
> +
[...]

Thanks,
SJ

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ