public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio
@ 2026-04-04 16:39 SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 1/9] mm/damon/core: introduce " SeongJae Park
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, Brendan Higgins,
	David Gow, David Hildenbrand, Jonathan Corbet, Lorenzo Stoakes,
	Michal Hocko, Mike Rapoport, Shuah Khan, Shuah Khan,
	Suren Baghdasaryan, Vlastimil Babka, damon, kunit-dev, linux-doc,
	linux-kernel, linux-kselftest, linux-mm

TL; DR: Let users set different DAMOS quota charge ratios for DAMOS
action failed regions, for deterministic and consistent DAMOS action
progress.

Common Reports: Unexpectedly Slow DAMOS
=======================================

One common issue report that we get from DAMON users is that DAMOS
action applying progress speed is sometimes much slower than expected.
And one common root cause is that the DAMOS quota is exceeded by the
action applying failed memory regions.

For example, a group of users tried to run DAMOS-based proactive memory
reclamation (DAMON_RECLAIM) with 100 MiB per second DAMOS quota.  They
ran it on a system having no active workload which means all memory of
the system is cold.  The expectation was that the system will show 100
MiB per second reclamation until (nearly) all memory is reclaimed. But
what they found is that the speed is quite inconsistent and sometimes it
becomes very slower than the expectation, sometimes even no reclamation
at all for about tens of seconds.  The upper limit of the speed (100 MiB
per second) was being kept as expected, though.

By monitoring the qt_exceeds (number of DAMOS quota exceed events) DAMOS
stat, we found DAMOS quota is always exceeded when the speed is slow. By
monitoring sz_tried and sz_applied (the total amount of DAMOS action
tried memory and succeeded memory) DAMOS stats together, we found the
reclamation attempts nearly always failed when the speed is slow.

DAMOS quota charges DAMOS action tried regions regardless of the
successfulness of the try.  Hence in the example reported case, there
was unreclaimable memory spread around the system memory.  Sometimes
nearly 100 MiB of memory that DAMOS tried to reclaim in the given quota
interval was reclaimable, and therefore showed nearly 100 MiB per second
speed.  Sometimes nearly 99 MiB of memory that DAMOS was trying to
reclaim in the given quota interval was unreclaimable, and therefore
showing only about 1 MiB per second reclaim speed.

We explained it is an expected behavior of the feature rather than a
bug, as DAMOS quota is there for only the upper-limit of the speed.  The
users agreed and later reported a huge win from the adoption of
DAMON_RECLAIM on their products.

It is Not a Bug but a Feature; But...
=====================================

So nothing is broken.  DAMOS quota is working as intended, as the upper
limit of the speed.  It also provides its behavior observability via
DAMOS stat.  In the real world production environment that runs long
term active workloads and matters stability, the speed sometimes being
slow is not a real problem.

But, the non-deterministic behavior is sometimes annoying, especially in
lab environments.  Even in a realistic production environment, when
there is a huge amount of DAMOS action unapplicable memory, the speed
could be problematically slow.  Let's suppose a virtual machines
provider that setup 99% of the host memory as hugetlb pages that cannot
be reclaimed, to give it to virtual machines.  Also, when aim-oriented
DAMOS auto-tuning is applied, this could also make the internal feedback
loop confused.

The intention of the current behavior was that trying DAMOS action to
regions would anyway impose some overhead, and therefore somehow be
charged.  But in the real world, the overhead for failed action is much
lighter than successful action.  Charging those at the same ratio may be
unfair, or at least suboptimum in some environments.

DAMOS Action Failed Region Quota Charge Ratio
=============================================

Let users set the charge ratio for the action-failed memory, for more
optimal and deterministic use of DAMOS.  It allows users to specify the
numerator and the denominator of the ratio for flexible setup.  For
example, let's suppose the numerator and the denominator are set to 1
and 4,096, respectively.  The ratio is 1 / 4,096.  A DAMOS scheme action
is applied to 5 GiB memory.  For 1 GiB of the memory, the action is
succeeded.  For the rest (4 GiB), the action is failed.  Then, only 1
GiB and 1 MiB quota is charged.

The optimal charge ratio will depend on the use case and
system/workload.  I'd recommend starting from setting the nominator as 1
and the denominator as PAGE_SIZE and tune based on the results, because
many DAMOS actions are applied at page level.

Tests
=====

I tested this feature in the steps below.

1. Allocate 50% of system memory and mlock() it using a test program.
2. Fill up the page cache to exhaust nearly all free memory.
3. Start DAMON-based proactive reclamation with 100 MiB/second DAMOS
   hard-quota.  Auto-tune the DAMOS soft-quota under the hard-quota for
   achieving 40% free memory of the system with 'temporal' tuner.

For step 1, I run a simple C program that is written by Gemini.  It is
quite straightforward, so I'm not sharing the code here.

For step 2, I use dd command like below:

   dd if=/dev/zero of=foo bs=1M count=$50_percent_of_system_memory

For step 3, I use the latest version of DAMON user-space tool (damo)
like below.

    sudo damo start --damos_action pageout \
            ` # Do the pageout only up to 100 MiB per second ` \
            --damos_quota_space 100M --damos_quota_interval 1s \
            ` # Auto-tune the quota below the hard quota aiming` \
            ` # 40% free memory of the node 0 ` \
            ` # (entire node of the test system)` \
            --damos_quota_goal node_mem_free_bp 40% 0 \
            ` # use temporal tuner, which is easy to understnd ` \
            --damos_quota_goal_tuner temporal

As expected, the progress of the reclamation is not consistent, because
the quota is exceeded for the failed reclamation of the unreclaimable
memory.

I do this again, but with the failed region charge ratio feature.  For
this, the above 'damo' command is used, after appending command line
option for setup of the charge ratio like below.  Note that the option
was added to 'damo' after v3.1.9.

    sudo ./damo start --damos_action pageout \
            [...]
            ` # quota-charge only 1/4096 for pageout-failed regions ` \
            --damos_quota_fail_charge_ratio 1 4096

The progress of the reclamation was nearly 100 MiB per second until the
goal was achieved, meeting the expectation.

Patches Sequence
================

