Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/damon: add paddr kunit and replace weird "same to" uses in design doc
@ 2026-11-16 15:10 SJ Park
  2026-11-16 15:10 ` [PATCH 1/2] mm/damon/paddr: add KUnit tests for addr_unit conversion SJ Park
  2026-11-16 15:10 ` [PATCH 2/2] Docs/mm/damon/design: replace "same to" with "same as" SJ Park
  0 siblings, 2 replies; 3+ messages in thread
From: SJ Park @ 2026-11-16 15:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SJ Park, Jonathan Corbet, Randy Dunlap, Shuah Khan, damon,
	linux-doc, linux-kernel, linux-mm

Add kunit tests for physical address space DAMON operation set, via
patch 1 from Avelin Noir.  Use idiomatic "same as" instead of weird
"same to" in design doc, via patch 2 from Enze Li.

This is a batched reposting of DAMON patches for mm.git merge request.
Refer to changelog in each patch for their real changelog.

Aveline Noir (1):
  mm/damon/paddr: add KUnit tests for addr_unit conversion

Enze Li (1):
  Docs/mm/damon/design: replace "same to" with "same as"

 Documentation/mm/damon/design.rst | 14 ++++----
 mm/damon/Kconfig                  | 12 +++++++
 mm/damon/paddr.c                  |  2 ++
 mm/damon/tests/.kunitconfig       |  4 +++
 mm/damon/tests/paddr-kunit.h      | 55 +++++++++++++++++++++++++++++++
 5 files changed, 80 insertions(+), 7 deletions(-)
 create mode 100644 mm/damon/tests/paddr-kunit.h


base-commit: 4789d52076c67ff1ce4c66fe7ee17718a48b3bec
-- 
2.47.3


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

* [PATCH 1/2] mm/damon/paddr: add KUnit tests for addr_unit conversion
  2026-11-16 15:10 [PATCH 0/2] mm/damon: add paddr kunit and replace weird "same to" uses in design doc SJ Park
@ 2026-11-16 15:10 ` SJ Park
  2026-11-16 15:10 ` [PATCH 2/2] Docs/mm/damon/design: replace "same to" with "same as" SJ Park
  1 sibling, 0 replies; 3+ messages in thread
From: SJ Park @ 2026-11-16 15:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Aveline Noir, SJ Park, damon, linux-kernel, linux-mm

From: Aveline Noir <jm5905938@gmail.com>

damon_pa_phys_addr() and damon_pa_core_addr() convert between DAMON core
addresses and physical addresses using addr_unit.  addr_unit lets 32-bit
kernels with a 64-bit phys_addr_t monitor physical memory above 4 GiB,
but no test covers the conversions.

Add a KUnit suite for both helpers, including a case for addresses above
4 GiB that is skipped when phys_addr_t is 32-bit.

Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20261109-test-damon-paddr-addr-unit-kunit-v1-1-bd10bb87be98@gmail.com
- Shorten config prompt.
- Collect R-b: from SJ.
- Rebase to the latest mm-new.

 mm/damon/Kconfig             | 12 ++++++++
 mm/damon/paddr.c             |  2 ++
 mm/damon/tests/.kunitconfig  |  4 +++
 mm/damon/tests/paddr-kunit.h | 55 ++++++++++++++++++++++++++++++++++++
 4 files changed, 73 insertions(+)
 create mode 100644 mm/damon/tests/paddr-kunit.h

diff --git a/mm/damon/Kconfig b/mm/damon/Kconfig
index 34631a44cdecb..a33f21c563475 100644
--- a/mm/damon/Kconfig
+++ b/mm/damon/Kconfig
@@ -65,6 +65,18 @@ config DAMON_VADDR_KUNIT_TEST
 
 	  If unsure, say N.
 
