linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Quanmin Yan <yanquanmin1@huawei.com>
Cc: SeongJae Park <sj@kernel.org>,
	akpm@linux-foundation.org, damon@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	wangkefeng.wang@huawei.com, zuoze1@huawei.com
Subject: Re: [RFC PATCH -next 15/16] mm/damon: the byte statistics data type in damos_stat uses unsigned long long
Date: Wed, 13 Aug 2025 10:10:00 -0700	[thread overview]
Message-ID: <20250813171000.6345-1-sj@kernel.org> (raw)
In-Reply-To: <20250813050706.1564229-16-yanquanmin1@huawei.com>

On Wed, 13 Aug 2025 13:07:05 +0800 Quanmin Yan <yanquanmin1@huawei.com> wrote:

> For 32-bit systems, damos_stat now uses unsigned long long for byte
> statistics data to avoid integer overflow risks inherent in the
> previous design.

I suggested using the core-layer address unit on stat, and ask users to
multiply the addr_unit value to stat values if they want bytes value.  If we
agree on it, I think this patch wouldn't really be required.

> 
> Signed-off-by: Quanmin Yan <yanquanmin1@huawei.com>
> ---
>  include/linux/damon.h     |  6 +++---
>  mm/damon/modules-common.h |  4 ++--
>  mm/damon/sysfs-schemes.c  | 12 ++++++------
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index aa045dcb5b5d..d85850cf06c5 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -333,10 +333,10 @@ struct damos_watermarks {
>   */
>  struct damos_stat {
>  	unsigned long nr_tried;
> -	unsigned long sz_tried;
> +	unsigned long long sz_tried;
>  	unsigned long nr_applied;
> -	unsigned long sz_applied;
> -	unsigned long sz_ops_filter_passed;
> +	unsigned long long sz_applied;
> +	unsigned long long sz_ops_filter_passed;
>  	unsigned long qt_exceeds;
>  };
>  
> diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h
> index c7048a449321..ae45d0eb960e 100644
> --- a/mm/damon/modules-common.h
> +++ b/mm/damon/modules-common.h
> @@ -36,11 +36,11 @@
>  #define DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(stat, try_name,		\
>  		succ_name, qt_exceed_name)				\
>  	module_param_named(nr_##try_name, stat.nr_tried, ulong, 0400);	\
> -	module_param_named(bytes_##try_name, stat.sz_tried, ulong,	\
> +	module_param_named(bytes_##try_name, stat.sz_tried, ullong,	\
>  			0400);						\
>  	module_param_named(nr_##succ_name, stat.nr_applied, ulong,	\
>  			0400);						\
> -	module_param_named(bytes_##succ_name, stat.sz_applied, ulong,	\
> +	module_param_named(bytes_##succ_name, stat.sz_applied, ullong,	\
>  			0400);						\
>  	module_param_named(nr_##qt_exceed_name, stat.qt_exceeds, ulong,	\
>  			0400);
> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index 74056bcd6a2c..3c4882549a28 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c
> @@ -199,10 +199,10 @@ static const struct kobj_type damon_sysfs_scheme_regions_ktype = {
>  struct damon_sysfs_stats {
>  	struct kobject kobj;
>  	unsigned long nr_tried;
> -	unsigned long sz_tried;
> +	unsigned long long sz_tried;
>  	unsigned long nr_applied;
> -	unsigned long sz_applied;
> -	unsigned long sz_ops_filter_passed;
> +	unsigned long long sz_applied;
> +	unsigned long long sz_ops_filter_passed;
>  	unsigned long qt_exceeds;
>  };
>  
> @@ -226,7 +226,7 @@ static ssize_t sz_tried_show(struct kobject *kobj, struct kobj_attribute *attr,
>  	struct damon_sysfs_stats *stats = container_of(kobj,
>  			struct damon_sysfs_stats, kobj);
>  
> -	return sysfs_emit(buf, "%lu\n", stats->sz_tried);
> +	return sysfs_emit(buf, "%llu\n", stats->sz_tried);
>  }
>  
>  static ssize_t nr_applied_show(struct kobject *kobj,
> @@ -244,7 +244,7 @@ static ssize_t sz_applied_show(struct kobject *kobj,
>  	struct damon_sysfs_stats *stats = container_of(kobj,
>  			struct damon_sysfs_stats, kobj);
>  
> -	return sysfs_emit(buf, "%lu\n", stats->sz_applied);
> +	return sysfs_emit(buf, "%llu\n", stats->sz_applied);
>  }
>  
>  static ssize_t sz_ops_filter_passed_show(struct kobject *kobj,
> @@ -253,7 +253,7 @@ static ssize_t sz_ops_filter_passed_show(struct kobject *kobj,
>  	struct damon_sysfs_stats *stats = container_of(kobj,
>  			struct damon_sysfs_stats, kobj);
>  
> -	return sysfs_emit(buf, "%lu\n", stats->sz_ops_filter_passed);
> +	return sysfs_emit(buf, "%llu\n", stats->sz_ops_filter_passed);
>  }
>  
>  static ssize_t qt_exceeds_show(struct kobject *kobj,
> -- 
> 2.34.1


  reply	other threads:[~2025-08-13 17:10 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13  5:06 [RFC PATCH -next 00/16] mm/damon: support ARM32 with LPAE Quanmin Yan
2025-08-13  5:06 ` [RFC PATCH -next 01/16] mm/damon/core: add damon_ctx->addr_unit Quanmin Yan
2025-08-13  5:06 ` [RFC PATCH -next 02/16] mm/damon/paddr: support addr_unit for access monitoring Quanmin Yan
2025-08-13  5:06 ` [RFC PATCH -next 03/16] mm/damon/paddr: support addr_unit for DAMOS_PAGEOUT Quanmin Yan
2025-08-19  6:18   ` SeongJae Park
2025-08-19  6:26     ` SeongJae Park
2025-08-19 14:18       ` Quanmin Yan
2025-08-19 15:53         ` SeongJae Park
2025-08-13  5:06 ` [RFC PATCH -next 04/16] mm/damon/paddr: support addr_unit for DAMOS_LRU_[DE]PRIO Quanmin Yan
2025-08-19  6:19   ` SeongJae Park
2025-08-19  6:26     ` SeongJae Park
2025-08-13  5:06 ` [RFC PATCH -next 05/16] mm/damon/paddr: support addr_unit for MIGRATE_{HOT,COLD} Quanmin Yan
2025-08-19  6:21   ` SeongJae Park
2025-08-19  6:27     ` SeongJae Park
2025-08-13  5:06 ` [RFC PATCH -next 06/16] mm/damon/paddr: support addr_unit for DAMOS_STAT Quanmin Yan
2025-08-19  6:22   ` SeongJae Park
2025-08-19  6:27     ` SeongJae Park
2025-08-13  5:06 ` [RFC PATCH -next 07/16] mm/damon/sysfs: implement addr_unit file under context dir Quanmin Yan
2025-08-19  6:24   ` SeongJae Park
2025-08-19 14:45     ` Quanmin Yan
2025-08-19 15:56       ` SeongJae Park
2025-08-13  5:06 ` [RFC PATCH -next 08/16] Docs/mm/damon/design: document 'address unit' parameter Quanmin Yan
2025-08-13  5:06 ` [RFC PATCH -next 09/16] Docs/admin-guide/mm/damon/usage: document addr_unit file Quanmin Yan
2025-08-13  5:07 ` [RFC PATCH -next 10/16] Docs/ABI/damon: " Quanmin Yan
2025-08-13  5:07 ` [RFC PATCH -next 11/16] mm/damon: add addr_unit for DAMON_RECLAIM and LRU_SORT Quanmin Yan
2025-08-13 16:36   ` SeongJae Park
2025-08-14 12:59     ` Quanmin Yan
2025-08-14 16:11       ` SeongJae Park
2025-08-19 14:59         ` Quanmin Yan
2025-08-13  5:07 ` [RFC PATCH -next 12/16] mm/damon: add damon_ctx->min_region and damon_target->min_region Quanmin Yan
2025-08-13 16:49   ` SeongJae Park
2025-08-19 14:52     ` Quanmin Yan
2025-08-13  5:07 ` [RFC PATCH -next 13/16] mm/damon/sysfs: ensure valid addr_unit setting in damon_sysfs_apply_inputs() Quanmin Yan
2025-08-13 17:02   ` SeongJae Park
2025-08-20  8:45     ` Quanmin Yan
2025-08-13  5:07 ` [RFC PATCH -next 14/16] mm/damon/core: convert sz to byte units when updating state Quanmin Yan
2025-08-13 17:08   ` SeongJae Park
2025-08-20 10:10     ` Quanmin Yan
2025-08-13  5:07 ` [RFC PATCH -next 15/16] mm/damon: the byte statistics data type in damos_stat uses unsigned long long Quanmin Yan
2025-08-13 17:10   ` SeongJae Park [this message]
2025-08-20  9:54     ` Quanmin Yan
2025-08-20 19:57       ` SeongJae Park
2025-08-13  5:07 ` [RFC PATCH -next 16/16] mm/damon/core: handle quota->esz overflow issues Quanmin Yan
2025-08-13 17:15   ` SeongJae Park
2025-08-20 10:06     ` Quanmin Yan
2025-08-13 17:25 ` [RFC PATCH -next 00/16] mm/damon: support ARM32 with LPAE SeongJae Park
2025-08-14  0:57   ` SeongJae Park
2025-08-14 14:07     ` Quanmin Yan
2025-08-14 16:04       ` SeongJae Park
2025-08-20 10:19         ` Quanmin Yan
2025-08-13 17:28 ` SeongJae Park

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=20250813171000.6345-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=wangkefeng.wang@huawei.com \
    --cc=yanquanmin1@huawei.com \
    --cc=zuoze1@huawei.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).