Patch 1 implements the feature and exposes it via DAMON core API.
Patch 2 implements DAMON sysfs ABI for the feature.  Three following
patches (3-5) document the feature and ABI on design, usage, and ABI
documents, respectively.  Four patches for testing of the new feature
follow.  Patch 6 implements a kunit test for the feature.  Patches 7
and 8 extend DAMON selftest helpers for DAMON sysfs control and internal
state dumping for adding a new selftest for the feature.  Patch 9
extends existing DAMON sysfs interface selftest to test the new feature
using the extended helper scripts.

SeongJae Park (9):
  mm/damon/core: introduce failed region quota charge ratio
  mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files
  Docs/mm/damon/design: document fail_charge_{num,denom}
  Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom}
    files
  Docs/ABI/damon: document fail_charge_{num,denom}
  mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing
  selftets/damon/_damon_sysfs: support failed region quota charge ratio
  selftests/damon/drgn_dump_damon_status: support failed region quota
    charge ratio
  selftets/damon/sysfs.py: test failed region quota charge ratio

 .../ABI/testing/sysfs-kernel-mm-damon         | 12 +++++
 Documentation/admin-guide/mm/damon/usage.rst  | 18 +++++--
 Documentation/mm/damon/design.rst             | 21 ++++++++
 include/linux/damon.h                         |  9 ++++
 mm/damon/core.c                               |  9 +++-
 mm/damon/sysfs-schemes.c                      | 54 +++++++++++++++++++
 mm/damon/tests/core-kunit.h                   |  6 +++
 tools/testing/selftests/damon/_damon_sysfs.py | 21 +++++++-
 .../selftests/damon/drgn_dump_damon_status.py |  2 +
 tools/testing/selftests/damon/sysfs.py        |  6 +++
 10 files changed, 151 insertions(+), 7 deletions(-)


base-commit: 9e634d6813be2e3d1cb023a0b83619fd2bcdd13b
-- 
2.47.3


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 1/9] mm/damon/core: introduce failed region quota charge ratio
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 20:46   ` (sashiko review) " SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files SeongJae Park
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm

DAMOS quota is charged to all DAMOS action application attempted memory,
regardless of how much of the memory the action was successful and
failed.  This makes understanding quota behavior without DAMOS stat but
only with end level metrics (e.g., increased amount of free memory for
DAMOS_PAGEOUT action) difficult.  Also, charging action-failed memory
same as action-successful memory is somewhat unfair, as successful
action application will induce more overhead in most cases.

Introduce DAMON core API for setting the charge ratio for such
action-failed memory.  It allows API callers to specify the ratio in a
flexible way, by setting the numerator and the denominator.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 include/linux/damon.h | 9 +++++++++
 mm/damon/core.c       | 9 ++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 4b69f4553267d..9ab7331775b9e 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -233,6 +233,8 @@ enum damos_quota_goal_tuner {
  * @goals:		Head of quota tuning goals (&damos_quota_goal) list.
  * @goal_tuner:		Goal-based @esz tuning algorithm to use.
  * @esz:		Effective size quota in bytes.
+ * @fail_charge_num:	Failed regions charge rate numerator.
+ * @fail_charge_denom:	Failed regions charge rate denominator.
  *
  * @weight_sz:		Weight of the region's size for prioritization.
  * @weight_nr_accesses:	Weight of the region's nr_accesses for prioritization.
@@ -262,6 +264,10 @@ enum damos_quota_goal_tuner {
  *
  * The resulting effective size quota in bytes is set to @esz.
  *
+ * For DAMOS action applying failed amount of regions, charging those same to
+ * those that the action has successfully applied may be unfair.  For the
+ * reason, 'the size * @fail_charge_num / @fail_charge_denom' is charged.
+ *
  * For selecting regions within the quota, DAMON prioritizes current scheme's
  * target memory regions using the &struct damon_operations->get_scheme_score.
  * You could customize the prioritization logic by setting &weight_sz,
@@ -276,6 +282,9 @@ struct damos_quota {
 	enum damos_quota_goal_tuner goal_tuner;
 	unsigned long esz;
 
+	unsigned int fail_charge_num;
+	unsigned int fail_charge_denom;
+
 	unsigned int weight_sz;
 	unsigned int weight_nr_accesses;
 	unsigned int weight_age;
diff --git a/mm/damon/core.c b/mm/damon/core.c
index fe5a4a8d5b294..4cbf664c52021 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -918,6 +918,8 @@ static int damos_commit_quota(struct damos_quota *dst, struct damos_quota *src)
 	if (err)
 		return err;
 	dst->goal_tuner = src->goal_tuner;
+	dst->fail_charge_num = src->fail_charge_num;
+	dst->fail_charge_denom = src->fail_charge_denom;
 	dst->weight_sz = src->weight_sz;
 	dst->weight_nr_accesses = src->weight_nr_accesses;
 	dst->weight_age = src->weight_age;
@@ -2098,7 +2100,12 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
 		ktime_get_coarse_ts64(&end);
 		quota->total_charged_ns += timespec64_to_ns(&end) -
 			timespec64_to_ns(&begin);
-		quota->charged_sz += sz;
+		if (quota->fail_charge_denom)
+			quota->charged_sz += sz_applied +
+				(sz - sz_applied) * quota->fail_charge_num /
+				quota->fail_charge_denom;
+		else
+			quota->charged_sz += sz;
 		if (damos_quota_is_set(quota) &&
 				quota->charged_sz >= quota->esz) {
 			quota->charge_target_from = t;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 1/9] mm/damon/core: introduce " SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 20:52   ` (sashiko review) " SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 3/9] Docs/mm/damon/design: document fail_charge_{num,denom} SeongJae Park
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm

Implement the user-space ABI for the DAMOS action failed region
quota-charge ratio setup.  For this, add two new sysfs files under the
DAMON sysfs interface for DAMOS quotas.  Names of the files are
fail_charge_num and fail_charge_denom, and work for reading and setting
the numerator and denominator of the failed regions charge ratio.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/sysfs-schemes.c | 54 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 5186966dafb35..d5bfba79f105f 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -1489,6 +1489,8 @@ struct damon_sysfs_quotas {
 	unsigned long reset_interval_ms;
 	unsigned long effective_sz;	/* Effective size quota in bytes */
 	enum damos_quota_goal_tuner goal_tuner;
+	unsigned int fail_charge_num;
+	unsigned int fail_charge_denom;
 };
 
 static struct damon_sysfs_quotas *damon_sysfs_quotas_alloc(void)
@@ -1663,6 +1665,48 @@ static ssize_t goal_tuner_store(struct kobject *kobj,
 	return -EINVAL;
 }
 