+config DAMON_PADDR_KUNIT_TEST
+	bool "Tets for DAMON physical address operations" if !KUNIT_ALL_TESTS
+	depends on DAMON_PADDR && KUNIT=y
+	default KUNIT_ALL_TESTS
+	help
+	  This builds the DAMON physical address operations Kunit test suite.
+
+	  For more information on KUnit and unit tests in general, please refer
+	  to the KUnit documentation.
+
+	  If unsure, say N.
+
 config DAMON_SYSFS
 	bool "DAMON sysfs interface"
 	depends on DAMON && SYSFS
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 5b773012a8764..e89cb14ee17be 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -479,3 +479,5 @@ static int __init damon_pa_initcall(void)
 }
 
 subsys_initcall(damon_pa_initcall);
+
+#include "tests/paddr-kunit.h"
diff --git a/mm/damon/tests/.kunitconfig b/mm/damon/tests/.kunitconfig
index 144d27e6ecc5c..9279f0c82be7e 100644
--- a/mm/damon/tests/.kunitconfig
+++ b/mm/damon/tests/.kunitconfig
@@ -9,6 +9,10 @@ CONFIG_PAGE_IDLE_FLAG=y
 CONFIG_DAMON_VADDR=y
 CONFIG_DAMON_VADDR_KUNIT_TEST=y
 
+# for DAMON paddr ops
+CONFIG_DAMON_PADDR=y
+CONFIG_DAMON_PADDR_KUNIT_TEST=y
+
 # for DAMON sysfs interface
 CONFIG_SYSFS=y
 CONFIG_DAMON_SYSFS=y
diff --git a/mm/damon/tests/paddr-kunit.h b/mm/damon/tests/paddr-kunit.h
new file mode 100644
index 0000000000000..9839cc2330712
--- /dev/null
+++ b/mm/damon/tests/paddr-kunit.h
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Data Access Monitor Unit Tests
+ */
+
+#ifdef CONFIG_DAMON_PADDR_KUNIT_TEST
+
+#ifndef _DAMON_PADDR_TEST_H
+#define _DAMON_PADDR_TEST_H
+
+#include <kunit/test.h>
+
+static void damon_test_pa_phys_addr(struct kunit *test)
+{
+	KUNIT_EXPECT_EQ(test, damon_pa_phys_addr(0x1000, 1), 0x1000);
+	KUNIT_EXPECT_EQ(test, damon_pa_phys_addr(0x40000, 0x1000), 0x40000000);
+}
+
+static void damon_test_pa_core_addr(struct kunit *test)
+{
+	KUNIT_EXPECT_EQ(test, damon_pa_core_addr(0x1000000, 0x1000), 0x1000);
+	/* The conversion rounds down. */
+	KUNIT_EXPECT_EQ(test, damon_pa_core_addr(0x1fff, 0x1000), 1);
+	KUNIT_EXPECT_EQ(test, damon_pa_core_addr(0xfff, 0x1000), 0);
+}
+
+static void damon_test_pa_addr_over_4g(struct kunit *test)
+{
+	unsigned long addr = 0xffffffffUL;
+	unsigned long addr_unit = 0x1000;
+	u64 pa = 0xffffffff000ULL;
+
+	if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT))
+		kunit_skip(test, "phys_addr_t is 32-bit");
+
+	KUNIT_EXPECT_EQ(test, damon_pa_phys_addr(addr, addr_unit), pa);
+	KUNIT_EXPECT_EQ(test, damon_pa_core_addr(pa, addr_unit), addr);
+}
+
+static struct kunit_case damon_paddr_test_cases[] = {
+	KUNIT_CASE(damon_test_pa_phys_addr),
+	KUNIT_CASE(damon_test_pa_core_addr),
+	KUNIT_CASE(damon_test_pa_addr_over_4g),
+	{},
+};
+
+static struct kunit_suite damon_paddr_test_suite = {
+	.name = "damon-paddr",
+	.test_cases = damon_paddr_test_cases,
+};
+kunit_test_suite(damon_paddr_test_suite);
+
+#endif /* _DAMON_PADDR_TEST_H */
+
+#endif	/* CONFIG_DAMON_PADDR_KUNIT_TEST */
-- 
2.47.3


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

