Linux Documentation
 help / color / mirror / Atom feed
* [PATCH 1/6] mm/damon: fix missing parens in macro arguments
@ 2026-05-18 19:09 Maksym Shcherba
  2026-05-18 19:09 ` [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command Maksym Shcherba
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Maksym Shcherba @ 2026-05-18 19:09 UTC (permalink / raw)
  To: sj, akpm
  Cc: david, ljs, liam, vbabka, rppt, surenb, mhocko, corbet, skhan,
	damon, linux-mm, linux-kernel, linux-doc, linux-kselftest,
	Maksym Shcherba

The DAMON iterator macros do not wrap their pointer arguments with
parentheses. This can cause build failures when the argument is a
complex expression due to operator precedence issues.

Add missing parentheses around the arguments in the following macros
to prevent potential build failures:
- damon_for_each_region()
- damon_for_each_region_from()
- damon_for_each_region_safe()
- damos_for_each_quota_goal()

Assisted-by: Antigravity:Gemini-3.1-Pro
Signed-off-by: Maksym Shcherba <maksym.shcherba@lnu.edu.ua>
---
 include/linux/damon.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 4d4f031bcb45..32f2318ac77f 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -902,13 +902,13 @@ static inline unsigned long damon_sz_region(struct damon_region *r)
 
 
 #define damon_for_each_region(r, t) \
-	list_for_each_entry(r, &t->regions_list, list)
+	list_for_each_entry(r, &(t)->regions_list, list)
 
 #define damon_for_each_region_from(r, t) \
-	list_for_each_entry_from(r, &t->regions_list, list)
+	list_for_each_entry_from(r, &(t)->regions_list, list)
 
 #define damon_for_each_region_safe(r, next, t) \
-	list_for_each_entry_safe(r, next, &t->regions_list, list)
+	list_for_each_entry_safe(r, next, &(t)->regions_list, list)
 
 #define damon_for_each_target(t, ctx) \
 	list_for_each_entry(t, &(ctx)->adaptive_targets, list)
@@ -923,7 +923,7 @@ static inline unsigned long damon_sz_region(struct damon_region *r)
 	list_for_each_entry_safe(s, next, &(ctx)->schemes, list)
 
 #define damos_for_each_quota_goal(goal, quota) \
-	list_for_each_entry(goal, &quota->goals, list)
+	list_for_each_entry(goal, &(quota)->goals, list)
 
 #define damos_for_each_quota_goal_safe(goal, next, quota) \
 	list_for_each_entry_safe(goal, next, &(quota)->goals, list)
-- 
2.43.0


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

* [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command
  2026-05-18 19:09 [PATCH 1/6] mm/damon: fix missing parens in macro arguments Maksym Shcherba
@ 2026-05-18 19:09 ` Maksym Shcherba
  2026-05-19  0:17   ` SeongJae Park
  2026-05-18 19:09 ` [PATCH 3/6] Docs/ABI/damon: document " Maksym Shcherba
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Maksym Shcherba @ 2026-05-18 19:09 UTC (permalink / raw)
  To: sj, akpm
  Cc: david, ljs, liam, vbabka, rppt, surenb, mhocko, corbet, skhan,
	damon, linux-mm, linux-kernel, linux-doc, linux-kselftest,
	Maksym Shcherba

Add the logic to copy the current_value from the internal
damos_quota_goal structure to the damos_sysfs_quota_goal sysfs structure.
Introduce the DAMON_SYSFS_CMD_UPDATE_SCHEMES_QUOTA_GOALS command
and integrate it with the sysfs interface via the 'state' file.

Assisted-by: Antigravity:Gemini-3.1-Pro
Signed-off-by: Maksym Shcherba <maksym.shcherba@lnu.edu.ua>
---
 mm/damon/sysfs-common.h  |  4 ++++
 mm/damon/sysfs-schemes.c | 29 +++++++++++++++++++++++++++++
 mm/damon/sysfs.c         | 21 +++++++++++++++++++++
 3 files changed, 54 insertions(+)

diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h
index 2099adee11d0..9703414fa15f 100644
--- a/mm/damon/sysfs-common.h
+++ b/mm/damon/sysfs-common.h
@@ -59,3 +59,7 @@ int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes,
 void damos_sysfs_update_effective_quotas(
 		struct damon_sysfs_schemes *sysfs_schemes,
 		struct damon_ctx *ctx);