+static ssize_t fail_charge_num_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	struct damon_sysfs_quotas *quotas = container_of(kobj,
+			struct damon_sysfs_quotas, kobj);
+
+	return sysfs_emit(buf, "%u\n", quotas->fail_charge_num);
+}
+
+static ssize_t fail_charge_num_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	struct damon_sysfs_quotas *quotas = container_of(kobj,
+			struct damon_sysfs_quotas, kobj);
+	int err = kstrtouint(buf, 0, &quotas->fail_charge_num);
+
+	if (err)
+		return -EINVAL;
+	return count;
+}
+
+static ssize_t fail_charge_denom_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	struct damon_sysfs_quotas *quotas = container_of(kobj,
+			struct damon_sysfs_quotas, kobj);
+
+	return sysfs_emit(buf, "%u\n", quotas->fail_charge_denom);
+}
+
+static ssize_t fail_charge_denom_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	struct damon_sysfs_quotas *quotas = container_of(kobj,
+			struct damon_sysfs_quotas, kobj);
+	int err = kstrtouint(buf, 0, &quotas->fail_charge_denom);
+
+	if (err)
+		return -EINVAL;
+	return count;
+}
+
 static void damon_sysfs_quotas_release(struct kobject *kobj)
 {
 	kfree(container_of(kobj, struct damon_sysfs_quotas, kobj));
@@ -1683,12 +1727,20 @@ static struct kobj_attribute damon_sysfs_quotas_effective_bytes_attr =
 static struct kobj_attribute damon_sysfs_quotas_goal_tuner_attr =
 		__ATTR_RW_MODE(goal_tuner, 0600);
 
+static struct kobj_attribute damon_sysfs_quotas_fail_charge_num_attr =
+		__ATTR_RW_MODE(fail_charge_num, 0600);
+
+static struct kobj_attribute damon_sysfs_quotas_fail_charge_denom_attr =
+		__ATTR_RW_MODE(fail_charge_denom, 0600);
+
 static struct attribute *damon_sysfs_quotas_attrs[] = {
 	&damon_sysfs_quotas_ms_attr.attr,
 	&damon_sysfs_quotas_sz_attr.attr,
 	&damon_sysfs_quotas_reset_interval_ms_attr.attr,
 	&damon_sysfs_quotas_effective_bytes_attr.attr,
 	&damon_sysfs_quotas_goal_tuner_attr.attr,
+	&damon_sysfs_quotas_fail_charge_num_attr.attr,
+	&damon_sysfs_quotas_fail_charge_denom_attr.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(damon_sysfs_quotas);
@@ -2776,6 +2828,8 @@ static struct damos *damon_sysfs_mk_scheme(
 		.weight_nr_accesses = sysfs_weights->nr_accesses,
 		.weight_age = sysfs_weights->age,
 		.goal_tuner = sysfs_quotas->goal_tuner,
+		.fail_charge_num = sysfs_quotas->fail_charge_num,
+		.fail_charge_denom = sysfs_quotas->fail_charge_denom,
 	};
 	struct damos_watermarks wmarks = {
 		.metric = sysfs_wmarks->metric,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 3/9] Docs/mm/damon/design: document fail_charge_{num,denom}
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 1/9] mm/damon/core: introduce " SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 20:58   ` (sashiko review) " SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 4/9] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files SeongJae Park
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
	Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
	Shuah Khan, Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
	linux-kernel, linux-mm

Update DAMON design document for the DAMOS action failed region quota
charge ratio.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/mm/damon/design.rst | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 510ec6375178d..58a72bd26dc11 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -572,6 +572,27 @@ interface <sysfs_interface>`, refer to :ref:`weights <sysfs_quotas>` part of
 the documentation.
 
 
+.. _damon_design_damos_quotas_failed_memory_charging_ratio:
+
+Action-failed Memory Charging Ratio
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+DAMOS action to a given region can fail for sub subsets of the memory of the
+region.  For example, if the action is ``pageout`` and the region has some
+unreclaimable pages, applying the action to the pages will fail.  The amount of
+system resource that is taken for such failed action applications is usually
+different from that for successful action applications.  For such cases, users
+can set different charging ratio for such failed memory.  The ratio can be
+specified using ``fail_charge_num`` and ``fail_charge_denom`` parameters.  The
+two parameters represent the numerator and denominator of the ratio.
+
+For example, let's suppose a DAMOS action is applied to a region of 1 GiB size.
+The action is successfully applied to only 700 MiB of the region.
+``fail_charge_num`` and ``fail_charge_denom`` are set to ``1`` and ``1024``,
+respectively.  Then only 700 MiB and 300 KiB of size (``700 MiB + 300 MiB * 1 /
+1024``) will be charged.
+
+
 .. _damon_design_damos_quotas_auto_tuning:
 
 Aim-oriented Feedback-driven Auto-tuning
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 4/9] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
                   ` (2 preceding siblings ...)
  2026-04-04 16:39 ` [RFC PATCH 3/9] Docs/mm/damon/design: document fail_charge_{num,denom} SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 21:01   ` (sashiko review) " SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 5/9] Docs/ABI/damon: document fail_charge_{num,denom} SeongJae Park
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Liam R. Howlett, Andrew Morton, David Hildenbrand,
	Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
	Shuah Khan, Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
	linux-kernel, linux-mm

Update DAMON usage document for the DAMOS action failed regions quota
charge ratio control sysfs files.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/admin-guide/mm/damon/usage.rst | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index bfdb717441f05..ffb32bdbe34ff 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -84,7 +84,9 @@ comma (",").
     │ │ │ │ │ │ │ │ sz/min,max
     │ │ │ │ │ │ │ │ nr_accesses/min,max
     │ │ │ │ │ │ │ │ age/min,max
-    │ │ │ │ │ │ │ :ref:`quotas <sysfs_quotas>`/ms,bytes,reset_interval_ms,effective_bytes,goal_tuner
+    │ │ │ │ │ │ │ :ref:`quotas <sysfs_quotas>`/ms,bytes,reset_interval_ms,
+    │ │ │ │ │ │ │     effective_bytes,goal_tuner,
+    │ │ │ │ │ │ │     fail_charge_num,fail_charge_denom
     │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil
     │ │ │ │ │ │ │ │ :ref:`goals <sysfs_schemes_quota_goals>`/nr_goals
     │ │ │ │ │ │ │ │ │ 0/target_metric,target_value,current_value,nid,path