* [PATCH 2/2] Docs/mm/damon/design: replace "same to" with "same as"
  2026-11-16 15:10 [PATCH 0/2] mm/damon: add paddr kunit and replace weird "same to" uses in design doc SJ Park
  2026-11-16 15:10 ` [PATCH 1/2] mm/damon/paddr: add KUnit tests for addr_unit conversion SJ Park
@ 2026-11-16 15:10 ` SJ Park
  1 sibling, 0 replies; 3+ messages in thread
From: SJ Park @ 2026-11-16 15:10 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Enze Li, Jonathan Corbet, Randy Dunlap, SJ Park, Shuah Khan,
	damon, linux-doc, linux-kernel, linux-mm

From: Enze Li <lienze@kylinos.cn>

"same to" is not idiomatic; it should be "the same as" or "same as".
This doc has six such usages.  Fix all of them at once for consistency.

Signed-off-by: Enze Li <lienze@kylinos.cn>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20261114055436.5546-1-lienze@kylinos.cn
- Collect A-b: from Randy and R-b: from SJ.
- Rebase to the latest mm-new.

 Documentation/mm/damon/design.rst | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index b676be6971589..6284b90054430 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -292,17 +292,17 @@ DAMON :ref:`context <damon_design_execution_model_and_data_structures>`.  The
 registration is made by specifying a probe per attribute.  Each of the probes
 specifies a rule to determine if a given memory region has the related
 attribute.  The rule is constructed with multiple filters.  The filters work
-same to :ref:`DAMOS filters <damon_design_damos_filters>` except the supported
-filter types.  Currently below filter types are supported.
+the same as :ref:`DAMOS filters <damon_design_damos_filters>` except the
+supported filter types.  Currently below filter types are supported.
 
-- ``anon``: Same to that for DAMOS filters.
-- ``memcg``: Same to that for DAMOS filters.
+- ``anon``: Same as that for DAMOS filters.
+- ``memcg``: Same as that for DAMOS filters.
 - ``pgidle_unset``: Matches if the page for the memory is marked as not
   access-idle.
 - ``pgidle_set``: Matches if the page for the memory is marked as access-idle.
 - ``hugepage_size``: Matches if the page for the memory is a part of a hugepage
   of a given size range.
-- ``active``: Same to that for DAMOS filters.
+- ``active``: Same as that for DAMOS filters.
 
 If such probes are registered, DAMON executes the probes for each region's
 sampling memory when it does the access :ref:`sampling
@@ -706,7 +706,7 @@ There are two such tuning algorithms that users can select as they need.
 The goal can be specified with six parameters, namely ``target_metric``,
 ``complement``, ``target_value``, ``current_value``, ``nid`` and ``path``.  The
 auto-tuning mechanism tries to make ``current_value`` of ``complement``-ed
-``target_metric`` be same to ``target_value``.
+``target_metric`` be the same as ``target_value``.
 
 - ``user_input``: User-provided value.  Users could use any metric that they
   have interest in for the value.  User space main workload's latency or
@@ -736,7 +736,7 @@ auto-tuning mechanism tries to make ``current_value`` of ``complement``-ed
 
 ``complement`` is a boolean parameter that determines whether to use
 complemented value of the target metric.  For example, if ``complement`` is set
-and target metric is ``active_mem_bp``, it is effectively same to
+and target metric is ``active_mem_bp``, it is effectively the same as
 ``inactive_mem_bp``.  ``complement`` is no-op when the target metric type is
 ``user_input``.  For the metric type, the user should be able to emit
 complemented metric values on their own.
-- 
2.47.3


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

end of thread, other threads:[~2026-11-16 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 15:10 [PATCH 0/2] mm/damon: add paddr kunit and replace weird "same to" uses in design doc SJ Park
2026-11-16 15:10 ` [PATCH 1/2] mm/damon/paddr: add KUnit tests for addr_unit conversion SJ Park
2026-11-16 15:10 ` [PATCH 2/2] Docs/mm/damon/design: replace "same to" with "same as" SJ Park

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