+
+void damos_sysfs_update_quota_goals(
+		struct damon_sysfs_schemes *sysfs_schemes,
+		struct damon_ctx *ctx);
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 5d966ac86419..5793659403ca 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2812,6 +2812,35 @@ void damos_sysfs_update_effective_quotas(
 	}
 }
 
+void damos_sysfs_update_quota_goals(
+		struct damon_sysfs_schemes *sysfs_schemes,
+		struct damon_ctx *ctx)
+{
+	struct damos *scheme;
+	int schemes_idx = 0;
+
+	damon_for_each_scheme(scheme, ctx) {
+		struct damos_sysfs_quota_goals *sysfs_goals;
+		struct damos_quota_goal *goal;
+		int goals_idx = 0;
+
+		/* user could have removed the scheme sysfs dir */
+		if (schemes_idx >= sysfs_schemes->nr)
+			break;
+
+		sysfs_goals =
+			sysfs_schemes->schemes_arr[schemes_idx++]->quotas->goals;
+
+		damos_for_each_quota_goal(goal, &scheme->quota) {
+			if (goals_idx >= sysfs_goals->nr)
+				break;
+
+			sysfs_goals->goals_arr[goals_idx++]->current_value =
+				goal->current_value;
+		}
+	}
+}
+
 static int damos_sysfs_add_migrate_dest(struct damos *scheme,
 		struct damos_sysfs_dests *sysfs_dests)
 {
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index d5863cc33d23..ecc880b52b32 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1320,6 +1320,11 @@ enum damon_sysfs_cmd {
 	 * effective size quota of the scheme in bytes.
 	 */
 	DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS,
+	/*
+	 * @DAMON_SYSFS_CMD_UPDATE_SCHEMES_QUOTA_GOALS: Update the
+	 * current value of the scheme quota goals.
+	 */
+	DAMON_SYSFS_CMD_UPDATE_SCHEMES_QUOTA_GOALS,
 	/*
 	 * @DAMON_SYSFS_CMD_UPDATE_TUNED_INTERVALS: Update the tuned monitoring
 	 * intervals.
@@ -1342,6 +1347,7 @@ static const char * const damon_sysfs_cmd_strs[] = {
 	"update_schemes_tried_regions",
 	"clear_schemes_tried_regions",
 	"update_schemes_effective_quotas",
+	"update_schemes_quota_goals",
 	"update_tuned_intervals",
 };
 
@@ -1606,6 +1612,16 @@ static int damon_sysfs_upd_schemes_effective_quotas(void *data)
 	return 0;
 }
 
+static int damon_sysfs_upd_schemes_quota_goals(void *data)
+{
+	struct damon_sysfs_kdamond *kdamond = data;
+	struct damon_ctx *ctx = kdamond->damon_ctx;
+
+	damos_sysfs_update_quota_goals(
+			kdamond->contexts->contexts_arr[0]->schemes, ctx);
+	return 0;
+}
+
 static int damon_sysfs_upd_tuned_intervals(void *data)
 {
 	struct damon_sysfs_kdamond *kdamond = data;
@@ -1656,6 +1672,7 @@ static int damon_sysfs_repeat_call_fn(void *data)
 	damon_sysfs_upd_tuned_intervals(sysfs_kdamond);
 	damon_sysfs_upd_schemes_stats(sysfs_kdamond);
 	damon_sysfs_upd_schemes_effective_quotas(sysfs_kdamond);
+	damon_sysfs_upd_schemes_quota_goals(sysfs_kdamond);
 out:
 	mutex_unlock(&damon_sysfs_lock);
 	return 0;
@@ -1813,6 +1830,10 @@ static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,
 		return damon_sysfs_damon_call(
 				damon_sysfs_upd_schemes_effective_quotas,
 				kdamond);
+	case DAMON_SYSFS_CMD_UPDATE_SCHEMES_QUOTA_GOALS:
+		return damon_sysfs_damon_call(
+				damon_sysfs_upd_schemes_quota_goals,
+				kdamond);
 	case DAMON_SYSFS_CMD_UPDATE_TUNED_INTERVALS:
 		return damon_sysfs_damon_call(
 				damon_sysfs_upd_tuned_intervals, kdamond);
-- 
2.43.0


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

* [PATCH 3/6] Docs/ABI/damon: document update_schemes_quota_goals command
  2026-05-18 19:09 [PATCH 1/6] mm/damon: fix missing parens in macro arguments Maksym Shcherba
  2026-05-18 19:09 ` [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command Maksym Shcherba
@ 2026-05-18 19:09 ` Maksym Shcherba
  2026-05-18 19:09 ` [PATCH 4/6] Docs/admin-guide/mm/damon/usage: document update_schemes_quota_goals sysfs command Maksym Shcherba
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Maksym Shcherba @ 2026-05-18 19:09 UTC (permalink / raw)
  To: sj, akpm
  Cc: david, ljs, liam, vbabka, rppt, surenb, mhocko, corbet, skhan,
	damon, linux-mm, linux-kernel, linux-doc, linux-kselftest,
	Maksym Shcherba

Update the DAMON ABI doc for the kdamond state file input command
for updating the current values of quota goals.

Assisted-by: Antigravity:Gemini-3.1-Pro
Signed-off-by: Maksym Shcherba <maksym.shcherba@lnu.edu.ua>
---
 Documentation/ABI/testing/sysfs-kernel-mm-damon | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon
index ee29d4e204ff..0bd33c1e6790 100644
--- a/Documentation/ABI/testing/sysfs-kernel-mm-damon
+++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon
@@ -36,7 +36,9 @@ Description:	Writing 'on' or 'off' to this file makes the kdamond starts or
 		kdamond.  Writing 'clear_schemes_tried_regions' to the file
 		removes contents of the 'tried_regions' directory.  Writing
 		'update_schemes_effective_quotas' to the file updates
-		'.../quotas/effective_bytes' files of this kdamond.
+		'.../quotas/effective_bytes' files of this kdamond.  Writing
+		'update_schemes_quota_goals' to the file updates
+		'.../quotas/goals/<G>/current_value' files of this kdamond.
 
 What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/pid
 Date:		Mar 2022
-- 
2.43.0


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

* [PATCH 4/6] Docs/admin-guide/mm/damon/usage: document update_schemes_quota_goals sysfs command
  2026-05-18 19:09 [PATCH 1/6] mm/damon: fix missing parens in macro arguments Maksym Shcherba
  2026-05-18 19:09 ` [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command Maksym Shcherba
  2026-05-18 19:09 ` [PATCH 3/6] Docs/ABI/damon: document " Maksym Shcherba
@ 2026-05-18 19:09 ` Maksym Shcherba
  2026-05-18 19:09 ` [PATCH 5/6] selftests/damon/_damon_sysfs: support update_schemes_quota_goals Maksym Shcherba
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Maksym Shcherba @ 2026-05-18 19:09 UTC (permalink / raw)
  To: sj, akpm
  Cc: david, ljs, liam, vbabka, rppt, surenb, mhocko, corbet, skhan,
	damon, linux-mm, linux-kernel, linux-doc, linux-kselftest,
	Maksym Shcherba

Update the DAMON sysfs usage document to describe the newly
added update_schemes_quota_goals command, which allows users to read the
current values of the quota goals after explicitly triggering an update.

Assisted-by: Antigravity:Gemini-3.1-Pro
Signed-off-by: Maksym Shcherba <maksym.shcherba@lnu.edu.ua>
---
 Documentation/admin-guide/mm/damon/usage.rst | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 11c75a598393..097d8ebe960b 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -167,6 +167,9 @@ Users can write below commands for the kdamond to the ``state`` file.
 - ``update_schemes_effective_quotas``: Update the contents of
   ``effective_bytes`` files for each DAMON-based operation scheme of the
   kdamond.  For more details, refer to :ref:`quotas directory <sysfs_quotas>`.
+- ``update_schemes_quota_goals``: Update the contents of ``current_value`` files
+  for each DAMON-based operation scheme quota goal of the kdamond.  For more
+  details, refer to :ref:`goals directory <sysfs_schemes_quota_goals>`.
 
 If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread.
 
@@ -448,7 +451,11 @@ get the five parameters for the quota auto-tuning goals that specified on the
 :ref:`design doc <damon_design_damos_quotas_auto_tuning>` by writing to and
 reading from each of the files.  Note that users should further write
 ``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond
-directory <sysfs_kdamond>` to pass the feedback to DAMON.
+directory <sysfs_kdamond>` to pass the feedback to DAMON.  The
+``current_value`` file is not updated in real time, so users should ask DAMON
+sysfs interface to periodically update it using ``refresh_ms``, or do a one time
+update by writing a special keyword, ``update_schemes_quota_goals`` to the
+relevant ``kdamonds/<N>/state`` file.
 
 .. _sysfs_watermarks:
 
-- 
2.43.0


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

* [PATCH 5/6] selftests/damon/_damon_sysfs: support update_schemes_quota_goals
  2026-05-18 19:09 [PATCH 1/6] mm/damon: fix missing parens in macro arguments Maksym Shcherba
                   ` (2 preceding siblings ...)
  2026-05-18 19:09 ` [PATCH 4/6] Docs/admin-guide/mm/damon/usage: document update_schemes_quota_goals sysfs command Maksym Shcherba
@ 2026-05-18 19:09 ` Maksym Shcherba
  2026-05-18 19:09 ` [PATCH 6/6] selftests/damon: add a test for update_schemes_quota_goals Maksym Shcherba
  2026-05-19  0:10 ` [PATCH 1/6] mm/damon: fix missing parens in macro arguments SeongJae Park
  5 siblings, 0 replies; 10+ messages in thread
From: Maksym Shcherba @ 2026-05-18 19:09 UTC (permalink / raw)
  To: sj, akpm
  Cc: david, ljs, liam, vbabka, rppt, surenb, mhocko, corbet, skhan,
	damon, linux-mm, linux-kernel, linux-doc, linux-kselftest,
	Maksym Shcherba

Add update_schemes_quota_goals() method to the Kdamond class in
_damon_sysfs.py, which writes 'update_schemes_quota_goals' to the state
file and reads back the current_value of each quota goal.

Assisted-by: Antigravity:Gemini-3.1-Pro
Signed-off-by: Maksym Shcherba <maksym.shcherba@lnu.edu.ua>
---
 tools/testing/selftests/damon/_damon_sysfs.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing/selftests/damon/_damon_sysfs.py
index 8b12cc048440..27cd94683f6d 100644
--- a/tools/testing/selftests/damon/_damon_sysfs.py
+++ b/tools/testing/selftests/damon/_damon_sysfs.py
@@ -806,6 +806,21 @@ class Kdamond:
                     goal.effective_bytes = int(content)
         return None
 
+    def update_schemes_quota_goals(self):
+        err = write_file(os.path.join(self.sysfs_dir(), 'state'),
+                         'update_schemes_quota_goals')
+        if err is not None:
+            return err
+        for context in self.contexts:
+            for scheme in context.schemes:
+                for goal in scheme.quota.goals:
+                    content, err = read_file(
+                            os.path.join(goal.sysfs_dir(), 'current_value'))
+                    if err is not None:
+                        return err
+                    goal.current_value = int(content)
+        return None
+
     def commit(self):
         nr_contexts_file = os.path.join(self.sysfs_dir(),
                 'contexts', 'nr_contexts')
-- 
2.43.0


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

* [PATCH 6/6] selftests/damon: add a test for update_schemes_quota_goals
  2026-05-18 19:09 [PATCH 1/6] mm/damon: fix missing parens in macro arguments Maksym Shcherba
                   ` (3 preceding siblings ...)
  2026-05-18 19:09 ` [PATCH 5/6] selftests/damon/_damon_sysfs: support update_schemes_quota_goals Maksym Shcherba
@ 2026-05-18 19:09 ` Maksym Shcherba
  2026-05-19  0:10 ` [PATCH 1/6] mm/damon: fix missing parens in macro arguments SeongJae Park
  5 siblings, 0 replies; 10+ messages in thread
From: Maksym Shcherba @ 2026-05-18 19:09 UTC (permalink / raw)
  To: sj, akpm
  Cc: david, ljs, liam, vbabka, rppt, surenb, mhocko, corbet, skhan,
	damon, linux-mm, linux-kernel, linux-doc, linux-kselftest,
	Maksym Shcherba

The new update_schemes_quota_goals sysfs command allows users to manually
update the current_value of quota goals.

Add a selftest for the command. The test writes a dummy value to
current_value, executes the update command, and verifies that the dummy
value is successfully overwritten by the kernel.

Assisted-by: Antigravity:Gemini-3.1-Pro
Signed-off-by: Maksym Shcherba <maksym.shcherba@lnu.edu.ua>
---
 tools/testing/selftests/damon/Makefile        |  1 +
 .../damon/sysfs_update_schemes_quota_goals.py | 86 +++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100755 tools/testing/selftests/damon/sysfs_update_schemes_quota_goals.py

diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile
index 2180c328a825..a692ebaa6c8a 100644
--- a/tools/testing/selftests/damon/Makefile
+++ b/tools/testing/selftests/damon/Makefile
@@ -13,6 +13,7 @@ TEST_PROGS += sysfs.py
 TEST_PROGS += sysfs_update_schemes_tried_regions_wss_estimation.py
 TEST_PROGS += damos_quota.py damos_quota_goal.py damos_apply_interval.py
 TEST_PROGS += damos_tried_regions.py damon_nr_regions.py
+TEST_PROGS += sysfs_update_schemes_quota_goals.py
 TEST_PROGS += reclaim.sh lru_sort.sh
 
 # regression tests (reproducers of previously found bugs)
diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_quota_goals.py b/tools/testing/selftests/damon/sysfs_update_schemes_quota_goals.py
new file mode 100755
index 000000000000..745b97f75bc2
--- /dev/null
+++ b/tools/testing/selftests/damon/sysfs_update_schemes_quota_goals.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""
+Test the update_schemes_quota_goals sysfs command.
+
+Start DAMON with a scheme that has a some_mem_psi_us quota goal.  Write a
+physically impossible dummy value to the goal's current_value sysfs file.
+Wait for a while, ensure the dummy value is not overwritten asynchronously,
+then write 'update_schemes_quota_goals' to the state file and verify that
+the dummy value is overwritten by the kernel.
+"""
+
+import os
+import time
+
+import _damon_sysfs
+
+
+def main():
+    goal = _damon_sysfs.DamosQuotaGoal(
+            metric=_damon_sysfs.qgoal_metric_some_mem_psi_us,
+            target_value=1000)
+    kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond(
+            contexts=[_damon_sysfs.DamonCtx(
+                ops='paddr',
+                schemes=[_damon_sysfs.Damos(
+                    action='stat',
+                    quota=_damon_sysfs.DamosQuota(
+                        goals=[goal], reset_interval_ms=100),
+                    )]  # schemes
+                )]  # contexts
+            )])  # kdamonds
+
+    err = kdamonds.start()
+    if err is not None:
+        print('kdamond start failed: %s' % err)
+        exit(1)
+
+    # Write a dummy value to current_value to ensure the command actually
+    # overwrites it. We use 2x the quota reset interval in microseconds,
+    # which is a physically impossible value for the kernel to measure.
+    impossible_value = goal.quota.reset_interval_ms * 2000
+    err = _damon_sysfs.write_file(
+            os.path.join(goal.sysfs_dir(), 'current_value'),
+            '%d' % impossible_value)
+    if err is not None:
+        kdamonds.stop()
+        print('Writing dummy current_value failed: %s' % err)
+        exit(1)
+
+    # wait a couple of aggregation intervals so that the kernel has a chance
+    # to compute the first current_value measurement
+    time.sleep(0.5)
+
+    content, err = _damon_sysfs.read_file(
+            os.path.join(goal.sysfs_dir(), 'current_value'))
+    if err is not None:
+        kdamonds.stop()
+        print('Reading current_value before update failed: %s' % err)
+        exit(1)
+    if int(content) != impossible_value:
+        kdamonds.stop()
+        print('current_value changed before update (%s)' % content)
+        exit(1)
+
+    err = kdamonds.kdamonds[0].update_schemes_quota_goals()
+    if err is not None:
+        kdamonds.stop()
+        print('update_schemes_quota_goals failed: %s' % err)
+        exit(1)
+
+    # current_value must be updated and different from our dummy value
+    if goal.current_value is None or goal.current_value == impossible_value:
+        kdamonds.stop()
+        print('update_schemes_quota_goals failed to update current_value')
+        exit(1)
+
+    print('current_value after update_schemes_quota_goals: %d' %
+          goal.current_value)
+
+    kdamonds.stop()
+
+
+if __name__ == '__main__':
+    main()
-- 
2.43.0


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

* Re: [PATCH 1/6] mm/damon: fix missing parens in macro arguments
  2026-05-18 19:09 [PATCH 1/6] mm/damon: fix missing parens in macro arguments Maksym Shcherba
                   ` (4 preceding siblings ...)
  2026-05-18 19:09 ` [PATCH 6/6] selftests/damon: add a test for update_schemes_quota_goals Maksym Shcherba
@ 2026-05-19  0:10 ` SeongJae Park
  5 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2026-05-19  0:10 UTC (permalink / raw)
  To: Maksym Shcherba
  Cc: SeongJae Park, akpm, david, ljs, liam, vbabka, rppt, surenb,
	mhocko, corbet, skhan, damon, linux-mm, linux-kernel, linux-doc,
	linux-kselftest, Maksym Shcherba

On Mon, 18 May 2026 22:09:27 +0300 Maksym Shcherba <mshcherba2000@gmail.com> wrote:

> The DAMON iterator macros do not wrap their pointer arguments with
> parentheses. This can cause build failures when the argument is a
> complex expression due to operator precedence issues.
> 
> Add missing parentheses around the arguments in the following macros
> to prevent potential build failures:
> - damon_for_each_region()
> - damon_for_each_region_from()
> - damon_for_each_region_safe()
> - damos_for_each_quota_goal()

Nice catch, thank you!

> 
> Assisted-by: Antigravity:Gemini-3.1-Pro
> Signed-off-by: Maksym Shcherba <maksym.shcherba@lnu.edu.ua>

checkpatch.pl warns as below:

WARNING: From:/Signed-off-by: email address mismatch: 'From: Maksym Shcherba <mshcherba2000@gmail.com>' != 'Signed-off-by: Maksym Shcherba <maksym.shcherba@lnu.edu.ua>'

Assuming that will be fixed,

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]

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

* Re: [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command
  2026-05-18 19:09 ` [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command Maksym Shcherba
@ 2026-05-19  0:17   ` SeongJae Park
  2026-05-19  7:33     ` Maksym Shcherba
  0 siblings, 1 reply; 10+ messages in thread
From: SeongJae Park @ 2026-05-19  0:17 UTC (permalink / raw)
  To: Maksym Shcherba
  Cc: SeongJae Park, akpm, david, ljs, liam, vbabka, rppt, surenb,
	mhocko, corbet, skhan, damon, linux-mm, linux-kernel, linux-doc,
	linux-kselftest, Maksym Shcherba

On Mon, 18 May 2026 22:09:28 +0300 Maksym Shcherba <mshcherba2000@gmail.com> wrote:

> Add the logic to copy the current_value from the internal
> damos_quota_goal structure to the damos_sysfs_quota_goal sysfs structure.
> Introduce the DAMON_SYSFS_CMD_UPDATE_SCHEMES_QUOTA_GOALS command
> and integrate it with the sysfs interface via the 'state' file.

Could you please further elaborate why you think this change is needed?  What
is the expected use case and benefit?

Seems the following patches of this series depend on this patch.  I will hold
review of more details in this and following patches until the above high level
question is answered.


Thanks,
SJ

[...]

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

* Re: [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command
  2026-05-19  0:17   ` SeongJae Park
@ 2026-05-19  7:33     ` Maksym Shcherba
  2026-05-19 15:08       ` SeongJae Park
  0 siblings, 1 reply; 10+ messages in thread
From: Maksym Shcherba @ 2026-05-19  7:33 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Maksym Shcherba, Maksym Shcherba, akpm, david, ljs, liam, vbabka,
	rppt, surenb, mhocko, corbet, skhan, damon, linux-mm,
	linux-kernel, linux-doc, linux-kselftest

On Mon, 18 May 2026 17:17:02 -0700 SeongJae Park <sj@kernel.org> wrote:

> On Mon, 18 May 2026 22:09:28 +0300 Maksym Shcherba <mshcherba2000@gmail.com> wrote:
> 
> > Add the logic to copy the current_value from the internal
> > damos_quota_goal structure to the damos_sysfs_quota_goal sysfs structure.
> > Introduce the DAMON_SYSFS_CMD_UPDATE_SCHEMES_QUOTA_GOALS command
> > and integrate it with the sysfs interface via the 'state' file.
> 
> Could you please further elaborate why you think this change is needed?  What
> is the expected use case and benefit?
>

Hi SJ,

The documentation (`Documentation/admin-guide/mm/damon/usage.rst`)
states that users can read the `current_value` file. However, the
kernel currently never updates this value in sysfs, preventing users
from reading the actual metrics.

This patch series implements the missing logic to align the code
with the documentation.

If the design intent was to intentionally keep `current_value`
internal and not expose it via sysfs, then the documentation is
incorrect. Let me know if that's the case, and I will send a v2
that drops the code changes and only fixes the documentation.

(Apologies for missing the cover letter where this should have
been explained, this is my first patch submission).

Thanks,
Maksym Shcherba

[...]

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

* Re: [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command
  2026-05-19  7:33     ` Maksym Shcherba
@ 2026-05-19 15:08       ` SeongJae Park
  0 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2026-05-19 15:08 UTC (permalink / raw)
  To: Maksym Shcherba
  Cc: SeongJae Park, Maksym Shcherba, akpm, david, ljs, liam, vbabka,
	rppt, surenb, mhocko, corbet, skhan, damon, linux-mm,
	linux-kernel, linux-doc, linux-kselftest

On Tue, 19 May 2026 10:33:52 +0300 Maksym Shcherba <mshcherba2000@gmail.com> wrote:

> On Mon, 18 May 2026 17:17:02 -0700 SeongJae Park <sj@kernel.org> wrote:
> 
> > On Mon, 18 May 2026 22:09:28 +0300 Maksym Shcherba <mshcherba2000@gmail.com> wrote:
> > 
> > > Add the logic to copy the current_value from the internal
> > > damos_quota_goal structure to the damos_sysfs_quota_goal sysfs structure.
> > > Introduce the DAMON_SYSFS_CMD_UPDATE_SCHEMES_QUOTA_GOALS command
> > > and integrate it with the sysfs interface via the 'state' file.
> > 
> > Could you please further elaborate why you think this change is needed?  What
> > is the expected use case and benefit?
> >
> 
> Hi SJ,
> 
> The documentation (`Documentation/admin-guide/mm/damon/usage.rst`)
> states that users can read the `current_value` file. However, the
> kernel currently never updates this value in sysfs, preventing users
> from reading the actual metrics.
> 
> This patch series implements the missing logic to align the code
> with the documentation.

Thank you for clarifying, Maksym.

> 
> If the design intent was to intentionally keep `current_value`
> internal and not expose it via sysfs, then the documentation is
> incorrect. Let me know if that's the case, and I will send a v2
> that drops the code changes and only fixes the documentation.

Yes, the documentation is incorrect.  It was written in the way due to
following history.  The DAMOS quota auto-tuning feature was initially developed
with oly 'user_input' target metric type.  In the case, 'current_value' is set
by users.  Hence reading the file was returning the last user-input value.
That is, as the documentation is also saying, it is returning the 'parameter'
(user input) value.  It is not designed for exposing the internal state.

Later we extended the feature to let DAMOS self-fetch the current value.  The
fact that the ``current_value`` is for reading and writing the parameter (user
input) value, and therefore reading it doesn't return the internal set value,
should be further clarified, but I forgot doing that.

So, yes, if the current behavior is not making problem, let's update the
documentation.  I'll wait for your v2 :)

> 
> (Apologies for missing the cover letter where this should have
> been explained, this is my first patch submission).

No worries, we continuously mistake and learn from each other in the
DAMON/mm/linux community!  Welcome to the community, and I'm looking forward to
your v2!


Thanks,
SJ

[...]

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

end of thread, other threads:[~2026-05-19 15:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-18 19:09 [PATCH 1/6] mm/damon: fix missing parens in macro arguments Maksym Shcherba
2026-05-18 19:09 ` [PATCH 2/6] mm/damon/sysfs: implement update_schemes_quota_goals command Maksym Shcherba
2026-05-19  0:17   ` SeongJae Park
2026-05-19  7:33     ` Maksym Shcherba
2026-05-19 15:08       ` SeongJae Park
2026-05-18 19:09 ` [PATCH 3/6] Docs/ABI/damon: document " Maksym Shcherba
2026-05-18 19:09 ` [PATCH 4/6] Docs/admin-guide/mm/damon/usage: document update_schemes_quota_goals sysfs command Maksym Shcherba
2026-05-18 19:09 ` [PATCH 5/6] selftests/damon/_damon_sysfs: support update_schemes_quota_goals Maksym Shcherba
2026-05-18 19:09 ` [PATCH 6/6] selftests/damon: add a test for update_schemes_quota_goals Maksym Shcherba
2026-05-19  0:10 ` [PATCH 1/6] mm/damon: fix missing parens in macro arguments SeongJae Park

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