@@ -381,9 +383,10 @@ schemes/<N>/quotas/
 The directory for the :ref:`quotas <damon_design_damos_quotas>` of the given
 DAMON-based operation scheme.
 
-Under ``quotas`` directory, five files (``ms``, ``bytes``,
-``reset_interval_ms``, ``effective_bytes`` and ``goal_tuner``) and two
-directories (``weights`` and ``goals``) exist.
+Under ``quotas`` directory, seven files (``ms``, ``bytes``,
+``reset_interval_ms``, ``effective_bytes``, ``goal_tuner``, ``fail_charge_num``
+and ``fail_charge_denom``) and two directories (``weights`` and ``goals``)
+exist.
 
 You can set the ``time quota`` in milliseconds, ``size quota`` in bytes, and
 ``reset interval`` in milliseconds by writing the values to the three files,
@@ -402,6 +405,13 @@ the background design of the feature and the name of the selectable algorithms.
 Refer to :ref:`goals directory <sysfs_schemes_quota_goals>` for the goals
 setup.
 
+You can set the action-failed memory quota charging ratio by writing the
+numerator and the denominator for the ratio to ``fail_charge_num`` and
+`fail_charge_denom`` files, respectively.  Reading those file will return the
+current set values.  Refer to :ref:`design
+<damon_design_damos_quotas_failed_memory_charging_ratio>` for more details of
+the ratio feature.
+
 The time quota is internally transformed to a size quota.  Between the
 transformed size quota and user-specified size quota, smaller one is applied.
 Based on the user-specified :ref:`goal <sysfs_schemes_quota_goals>`, the
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 5/9] Docs/ABI/damon: document fail_charge_{num,denom}
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
                   ` (3 preceding siblings ...)
  2026-04-04 16:39 ` [RFC PATCH 4/9] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 6/9] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing SeongJae Park
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, damon, linux-kernel, linux-mm

Update DAMON ABI document for the DAMOS action failed regions quota
charge ratio control sysfs files.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/ABI/testing/sysfs-kernel-mm-damon | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon
index 7059f540940f0..971c22e34e722 100644
--- a/Documentation/ABI/testing/sysfs-kernel-mm-damon
+++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon
@@ -329,6 +329,18 @@ Contact:	SeongJae Park <sj@kernel.org>
 Description:	Writing to and reading from this file sets and gets the
 		goal-based effective quota auto-tuning algorithm to use.
 
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/fail_charge_num
+Date:		Mar 2026
+Contact:	SeongJae Park <sj@kernel.org>
+Description:	Writing to and reading from this file sets and gets the
+		action-failed memory quota charging ratio numerator.
+
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/fail_charge_denom
+Date:		Mar 2026
+Contact:	SeongJae Park <sj@kernel.org>
+Description:	Writing to and reading from this file sets and gets the
+		action-failed memory quota charging ratio denominator.
+
 What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/schemes/<S>/quotas/weights/sz_permil
 Date:		Mar 2022
 Contact:	SeongJae Park <sj@kernel.org>
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 6/9] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
                   ` (4 preceding siblings ...)
  2026-04-04 16:39 ` [RFC PATCH 5/9] Docs/ABI/damon: document fail_charge_{num,denom} SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 21:03   ` (sashiko review) " SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 7/9] selftets/damon/_damon_sysfs: support failed region quota charge ratio SeongJae Park
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, Brendan Higgins, David Gow, damon,
	kunit-dev, linux-kernel, linux-kselftest, linux-mm

Extend damos_test_commit_quotas() kunit test to ensure
damos_commit_quota() handles fail_charge_{num,denom} parameters.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/tests/core-kunit.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 0030f682b23b7..16f68315ba119 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -694,6 +694,8 @@ static void damos_test_commit_quota(struct kunit *test)
 		.ms = 2,
 		.sz = 3,
 		.goal_tuner = DAMOS_QUOTA_GOAL_TUNER_CONSIST,
+		.fail_charge_num = 2,
+		.fail_charge_denom = 3,
 		.weight_sz = 4,
 		.weight_nr_accesses = 5,
 		.weight_age = 6,
@@ -703,6 +705,8 @@ static void damos_test_commit_quota(struct kunit *test)
 		.ms = 8,
 		.sz = 9,
 		.goal_tuner = DAMOS_QUOTA_GOAL_TUNER_TEMPORAL,
+		.fail_charge_num = 1,
+		.fail_charge_denom = 1024,
 		.weight_sz = 10,
 		.weight_nr_accesses = 11,
 		.weight_age = 12,
@@ -717,6 +721,8 @@ static void damos_test_commit_quota(struct kunit *test)
 	KUNIT_EXPECT_EQ(test, dst.ms, src.ms);
 	KUNIT_EXPECT_EQ(test, dst.sz, src.sz);
 	KUNIT_EXPECT_EQ(test, dst.goal_tuner, src.goal_tuner);
+	KUNIT_EXPECT_EQ(test, dst.fail_charge_num, 1);
+	KUNIT_EXPECT_EQ(test, dst.fail_charge_denom, 1024);
 	KUNIT_EXPECT_EQ(test, dst.weight_sz, src.weight_sz);
 	KUNIT_EXPECT_EQ(test, dst.weight_nr_accesses, src.weight_nr_accesses);
 	KUNIT_EXPECT_EQ(test, dst.weight_age, src.weight_age);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 7/9] selftets/damon/_damon_sysfs: support failed region quota charge ratio
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
                   ` (5 preceding siblings ...)
  2026-04-04 16:39 ` [RFC PATCH 6/9] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 8/9] selftests/damon/drgn_dump_damon_status: " SeongJae Park
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

Extend _damon_sysfs.py for DAMOS action failed regions quota charge
ratio setup, so that we can add kselftest for the new feature.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/_damon_sysfs.py | 21 +++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index 120b96ecbd741..8b12cc0484405 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -132,14 +132,17 @@ class DamosQuota:
     goals = None                # quota goals
     goal_tuner = None           # quota goal tuner
     reset_interval_ms = None    # quota reset interval
+    fail_charge_num = None
+    fail_charge_denom = None
     weight_sz_permil = None
     weight_nr_accesses_permil = None
     weight_age_permil = None
     scheme = None               # owner scheme
 
     def __init__(self, sz=0, ms=0, goals=None, goal_tuner='consist',
-                 reset_interval_ms=0, weight_sz_permil=0,
-                 weight_nr_accesses_permil=0, weight_age_permil=0):
+                 reset_interval_ms=0, fail_charge_num=0, fail_charge_denom=0,
+                 weight_sz_permil=0, weight_nr_accesses_permil=0,
+                 weight_age_permil=0):
         self.sz = sz
         self.ms = ms
         self.reset_interval_ms = reset_interval_ms
@@ -151,6 +154,8 @@ class DamosQuota:
         for idx, goal in enumerate(self.goals):
             goal.idx = idx
             goal.quota = self
+        self.fail_charge_num = fail_charge_num
+        self.fail_charge_denom = fail_charge_denom
 
     def sysfs_dir(self):
         return os.path.join(self.scheme.sysfs_dir(), 'quotas')
@@ -197,6 +202,18 @@ class DamosQuota:
                 os.path.join(self.sysfs_dir(), 'goal_tuner'), self.goal_tuner)
         if err is not None:
             return err
+
+        err = write_file(
+                os.path.join(self.sysfs_dir(), 'fail_charge_num'),
+                self.fail_charge_num)
+        if err is not None:
+            return err
+        err = write_file(
+                os.path.join(self.sysfs_dir(), 'fail_charge_denom'),
+                self.fail_charge_denom)
+        if err is not None:
+            return err
+
         return None
 
 class DamosWatermarks:
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 8/9] selftests/damon/drgn_dump_damon_status: support failed region quota charge ratio
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
                   ` (6 preceding siblings ...)
  2026-04-04 16:39 ` [RFC PATCH 7/9] selftets/damon/_damon_sysfs: support failed region quota charge ratio SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 16:39 ` [RFC PATCH 9/9] selftets/damon/sysfs.py: test " SeongJae Park
  2026-04-04 21:06 ` (sashiko status) [RFC PATCH 0/9] mm/damon: introduce DAMOS " SeongJae Park
  9 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

Extend drgn_dump_damon_status.py to dump DAMON internal state for DAMOS
action failed regions quota charge ratio, to be able to show if the
internal state for the feature is working, with future DAMON selftests.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/drgn_dump_damon_status.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/damon/drgn_dump_damon_status.py b/tools/testing/selftests/damon/drgn_dump_damon_status.py
index 5b90eb8e7ef88..972948e6215f1 100755
--- a/tools/testing/selftests/damon/drgn_dump_damon_status.py
+++ b/tools/testing/selftests/damon/drgn_dump_damon_status.py
@@ -112,6 +112,8 @@ def damos_quota_to_dict(quota):
         ['goals', damos_quota_goals_to_list],
         ['goal_tuner', int],
         ['esz', int],
+        ['fail_charge_num', int],
+        ['fail_charge_denom', int],
         ['weight_sz', int],
         ['weight_nr_accesses', int],
         ['weight_age', int],
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 9/9] selftets/damon/sysfs.py: test failed region quota charge ratio
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
                   ` (7 preceding siblings ...)
  2026-04-04 16:39 ` [RFC PATCH 8/9] selftests/damon/drgn_dump_damon_status: " SeongJae Park
@ 2026-04-04 16:39 ` SeongJae Park
  2026-04-04 21:06 ` (sashiko status) [RFC PATCH 0/9] mm/damon: introduce DAMOS " SeongJae Park
  9 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 16:39 UTC (permalink / raw)
  Cc: SeongJae Park, Shuah Khan, damon, linux-kernel, linux-kselftest,
	linux-mm

Extend sysfs.py DAMON selftest to setup DAMOS action failed region quota
charge ratio and assert the setup is made into DAMON internal state.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/sysfs.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index b8d6e0f8fd906..d8d4717128898 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -73,6 +73,10 @@ def assert_quota_committed(quota, dump):
             }
     assert_true(dump['goal_tuner'] == tuner_val[quota.goal_tuner],
                 'goal_tuner', dump)
+    assert_true(dump['fail_charge_num'] == quota.fail_charge_num,
+                'fail_charge_num', dump)
+    assert_true(dump['fail_charge_denom'] == quota.fail_charge_denom,
+                'fail_charge_denom', dump)
     assert_true(dump['weight_sz'] == quota.weight_sz_permil, 'weight_sz', dump)
     assert_true(dump['weight_nr_accesses'] == quota.weight_nr_accesses_permil,
                 'weight_nr_accesses', dump)
@@ -277,6 +281,8 @@ def main():
                         nid=1)],
                     goal_tuner='temporal',
                     reset_interval_ms=1500,
+                    fail_charge_num=1,
+                    fail_charge_denom=4096,
                     weight_sz_permil=20,
                     weight_nr_accesses_permil=200,
                     weight_age_permil=1000),
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: (sashiko review) [RFC PATCH 1/9] mm/damon/core: introduce failed region quota charge ratio
  2026-04-04 16:39 ` [RFC PATCH 1/9] mm/damon/core: introduce " SeongJae Park
@ 2026-04-04 20:46   ` SeongJae Park
  0 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 20:46 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, damon, linux-kernel, linux-mm

sashiko found an issue that better to be fixed.  I will fix it in the next
revision.

Forwarding sashiko review in a reply format with my inline
comments below, for details of my view and doing discussions
via mails if needed.

> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-2-sj@kernel.org
> # start of sashiko.dev inline review
> commit a0c4b65226ecf5534b53ebac64430db94a861d2c
> Author: SeongJae Park <sj@kernel.org>
> 
> mm/damon/core: introduce failed region quota charge ratio
> 
> This commit introduces a mechanism to specify how much of a DAMOS action's
> failed memory should be charged to the quota. It adds numerator and
> denominator parameters to allow flexible charge ratio configuration.
> 
> > diff --git a/include/linux/damon.h b/include/linux/damon.h
> > index f2cdb7c3f5e6c..df7b0340965f9 100644
> > --- a/include/linux/damon.h
> > +++ b/include/linux/damon.h
> [ ... ]
> > @@ -276,6 +282,9 @@ struct damos_quota {
> >  	enum damos_quota_goal_tuner goal_tuner;
> >  	unsigned long esz;
> >  
> > +	unsigned int fail_charge_num;
> > +	unsigned int fail_charge_denom;
> 
> Is there a guarantee that fail_charge_num is less than or equal to
> fail_charge_denom?
> 
> If fail_charge_num is larger, the added charge will be greater than sz.
> When a region is split to exactly fit the remaining quota, could this make
> quota->charged_sz strictly greater than quota->esz?
> 
> If so, would the remaining quota calculation in the next iteration underflow
> and lead to corrupting the damon_region boundaries when splitting?

No.  Existing charged_sz vs esz comparison code allows charged_sz be larger
than esz, using '>=' operator.  And when the next charge window starts,
quota->charged_sz is reset to zero.  So I show no problem here.

> 
> > +
> >  	unsigned int weight_sz;
> >  	unsigned int weight_nr_accesses;
> >  	unsigned int weight_age;
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 3bc7a2bbfe7de..f468c0257a3ec 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> [ ... ]
> > @@ -2097,7 +2099,12 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
> >  		ktime_get_coarse_ts64(&end);
> >  		quota->total_charged_ns += timespec64_to_ns(&end) -
> >  			timespec64_to_ns(&begin);
> > -		quota->charged_sz += sz;
> > +		if (quota->fail_charge_denom)
> > +			quota->charged_sz += sz_applied +
> > +				(sz - sz_applied) * quota->fail_charge_num /
> > +				quota->fail_charge_denom;
> 
> If memory management operations backing apply_scheme (like damon_pa_pageout)
> process whole folios, can sz_applied be strictly greater than the region's
> size sz (for example, when a 4KB region overlaps with a 2MB THP)?
> 
> Does this cause the unsigned subtraction (sz - sz_applied) to underflow
> into a very large positive value, exhausting the quota prematurely?

Good point.  The premature quota exhaustion should not be a critical issue, but
better to be avoided.  I will fix this in the next revision.

> 
> Could the multiplication (sz - sz_applied) * quota->fail_charge_num overflow
> before division?
> 
> On 32-bit architectures, or with a large fail_charge_num, could this wrap
> around and result in a much smaller charge than expected, allowing the scheme
> to bypass the quota limits?

I will use mult_frac() to avoid unnecessary overflow.

> 
> What happens if an action fails, and fail_charge_num is set to 0?
> 
> Does quota->charged_sz remain unchanged while the region is split to fit the
> remaining quota?
> 
> Since the remaining quota stays the same, could this cause the subsequent loop
> iterations to continuously split the remainder of the region into identical
> small chunks, allocating a massive number of damon_region structures?

That could happen, if that's what the user intend to.  That's no problem.

> 
> > +		else
> > +			quota->charged_sz += sz;
> >  		if (damos_quota_is_set(quota) &&
> >  				quota->charged_sz >= quota->esz) {
> >  			quota->charge_target_from = t;
> 
> 
> # end of sashiko.dev inline review
> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-2-sj@kernel.org

Thanks,
SJ

# hkml [1] generated a draft of this mail.  You can regenerate
# this using below command:
#
#     hkml patch sashiko_dev --for_forwarding \
#             20260404163943.89278-2-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: (sashiko review) [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files
  2026-04-04 16:39 ` [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files SeongJae Park
@ 2026-04-04 20:52   ` SeongJae Park
  0 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 20:52 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, damon, linux-kernel, linux-mm

sashiko found no real issue for this patch.

Forwarding sashiko review in a reply format with my inline
comments below, for details of my view and doing discussions
via mails if needed.

> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-3-sj@kernel.org
> # start of sashiko.dev inline review
> commit ee565644ac37e8bfceab5e62746d85906fb91b43
> Author: SeongJae Park <sj@kernel.org>
> 
> mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files
> 
> This commit implements the user-space ABI for the DAMOS action failed region
> quota-charge ratio setup. It adds two new sysfs files under the DAMON sysfs
> interface for DAMOS quotas, fail_charge_num and fail_charge_denom, which
> allow reading and setting the numerator and denominator of the failed regions
> charge ratio.
> 
> > diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> > index 5186966dafb35..d5bfba79f105f 100644
> > --- a/mm/damon/sysfs-schemes.c
> > +++ b/mm/damon/sysfs-schemes.c
> 
> [ ... ]
> 
> > @@ -1663,6 +1665,48 @@ static ssize_t goal_tuner_store(struct kobject *kobj,
> >  	return -EINVAL;
> >  }
> >  
> > +static ssize_t fail_charge_num_show(struct kobject *kobj,
> > +		struct kobj_attribute *attr, char *buf)
> > +{
> > +	struct damon_sysfs_quotas *quotas = container_of(kobj,
> > +			struct damon_sysfs_quotas, kobj);
> > +
> > +	return sysfs_emit(buf, "%u\n", quotas->fail_charge_num);
> > +}
> > +
> > +static ssize_t fail_charge_num_store(struct kobject *kobj,
> > +		struct kobj_attribute *attr, const char *buf, size_t count)
> > +{
> > +	struct damon_sysfs_quotas *quotas = container_of(kobj,
> > +			struct damon_sysfs_quotas, kobj);
> > +	int err = kstrtouint(buf, 0, &quotas->fail_charge_num);
> > +
> > +	if (err)
> > +		return -EINVAL;
> 
> Could this lack of upper bounds checking lead to an integer overflow when
> the scheme is applied in the DAMON core?
> 
> If a user provides a large value for fail_charge_num up to UINT_MAX, could the
> charge calculation in damos_apply_scheme():
> 
> (sz - sz_applied) * quota->fail_charge_num / quota->fail_charge_denom
> 
> overflow the unsigned long value?
> 
> For example, on a 32-bit system, an unapplied region of just 5 MB multiplied
> by a user-supplied numerator of 1,000 yields over 5 billion, which exceeds
> the 32-bit maximum limit. On a 64-bit system, a 10 GB region multiplied by
> 4,000,000,000 would similarly overflow.
> 
> When this overflow occurs, does the charged size wrap around to a very small
> value, causing the DAMOS action quota to be drastically undercharged and
> bypassing the user-defined limits?

That can happen, but shouldn't cause a real problem.  Meanwhile, adding such
overflow check would make code unnecessarily complicated.  I will keep this as
is.  If it turns out this causes a real problem, we can consider making this
better documented or updating the code later, after the report is really made.


Thanks,
SJ

> 
> > +	return count;
> > +}
> 
> [ ... ]
> 
> 
> # end of sashiko.dev inline review
> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-3-sj@kernel.org

# hkml [1] generated a draft of this mail.  You can regenerate
# this using below command:
#
#     hkml patch sashiko_dev --for_forwarding \
#             20260404163943.89278-3-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: (sashiko review) [RFC PATCH 3/9] Docs/mm/damon/design: document fail_charge_{num,denom}
  2026-04-04 16:39 ` [RFC PATCH 3/9] Docs/mm/damon/design: document fail_charge_{num,denom} SeongJae Park
@ 2026-04-04 20:58   ` SeongJae Park
  0 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 20:58 UTC (permalink / raw)
  To: SeongJae Park; +Cc: damon, linux-doc, linux-kernel, linux-mm

Dropped individual Cc's except myself to reduce unnecessary traffic.  I
initailly thought it would be good to keep Andrew in the Cc list, but even
Andrew may not really interested in each sashiko review for RFC patch, so I
dropped him from the list, too.

sashiko found issues.  I will fix those in the next revision.

Forwarding sashiko review in a reply format with my inline
comments below, for details of my view and doing discussions
via mails if needed.

> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-4-sj@kernel.org
> # start of sashiko.dev inline review
> commit bab641e86f0e9820b2ac0a7d4ae493d23c4c50f4
> Author: SeongJae Park <sj@kernel.org>
> Docs/mm/damon/design: document fail_charge_{num,denom}
> 
> This commit updates the DAMON design document to explain the action-failed
> memory charging ratio. It provides an example of how to calculate the
> charged memory when an action fails for a portion of a region.
> 
> > diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
> > index afc7d52bda2f7..01047e8431d17 100644
> > --- a/Documentation/mm/damon/design.rst
> > +++ b/Documentation/mm/damon/design.rst
> > @@ -565,6 +565,27 @@ interface <sysfs_interface>`, refer to :ref:`weights <sysfs_quotas>` part of
> >  the documentation.
> >  
> >  
> > +.. _damon_design_damos_quotas_failed_memory_charging_ratio:
> > +
> > +Action-failed Memory Charging Ratio
> > +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +DAMOS action to a given region can fail for sub subsets of the memory of the
> 
> This isn't a bug, but should "sub subsets" just be "some subsets" or
> "subsets"?

Good eye.  I will fix this in the next revision.

> 
> > +region.  For example, if the action is ``pageout`` and the region has some
> > +unreclaimable pages, applying the action to the pages will fail.  The amount of
> > +system resource that is taken for such failed action applications is usually
> > +different from that for successful action applications.  For such cases, users
> > +can set different charging ratio for such failed memory.  The ratio can be
> > +specified using ``fail_charge_num`` and ``fail_charge_denom`` parameters.  The
> > +two parameters represent the numerator and denominator of the ratio.
> > +
> > +For example, let's suppose a DAMOS action is applied to a region of 1 GiB size.
> > +The action is successfully applied to only 700 MiB of the region.
> > +``fail_charge_num`` and ``fail_charge_denom`` are set to ``1`` and ``1024``,
> > +respectively.  Then only 700 MiB and 300 KiB of size (``700 MiB + 300 MiB * 1 /
> > +1024``) will be charged.
> 
> Is this calculation accurate? Since 1 GiB is 1024 MiB, if 700 MiB are
> successfully applied, the remaining failed region would be 324 MiB rather
> than 300 MiB. Does the example intentionally use 1 GiB = 1000 MiB, or should
> the remaining portion be updated to 324 MiB?

Nice finding.  I will fix this in the next revision.


Thanks,
SJ

> 
> 
> # end of sashiko.dev inline review
> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-4-sj@kernel.org

# hkml [1] generated a draft of this mail.  You can regenerate
# this using below command:
#
#     hkml patch sashiko_dev --for_forwarding \
#             20260404163943.89278-4-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: (sashiko review) [RFC PATCH 4/9] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files
  2026-04-04 16:39 ` [RFC PATCH 4/9] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files SeongJae Park
@ 2026-04-04 21:01   ` SeongJae Park
  0 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 21:01 UTC (permalink / raw)
  To: SeongJae Park; +Cc: damon, linux-doc, linux-kernel, linux-mm

Dropped individual recipients from Cc list, to reduce unnecessary traffic.

TL; DR: sashiko found real issues.  I will fix those in the next revision.

Forwarding sashiko review in a reply format with my inline
comments below, for details of my view and doing discussions
via mails if needed.

> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-5-sj@kernel.org
> # start of sashiko.dev inline review
> commit 5f8a4cfde3d93d0a4d4ac3d9a57f14f310c43e02
> Author: SeongJae Park <sj@kernel.org>
> 
> Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files
> 
> Update DAMON usage document for the DAMOS action failed regions quota charge
> ratio control sysfs files.
> 
> > diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
> > index 534e1199cf091..3d6af6ce72d82 100644
> > --- a/Documentation/admin-guide/mm/damon/usage.rst
> > +++ b/Documentation/admin-guide/mm/damon/usage.rst
> [ ... ]
> > @@ -398,6 +401,13 @@ the background design of the feature and the name of the selectable algorithms.
> >  Refer to :ref:`goals directory <sysfs_schemes_quota_goals>` for the goals
> >  setup.
> >  
> > +You can set the action-failed memory quota charging ratio by writing the
> > +numerator and the denominator for the ratio to ``fail_charge_num`` and
> > +`fail_charge_denom`` files, respectively.  Reading those file will return the
> 
> This isn't a bug, but fail_charge_denom has a single leading backtick and
> double trailing backticks.
> 
> Additionally, should "Reading those file" be "Reading those files"?

Good catch!  I will fix those in the next spin.


Thanks,
SJ

> 
> > +current set values.  Refer to :ref:`design
> > +<damon_design_damos_quotas_failed_memory_charging_ratio>` for more details of
> > +the ratio feature.
> > +
> >  The time quota is internally transformed to a size quota.  Between the
> 
> 
> # end of sashiko.dev inline review
> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-5-sj@kernel.org

# hkml [1] generated a draft of this mail.  You can regenerate
# this using below command:
#
#     hkml patch sashiko_dev --for_forwarding \
#             20260404163943.89278-5-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: (sashiko review) [RFC PATCH 6/9] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing
  2026-04-04 16:39 ` [RFC PATCH 6/9] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing SeongJae Park
@ 2026-04-04 21:03   ` SeongJae Park
  0 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 21:03 UTC (permalink / raw)
  To: SeongJae Park; +Cc: damon, kunit-dev, linux-kernel, linux-kselftest, linux-mm

Dropped individuals from Cc list to reduce the traffic.

TL; DR: sashiko made a good suggestion to improve this patch.  I will do so in
the next revision.

Forwarding sashiko review in a reply format with my inline
comments below, for details of my view and doing discussions
via mails if needed.

> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-7-sj@kernel.org
> # start of sashiko.dev inline review
> commit 2c875b613d1b0d252222336af28714d95bf57930
> Author: SeongJae Park <sj@kernel.org>
> 
> mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing
> 
> This commit extends the damos_test_commit_quotas() kunit test to verify
> that damos_commit_quota() correctly copies the fail_charge_num and
> fail_charge_denom parameters.
> 
> > diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> > index 9e5904c2beeb2..1eb70f721d1e1 100644
> > --- a/mm/damon/tests/core-kunit.h
> > +++ b/mm/damon/tests/core-kunit.h
> [ ... ]
> > @@ -717,6 +721,8 @@ static void damos_test_commit_quota(struct kunit *test)
> >  	KUNIT_EXPECT_EQ(test, dst.ms, src.ms);
> >  	KUNIT_EXPECT_EQ(test, dst.sz, src.sz);
> >  	KUNIT_EXPECT_EQ(test, dst.goal_tuner, src.goal_tuner);
> > +	KUNIT_EXPECT_EQ(test, dst.fail_charge_num, 1);
> > +	KUNIT_EXPECT_EQ(test, dst.fail_charge_denom, 1024);
> 
> This isn't a bug, but should these assertions use src.fail_charge_num and
> src.fail_charge_denom instead of the hardcoded 1 and 1024?
> 
> Using the src fields would keep this consistent with the surrounding
> assertions. It would also prevent the test from becoming brittle if the
> src structure's initialization values are changed in the future.

Makes sense, I will do so in the next revision.


Thanks,
SJ

> 
> >  	KUNIT_EXPECT_EQ(test, dst.weight_sz, src.weight_sz);
> >  	KUNIT_EXPECT_EQ(test, dst.weight_nr_accesses, src.weight_nr_accesses);
> >  	KUNIT_EXPECT_EQ(test, dst.weight_age, src.weight_age);
> 
> 
> # end of sashiko.dev inline review
> # review url: https://sashiko.dev/#/patchset/20260404163943.89278-7-sj@kernel.org

# hkml [1] generated a draft of this mail.  You can regenerate
# this using below command:
#
#     hkml patch sashiko_dev --for_forwarding \
#             20260404163943.89278-7-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: (sashiko status) [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio
  2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
                   ` (8 preceding siblings ...)
  2026-04-04 16:39 ` [RFC PATCH 9/9] selftets/damon/sysfs.py: test " SeongJae Park
@ 2026-04-04 21:06 ` SeongJae Park
  9 siblings, 0 replies; 16+ messages in thread
From: SeongJae Park @ 2026-04-04 21:06 UTC (permalink / raw)
  To: SeongJae Park
  Cc: damon, kunit-dev, linux-doc, linux-kernel, linux-kselftest,
	linux-mm

Dropped individuals from Cc list to reduce the traffic.

TL; DR: sashiko made a few useful findings.  I will address those in the next
revision.

Forwarding sashiko.dev review status for the overall picture.  Read my replies
to 'ISSUES MAY FOUND' patches for more details.

# review url: https://sashiko.dev/#/patchset/20260404163943.89278-1-sj@kernel.org

- [RFC PATCH 1/9] mm/damon/core: introduce failed region quota charge ratio
  - status: Reviewed
  - review: ISSUES MAY FOUND
- [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files
  - status: Reviewed
  - review: ISSUES MAY FOUND
- [RFC PATCH 3/9] Docs/mm/damon/design: document fail_charge_{num,denom}
  - status: Reviewed
  - review: ISSUES MAY FOUND
- [RFC PATCH 4/9] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files
  - status: Reviewed
  - review: ISSUES MAY FOUND
- [RFC PATCH 5/9] Docs/ABI/damon: document fail_charge_{num,denom}
  - status: Reviewed
  - review: No issues found.
- [RFC PATCH 6/9] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing
  - status: Reviewed
  - review: ISSUES MAY FOUND
- [RFC PATCH 7/9] selftets/damon/_damon_sysfs: support failed region quota charge ratio
  - status: Reviewed
  - review: No issues found.
- [RFC PATCH 8/9] selftests/damon/drgn_dump_damon_status: support failed region quota charge ratio
  - status: Reviewed
  - review: No issues found.
- [RFC PATCH 9/9] selftets/damon/sysfs.py: test failed region quota charge ratio
  - status: Reviewed
  - review: No issues found.

# hkml [1] generated a draft of this mail.  It can be regenerated
# using below command:
#
#     hkml patch sashiko_dev --thread_status --for_forwarding \
#             20260404163943.89278-1-sj@kernel.org
#
# [1] https://github.com/sjp38/hackermail


Thanks,
SJ


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-04-04 21:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-04 16:39 [RFC PATCH 0/9] mm/damon: introduce DAMOS failed region quota charge ratio SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 1/9] mm/damon/core: introduce " SeongJae Park
2026-04-04 20:46   ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 2/9] mm/damon/sysfs-schemes: implement fail_charge_{num,denom} files SeongJae Park
2026-04-04 20:52   ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 3/9] Docs/mm/damon/design: document fail_charge_{num,denom} SeongJae Park
2026-04-04 20:58   ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 4/9] Docs/admin-guide/mm/damon/usage: document fail_charge_{num,denom} files SeongJae Park
2026-04-04 21:01   ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 5/9] Docs/ABI/damon: document fail_charge_{num,denom} SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 6/9] mm/damon/tests/core-kunit: test fail_charge_{num,denom} committing SeongJae Park
2026-04-04 21:03   ` (sashiko review) " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 7/9] selftets/damon/_damon_sysfs: support failed region quota charge ratio SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 8/9] selftests/damon/drgn_dump_damon_status: " SeongJae Park
2026-04-04 16:39 ` [RFC PATCH 9/9] selftets/damon/sysfs.py: test " SeongJae Park
2026-04-04 21:06 ` (sashiko status) [RFC PATCH 0/9] mm/damon: introduce DAMOS " SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox