* [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE.
@ 2026-03-23 14:56 gutierrez.asier
2026-03-23 14:56 ` [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action gutierrez.asier
2026-03-24 0:39 ` [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE SeongJae Park
0 siblings, 2 replies; 15+ messages in thread
From: gutierrez.asier @ 2026-03-23 14:56 UTC (permalink / raw)
To: gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, sj, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
working, since it relies on hugepage_madvise to add a new slot. This
slot should be picked up by khugepaged and eventually collapse (or
not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
enabled, khugepaged will not be working, and therefore no collapse
will happen.
DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
the address range synchronously.
This new action may be required to support autotuning with hugepage as
a goal[1].
[1]: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
---------
Benchmarks:
T n: THP never
T m: THP madvise
D h: DAMON action hugepage
D c: DAMON action collapse
+------------------+----------+----------+----------+
| | T n, D h | T m, D h | T n, D c |
+------------------+----------+----------+----------+
| Total memory use | 2.07 | 2.09 | 2.07 |
| Huge pages | 0 | 1.3 | 1.25 |
+------------------+----------+----------+----------+
Changes
---------
v1-v2:
Added benchmarks
Added damos_filter_type documentation for new action to fix kernel-doc
Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
---
Documentation/mm/damon/design.rst | 4 ++++
include/linux/damon.h | 2 ++
mm/damon/sysfs-schemes.c | 4 ++++
mm/damon/vaddr.c | 3 +++
tools/testing/selftests/damon/sysfs.py | 11 ++++++-----
5 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 838b14d22519..405142641e55 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -467,6 +467,10 @@ that supports each action are as below.
Supported by ``vaddr`` and ``fvaddr`` operations set. When
TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
fail.
+ - ``collapse``: Call ``madvise()`` for the region with ``MADV_COLLAPSE``.
+ Supported by ``vaddr`` and ``fvaddr`` operations set. When
+ TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
+ fail.
- ``lru_prio``: Prioritize the region on its LRU lists.
Supported by ``paddr`` operations set.
- ``lru_deprio``: Deprioritize the region on its LRU lists.
diff --git a/include/linux/damon.h b/include/linux/damon.h
index d9a3babbafc1..6941113968ec 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -121,6 +121,7 @@ struct damon_target {
* @DAMOS_PAGEOUT: Reclaim the region.
* @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE.
* @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE.
+ * @DAMOS_COLLAPSE: Call ``madvise()`` for the region with MADV_COLLAPSE.
* @DAMOS_LRU_PRIO: Prioritize the region on its LRU lists.
* @DAMOS_LRU_DEPRIO: Deprioritize the region on its LRU lists.
* @DAMOS_MIGRATE_HOT: Migrate the regions prioritizing warmer regions.
@@ -140,6 +141,7 @@ enum damos_action {
DAMOS_PAGEOUT,
DAMOS_HUGEPAGE,
DAMOS_NOHUGEPAGE,
+ DAMOS_COLLAPSE,
DAMOS_LRU_PRIO,
DAMOS_LRU_DEPRIO,
DAMOS_MIGRATE_HOT,
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 5186966dafb3..aa08a8f885fb 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2041,6 +2041,10 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
.action = DAMOS_NOHUGEPAGE,
.name = "nohugepage",
},
+ {
+ .action = DAMOS_COLLAPSE,
+ .name = "collapse",
+ },
{
.action = DAMOS_LRU_PRIO,
.name = "lru_prio",
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index b069dbc7e3d2..dd5f2d7027ac 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -903,6 +903,9 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx,
case DAMOS_NOHUGEPAGE:
madv_action = MADV_NOHUGEPAGE;
break;
+ case DAMOS_COLLAPSE:
+ madv_action = MADV_COLLAPSE;
+ break;
case DAMOS_MIGRATE_HOT:
case DAMOS_MIGRATE_COLD:
return damos_va_migrate(t, r, scheme, sz_filter_passed);
diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index 3aa5c91548a5..c6476e63f4fb 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
'pageout': 2,
'hugepage': 3,
'nohugeapge': 4,
- 'lru_prio': 5,
- 'lru_deprio': 6,
- 'migrate_hot': 7,
- 'migrate_cold': 8,
- 'stat': 9,
+ 'collapse': 5
+ 'lru_prio': 6,
+ 'lru_deprio': 7,
+ 'migrate_hot': 8,
+ 'migrate_cold': 9,
+ 'stat': 10,
}
assert_true(dump['action'] == action_val[scheme.action], 'action', dump)
assert_true(dump['apply_interval_us'] == scheme. apply_interval_us,
--
2.43.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
2026-03-23 14:56 [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE gutierrez.asier
@ 2026-03-23 14:56 ` gutierrez.asier
2026-03-24 0:29 ` (sashiko review) " SeongJae Park
2026-03-24 0:39 ` [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE SeongJae Park
1 sibling, 1 reply; 15+ messages in thread
From: gutierrez.asier @ 2026-03-23 14:56 UTC (permalink / raw)
To: gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, sj, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
This patch set introces a new action: DAMOS_COLLAPSE.
For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
working, since it relies on hugepage_madvise to add a new slot. This
slot should be picked up by khugepaged and eventually collapse (or
not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
enabled, khugepaged will not be working, and therefore no collapse
will happen.
DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
the address range synchronously.
This new action may be required to support autotuning with hugepage as
a goal[1].
[1]: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
---------
Benchmarks:
T n: THP never
T m: THP madvise
D h: DAMON action hugepage
D c: DAMON action collapse
+------------------+----------+----------+----------+
| | T n, D h | T m, D h | T n, D c |
+------------------+----------+----------+----------+
| Total memory use | 2.07 | 2.09 | 2.07 |
| Huge pages | 0 | 1.3 | 1.25 |
+------------------+----------+----------+----------+
Changes
---------
v1 -> v2:
Added benchmarks
Added damos_filter_type documentation for new action to fix kernel-doc
Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
---
Documentation/mm/damon/design.rst | 4 ++++
include/linux/damon.h | 2 ++
mm/damon/sysfs-schemes.c | 4 ++++
mm/damon/vaddr.c | 3 +++
tools/testing/selftests/damon/sysfs.py | 11 ++++++-----
5 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 838b14d22519..405142641e55 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -467,6 +467,10 @@ that supports each action are as below.
Supported by ``vaddr`` and ``fvaddr`` operations set. When
TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
fail.
+ - ``collapse``: Call ``madvise()`` for the region with ``MADV_COLLAPSE``.
+ Supported by ``vaddr`` and ``fvaddr`` operations set. When
+ TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
+ fail.
- ``lru_prio``: Prioritize the region on its LRU lists.
Supported by ``paddr`` operations set.
- ``lru_deprio``: Deprioritize the region on its LRU lists.
diff --git a/include/linux/damon.h b/include/linux/damon.h
index d9a3babbafc1..6941113968ec 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -121,6 +121,7 @@ struct damon_target {
* @DAMOS_PAGEOUT: Reclaim the region.
* @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE.
* @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE.
+ * @DAMOS_COLLAPSE: Call ``madvise()`` for the region with MADV_COLLAPSE.
* @DAMOS_LRU_PRIO: Prioritize the region on its LRU lists.
* @DAMOS_LRU_DEPRIO: Deprioritize the region on its LRU lists.
* @DAMOS_MIGRATE_HOT: Migrate the regions prioritizing warmer regions.
@@ -140,6 +141,7 @@ enum damos_action {
DAMOS_PAGEOUT,
DAMOS_HUGEPAGE,
DAMOS_NOHUGEPAGE,
+ DAMOS_COLLAPSE,
DAMOS_LRU_PRIO,
DAMOS_LRU_DEPRIO,
DAMOS_MIGRATE_HOT,
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 5186966dafb3..aa08a8f885fb 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2041,6 +2041,10 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
.action = DAMOS_NOHUGEPAGE,
.name = "nohugepage",
},
+ {
+ .action = DAMOS_COLLAPSE,
+ .name = "collapse",
+ },
{
.action = DAMOS_LRU_PRIO,
.name = "lru_prio",
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index b069dbc7e3d2..dd5f2d7027ac 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -903,6 +903,9 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx,
case DAMOS_NOHUGEPAGE:
madv_action = MADV_NOHUGEPAGE;
break;
+ case DAMOS_COLLAPSE:
+ madv_action = MADV_COLLAPSE;
+ break;
case DAMOS_MIGRATE_HOT:
case DAMOS_MIGRATE_COLD:
return damos_va_migrate(t, r, scheme, sz_filter_passed);
diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index 3aa5c91548a5..c6476e63f4fb 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
'pageout': 2,
'hugepage': 3,
'nohugeapge': 4,
- 'lru_prio': 5,
- 'lru_deprio': 6,
- 'migrate_hot': 7,
- 'migrate_cold': 8,
- 'stat': 9,
+ 'collapse': 5
+ 'lru_prio': 6,
+ 'lru_deprio': 7,
+ 'migrate_hot': 8,
+ 'migrate_cold': 9,
+ 'stat': 10,
}
assert_true(dump['action'] == action_val[scheme.action], 'action', dump)
assert_true(dump['apply_interval_us'] == scheme. apply_interval_us,
--
2.43.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: (sashiko review) [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
2026-03-23 14:56 ` [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action gutierrez.asier
@ 2026-03-24 0:29 ` SeongJae Park
2026-03-24 0:41 ` SeongJae Park
0 siblings, 1 reply; 15+ messages in thread
From: SeongJae Park @ 2026-03-24 0:29 UTC (permalink / raw)
To: gutierrez.asier
Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
Forwarding Sashiko review for doing discussions via mails.
# review url: https://sashiko.dev/#/patchset/20260323145646.4165053-2-gutierrez.asier@huawei-partners.com
# start of sashiko.dev inline review
commit eaed291e6fae91842b1836c68bab867d53525db5
Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
This commit introduces a new DAMON action, DAMOS_COLLAPSE. It allows
DAMON to synchronously collapse an address range by calling madvise
with MADV_COLLAPSE.
Link: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
[ ... ]
> diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
> index 3aa5c91548a5..c6476e63f4fb 100755
> --- a/tools/testing/selftests/damon/sysfs.py
> +++ b/tools/testing/selftests/damon/sysfs.py
> @@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
> 'pageout': 2,
> 'hugepage': 3,
> 'nohugeapge': 4,
> - 'lru_prio': 5,
> - 'lru_deprio': 6,
> - 'migrate_hot': 7,
> - 'migrate_cold': 8,
> - 'stat': 9,
> + 'collapse': 5
> + 'lru_prio': 6,
Will this cause a Python syntax error when executing the selftest? It looks
like there is a missing comma after 'collapse': 5, which might break the
execution of the DAMON sysfs test suite.
# end of sashiko.dev inline review
# review url: https://sashiko.dev/#/patchset/20260323145646.4165053-2-gutierrez.asier@huawei-partners.com
#
# hkml [1] generated a draft of this mail. It can be regenerated
# using below command:
#
# hkml patch sashiko_dev --for_forwarding \
# 20260323145646.4165053-2-gutierrez.asier@huawei-partners.com
#
# [1] https://github.com/sjp38/hackermail
Sent using hkml (https://github.com/sjp38/hackermail)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE.
2026-03-23 14:56 [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE gutierrez.asier
2026-03-23 14:56 ` [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action gutierrez.asier
@ 2026-03-24 0:39 ` SeongJae Park
2026-03-24 13:57 ` Gutierrez Asier
1 sibling, 1 reply; 15+ messages in thread
From: SeongJae Park @ 2026-03-24 0:39 UTC (permalink / raw)
To: gutierrez.asier
Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
Hello Asier,
On Mon, 23 Mar 2026 14:56:45 +0000 <gutierrez.asier@huawei-partners.com> wrote:
> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>
> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
> working, since it relies on hugepage_madvise to add a new slot. This
> slot should be picked up by khugepaged and eventually collapse (or
> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
> enabled, khugepaged will not be working, and therefore no collapse
> will happen.
>
> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
> the address range synchronously.
>
> This new action may be required to support autotuning with hugepage as
> a goal[1].
>
> [1]: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
>
> ---------
> Benchmarks:
>
> T n: THP never
> T m: THP madvise
> D h: DAMON action hugepage
> D c: DAMON action collapse
>
> +------------------+----------+----------+----------+
> | | T n, D h | T m, D h | T n, D c |
> +------------------+----------+----------+----------+
> | Total memory use | 2.07 | 2.09 | 2.07 |
> | Huge pages | 0 | 1.3 | 1.25 |
> +------------------+----------+----------+----------+
Thank you for sharing the benchmark results! But, I'm having a hard time to
understand what this really means. Could you please further clarify the setup
of the benchmarks and interpretation of the results?
>
> Changes
> ---------
> v1-v2:
> Added benchmarks
> Added damos_filter_type documentation for new action to fix kernel-doc
Please add Changelog on the commentary section [1]. Also, please consider
adding links to previous versions.
>
> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
> ---
> Documentation/mm/damon/design.rst | 4 ++++
> include/linux/damon.h | 2 ++
> mm/damon/sysfs-schemes.c | 4 ++++
> mm/damon/vaddr.c | 3 +++
> tools/testing/selftests/damon/sysfs.py | 11 ++++++-----
> 5 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
> index 838b14d22519..405142641e55 100644
> --- a/Documentation/mm/damon/design.rst
> +++ b/Documentation/mm/damon/design.rst
> @@ -467,6 +467,10 @@ that supports each action are as below.
> Supported by ``vaddr`` and ``fvaddr`` operations set. When
> TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
> fail.
> + - ``collapse``: Call ``madvise()`` for the region with ``MADV_COLLAPSE``.
> + Supported by ``vaddr`` and ``fvaddr`` operations set. When
> + TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
> + fail.
> - ``lru_prio``: Prioritize the region on its LRU lists.
> Supported by ``paddr`` operations set.
> - ``lru_deprio``: Deprioritize the region on its LRU lists.
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index d9a3babbafc1..6941113968ec 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -121,6 +121,7 @@ struct damon_target {
> * @DAMOS_PAGEOUT: Reclaim the region.
> * @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE.
> * @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE.
> + * @DAMOS_COLLAPSE: Call ``madvise()`` for the region with MADV_COLLAPSE.
> * @DAMOS_LRU_PRIO: Prioritize the region on its LRU lists.
> * @DAMOS_LRU_DEPRIO: Deprioritize the region on its LRU lists.
> * @DAMOS_MIGRATE_HOT: Migrate the regions prioritizing warmer regions.
> @@ -140,6 +141,7 @@ enum damos_action {
> DAMOS_PAGEOUT,
> DAMOS_HUGEPAGE,
> DAMOS_NOHUGEPAGE,
> + DAMOS_COLLAPSE,
> DAMOS_LRU_PRIO,
> DAMOS_LRU_DEPRIO,
> DAMOS_MIGRATE_HOT,
> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index 5186966dafb3..aa08a8f885fb 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c
> @@ -2041,6 +2041,10 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
> .action = DAMOS_NOHUGEPAGE,
> .name = "nohugepage",
> },
> + {
> + .action = DAMOS_COLLAPSE,
> + .name = "collapse",
> + },
> {
> .action = DAMOS_LRU_PRIO,
> .name = "lru_prio",
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index b069dbc7e3d2..dd5f2d7027ac 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -903,6 +903,9 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx,
> case DAMOS_NOHUGEPAGE:
> madv_action = MADV_NOHUGEPAGE;
> break;
> + case DAMOS_COLLAPSE:
> + madv_action = MADV_COLLAPSE;
> + break;
> case DAMOS_MIGRATE_HOT:
> case DAMOS_MIGRATE_COLD:
> return damos_va_migrate(t, r, scheme, sz_filter_passed);
> diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
> index 3aa5c91548a5..c6476e63f4fb 100755
> --- a/tools/testing/selftests/damon/sysfs.py
> +++ b/tools/testing/selftests/damon/sysfs.py
> @@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
> 'pageout': 2,
> 'hugepage': 3,
> 'nohugeapge': 4,
> - 'lru_prio': 5,
> - 'lru_deprio': 6,
> - 'migrate_hot': 7,
> - 'migrate_cold': 8,
> - 'stat': 9,
> + 'collapse': 5
Comman is missed?
> + 'lru_prio': 6,
> + 'lru_deprio': 7,
> + 'migrate_hot': 8,
> + 'migrate_cold': 9,
> + 'stat': 10,
> }
> assert_true(dump['action'] == action_val[scheme.action], 'action', dump)
> assert_true(dump['apply_interval_us'] == scheme. apply_interval_us,
> --
> 2.43.0
Other than the selftest part, code looks good. Please consider dropping RFC
tag from the next spin. Clarifying more details about the test would be
helpful, though.
[1] https://docs.kernel.org/process/submitting-patches.html#commentary
Thanks,
SJ
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: (sashiko review) [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
2026-03-24 0:29 ` (sashiko review) " SeongJae Park
@ 2026-03-24 0:41 ` SeongJae Park
2026-03-24 13:49 ` Gutierrez Asier
0 siblings, 1 reply; 15+ messages in thread
From: SeongJae Park @ 2026-03-24 0:41 UTC (permalink / raw)
To: SeongJae Park
Cc: gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
On Mon, 23 Mar 2026 17:29:36 -0700 SeongJae Park <sj@kernel.org> wrote:
> Forwarding Sashiko review for doing discussions via mails.
>
> # review url: https://sashiko.dev/#/patchset/20260323145646.4165053-2-gutierrez.asier@huawei-partners.com
> # start of sashiko.dev inline review
> commit eaed291e6fae91842b1836c68bab867d53525db5
> Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>
> mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
>
> This commit introduces a new DAMON action, DAMOS_COLLAPSE. It allows
> DAMON to synchronously collapse an address range by calling madvise
> with MADV_COLLAPSE.
>
> Link: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
>
> [ ... ]
> > diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
> > index 3aa5c91548a5..c6476e63f4fb 100755
> > --- a/tools/testing/selftests/damon/sysfs.py
> > +++ b/tools/testing/selftests/damon/sysfs.py
> > @@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
> > 'pageout': 2,
> > 'hugepage': 3,
> > 'nohugeapge': 4,
> > - 'lru_prio': 5,
> > - 'lru_deprio': 6,
> > - 'migrate_hot': 7,
> > - 'migrate_cold': 8,
> > - 'stat': 9,
> > + 'collapse': 5
> > + 'lru_prio': 6,
>
> Will this cause a Python syntax error when executing the selftest? It looks
> like there is a missing comma after 'collapse': 5, which might break the
> execution of the DAMON sysfs test suite.
I think sashiko is correct. We need to add a comma.
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: (sashiko review) [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
2026-03-24 0:41 ` SeongJae Park
@ 2026-03-24 13:49 ` Gutierrez Asier
0 siblings, 0 replies; 15+ messages in thread
From: Gutierrez Asier @ 2026-03-24 13:49 UTC (permalink / raw)
To: SeongJae Park
Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1,
zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka, rppt, surenb,
mhocko, corbet, skhan, linux-doc, linux-mm, linux-kernel
Hi SJ,
On 3/24/2026 3:41 AM, SeongJae Park wrote:
> On Mon, 23 Mar 2026 17:29:36 -0700 SeongJae Park <sj@kernel.org> wrote:
>
>> Forwarding Sashiko review for doing discussions via mails.
>>
>> # review url: https://sashiko.dev/#/patchset/20260323145646.4165053-2-gutierrez.asier@huawei-partners.com
>> # start of sashiko.dev inline review
>> commit eaed291e6fae91842b1836c68bab867d53525db5
>> Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>>
>> mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
>>
>> This commit introduces a new DAMON action, DAMOS_COLLAPSE. It allows
>> DAMON to synchronously collapse an address range by calling madvise
>> with MADV_COLLAPSE.
>>
>> Link: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
>>
>> [ ... ]
>>> diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
>>> index 3aa5c91548a5..c6476e63f4fb 100755
>>> --- a/tools/testing/selftests/damon/sysfs.py
>>> +++ b/tools/testing/selftests/damon/sysfs.py
>>> @@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
>>> 'pageout': 2,
>>> 'hugepage': 3,
>>> 'nohugeapge': 4,
>>> - 'lru_prio': 5,
>>> - 'lru_deprio': 6,
>>> - 'migrate_hot': 7,
>>> - 'migrate_cold': 8,
>>> - 'stat': 9,
>>> + 'collapse': 5
>>> + 'lru_prio': 6,
>>
>> Will this cause a Python syntax error when executing the selftest? It looks
>> like there is a missing comma after 'collapse': 5, which might break the
>> execution of the DAMON sysfs test suite.
>
> I think sashiko is correct. We need to add a comma.
I will fix it. Missed it, my bad
>
>
> Thanks,
> SJ
>
> [...]
>
--
Asier Gutierrez
Huawei
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE.
2026-03-24 0:39 ` [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE SeongJae Park
@ 2026-03-24 13:57 ` Gutierrez Asier
2026-03-24 14:12 ` SeongJae Park
0 siblings, 1 reply; 15+ messages in thread
From: Gutierrez Asier @ 2026-03-24 13:57 UTC (permalink / raw)
To: SeongJae Park
Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1,
zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka, rppt, surenb,
mhocko, corbet, skhan, linux-doc, linux-mm, linux-kernel
On 3/24/2026 3:39 AM, SeongJae Park wrote:
> Hello Asier,
>
> On Mon, 23 Mar 2026 14:56:45 +0000 <gutierrez.asier@huawei-partners.com> wrote:
>
>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>>
>> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
>> working, since it relies on hugepage_madvise to add a new slot. This
>> slot should be picked up by khugepaged and eventually collapse (or
>> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
>> enabled, khugepaged will not be working, and therefore no collapse
>> will happen.
>>
>> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
>> the address range synchronously.
>>
>> This new action may be required to support autotuning with hugepage as
>> a goal[1].
>>
>> [1]: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
>>
>> ---------
>> Benchmarks:
>>
>> T n: THP never
>> T m: THP madvise
>> D h: DAMON action hugepage
>> D c: DAMON action collapse
>>
>> +------------------+----------+----------+----------+
>> | | T n, D h | T m, D h | T n, D c |
>> +------------------+----------+----------+----------+
>> | Total memory use | 2.07 | 2.09 | 2.07 |
>> | Huge pages | 0 | 1.3 | 1.25 |
>> +------------------+----------+----------+----------+
>
> Thank you for sharing the benchmark results! But, I'm having a hard time to
> understand what this really means. Could you please further clarify the setup
> of the benchmarks and interpretation of the results?
I will fix the cover in the next version, which I will submit soon.
I tested the patch in a physical server with MariaDB 10.5. I run
sysbench to load the server.
I check 3 scenarios:
- DAMON action hugepage for the database task, THP as never
- DAMON action hugepage, THP madvise
- DAMON action collapse, THP never
I compared the memory consumption, both in overall in the server and
anonymous huge page consumption. The results are in the table
T n: THP never
T m: THP madvise
D h: DAMON action hugepage
D c: DAMON action collapse
+------------------+----------+----------+----------+
| | T n, D h | T m, D h | T n, D c |
+------------------+----------+----------+----------+
| Total memory use | 2.07 | 2.09 | 2.07 |
| Huge pages | 0 | 1.3 | 1.25 |
+------------------+----------+----------+----------+
>
>>
>> Changes
>> ---------
>> v1-v2:
>> Added benchmarks
>> Added damos_filter_type documentation for new action to fix kernel-doc
>
> Please add Changelog on the commentary section [1]. Also, please consider
> adding links to previous versions.
>
>>
>> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>> ---
>> Documentation/mm/damon/design.rst | 4 ++++
>> include/linux/damon.h | 2 ++
>> mm/damon/sysfs-schemes.c | 4 ++++
>> mm/damon/vaddr.c | 3 +++
>> tools/testing/selftests/damon/sysfs.py | 11 ++++++-----
>> 5 files changed, 19 insertions(+), 5 deletions(-)
>>
>> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
>> index 838b14d22519..405142641e55 100644
>> --- a/Documentation/mm/damon/design.rst
>> +++ b/Documentation/mm/damon/design.rst
>> @@ -467,6 +467,10 @@ that supports each action are as below.
>> Supported by ``vaddr`` and ``fvaddr`` operations set. When
>> TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
>> fail.
>> + - ``collapse``: Call ``madvise()`` for the region with ``MADV_COLLAPSE``.
>> + Supported by ``vaddr`` and ``fvaddr`` operations set. When
>> + TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
>> + fail.
>> - ``lru_prio``: Prioritize the region on its LRU lists.
>> Supported by ``paddr`` operations set.
>> - ``lru_deprio``: Deprioritize the region on its LRU lists.
>> diff --git a/include/linux/damon.h b/include/linux/damon.h
>> index d9a3babbafc1..6941113968ec 100644
>> --- a/include/linux/damon.h
>> +++ b/include/linux/damon.h
>> @@ -121,6 +121,7 @@ struct damon_target {
>> * @DAMOS_PAGEOUT: Reclaim the region.
>> * @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE.
>> * @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE.
>> + * @DAMOS_COLLAPSE: Call ``madvise()`` for the region with MADV_COLLAPSE.
>> * @DAMOS_LRU_PRIO: Prioritize the region on its LRU lists.
>> * @DAMOS_LRU_DEPRIO: Deprioritize the region on its LRU lists.
>> * @DAMOS_MIGRATE_HOT: Migrate the regions prioritizing warmer regions.
>> @@ -140,6 +141,7 @@ enum damos_action {
>> DAMOS_PAGEOUT,
>> DAMOS_HUGEPAGE,
>> DAMOS_NOHUGEPAGE,
>> + DAMOS_COLLAPSE,
>> DAMOS_LRU_PRIO,
>> DAMOS_LRU_DEPRIO,
>> DAMOS_MIGRATE_HOT,
>> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
>> index 5186966dafb3..aa08a8f885fb 100644
>> --- a/mm/damon/sysfs-schemes.c
>> +++ b/mm/damon/sysfs-schemes.c
>> @@ -2041,6 +2041,10 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
>> .action = DAMOS_NOHUGEPAGE,
>> .name = "nohugepage",
>> },
>> + {
>> + .action = DAMOS_COLLAPSE,
>> + .name = "collapse",
>> + },
>> {
>> .action = DAMOS_LRU_PRIO,
>> .name = "lru_prio",
>> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
>> index b069dbc7e3d2..dd5f2d7027ac 100644
>> --- a/mm/damon/vaddr.c
>> +++ b/mm/damon/vaddr.c
>> @@ -903,6 +903,9 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx,
>> case DAMOS_NOHUGEPAGE:
>> madv_action = MADV_NOHUGEPAGE;
>> break;
>> + case DAMOS_COLLAPSE:
>> + madv_action = MADV_COLLAPSE;
>> + break;
>> case DAMOS_MIGRATE_HOT:
>> case DAMOS_MIGRATE_COLD:
>> return damos_va_migrate(t, r, scheme, sz_filter_passed);
>> diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
>> index 3aa5c91548a5..c6476e63f4fb 100755
>> --- a/tools/testing/selftests/damon/sysfs.py
>> +++ b/tools/testing/selftests/damon/sysfs.py
>> @@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
>> 'pageout': 2,
>> 'hugepage': 3,
>> 'nohugeapge': 4,
>> - 'lru_prio': 5,
>> - 'lru_deprio': 6,
>> - 'migrate_hot': 7,
>> - 'migrate_cold': 8,
>> - 'stat': 9,
>> + 'collapse': 5
>
> Comman is missed?
>
>> + 'lru_prio': 6,
>> + 'lru_deprio': 7,
>> + 'migrate_hot': 8,
>> + 'migrate_cold': 9,
>> + 'stat': 10,
>> }
>> assert_true(dump['action'] == action_val[scheme.action], 'action', dump)
>> assert_true(dump['apply_interval_us'] == scheme. apply_interval_us,
>> --
>> 2.43.0
>
> Other than the selftest part, code looks good. Please consider dropping RFC
> tag from the next spin. Clarifying more details about the test would be
> helpful, though.
>
> [1] https://docs.kernel.org/process/submitting-patches.html#commentary
>
>
> Thanks,
> SJ
>
SJ, should I remove the RFC tag for the next version?
--
Asier Gutierrez
Huawei
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE.
2026-03-24 13:57 ` Gutierrez Asier
@ 2026-03-24 14:12 ` SeongJae Park
2026-03-24 15:01 ` Gutierrez Asier
0 siblings, 1 reply; 15+ messages in thread
From: SeongJae Park @ 2026-03-24 14:12 UTC (permalink / raw)
To: Gutierrez Asier
Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
On Tue, 24 Mar 2026 16:57:22 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote:
>
>
> On 3/24/2026 3:39 AM, SeongJae Park wrote:
> > Hello Asier,
> >
> > On Mon, 23 Mar 2026 14:56:45 +0000 <gutierrez.asier@huawei-partners.com> wrote:
> >
> >> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
> >>
> >> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
> >> working, since it relies on hugepage_madvise to add a new slot. This
> >> slot should be picked up by khugepaged and eventually collapse (or
> >> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
> >> enabled, khugepaged will not be working, and therefore no collapse
> >> will happen.
> >>
> >> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
> >> the address range synchronously.
> >>
> >> This new action may be required to support autotuning with hugepage as
> >> a goal[1].
> >>
> >> [1]: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
> >>
> >> ---------
> >> Benchmarks:
> >>
> >> T n: THP never
> >> T m: THP madvise
> >> D h: DAMON action hugepage
> >> D c: DAMON action collapse
> >>
> >> +------------------+----------+----------+----------+
> >> | | T n, D h | T m, D h | T n, D c |
> >> +------------------+----------+----------+----------+
> >> | Total memory use | 2.07 | 2.09 | 2.07 |
> >> | Huge pages | 0 | 1.3 | 1.25 |
> >> +------------------+----------+----------+----------+
> >
> > Thank you for sharing the benchmark results! But, I'm having a hard time to
> > understand what this really means. Could you please further clarify the setup
> > of the benchmarks and interpretation of the results?
> I will fix the cover in the next version, which I will submit soon.
>
> I tested the patch in a physical server with MariaDB 10.5. I run
> sysbench to load the server.
>
> I check 3 scenarios:
> - DAMON action hugepage for the database task, THP as never
> - DAMON action hugepage, THP madvise
> - DAMON action collapse, THP never
>
> I compared the memory consumption, both in overall in the server and
> anonymous huge page consumption. The results are in the table
>
> T n: THP never
> T m: THP madvise
> D h: DAMON action hugepage
> D c: DAMON action collapse
Thank you for sharing the details of the setup, Asier.
>
> +------------------+----------+----------+----------+
> | | T n, D h | T m, D h | T n, D c |
> +------------------+----------+----------+----------+
> | Total memory use | 2.07 | 2.09 | 2.07 |
> | Huge pages | 0 | 1.3 | 1.25 |
> +------------------+----------+----------+----------+
Could you please further share interpretation of the results? What these
results mean? Does it show some benefit of DAMOS_COLLAPSE?
Also, how is the performance? Does it show some difference?
> >
> >>
> >> Changes
> >> ---------
> >> v1-v2:
> >> Added benchmarks
> >> Added damos_filter_type documentation for new action to fix kernel-doc
> >
> > Please add Changelog on the commentary section [1]. Also, please consider
> > adding links to previous versions.
> >
> >>
> >> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
> >> ---
> >> Documentation/mm/damon/design.rst | 4 ++++
> >> include/linux/damon.h | 2 ++
> >> mm/damon/sysfs-schemes.c | 4 ++++
> >> mm/damon/vaddr.c | 3 +++
> >> tools/testing/selftests/damon/sysfs.py | 11 ++++++-----
> >> 5 files changed, 19 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
> >> index 838b14d22519..405142641e55 100644
> >> --- a/Documentation/mm/damon/design.rst
> >> +++ b/Documentation/mm/damon/design.rst
> >> @@ -467,6 +467,10 @@ that supports each action are as below.
> >> Supported by ``vaddr`` and ``fvaddr`` operations set. When
> >> TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
> >> fail.
> >> + - ``collapse``: Call ``madvise()`` for the region with ``MADV_COLLAPSE``.
> >> + Supported by ``vaddr`` and ``fvaddr`` operations set. When
> >> + TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
> >> + fail.
> >> - ``lru_prio``: Prioritize the region on its LRU lists.
> >> Supported by ``paddr`` operations set.
> >> - ``lru_deprio``: Deprioritize the region on its LRU lists.
> >> diff --git a/include/linux/damon.h b/include/linux/damon.h
> >> index d9a3babbafc1..6941113968ec 100644
> >> --- a/include/linux/damon.h
> >> +++ b/include/linux/damon.h
> >> @@ -121,6 +121,7 @@ struct damon_target {
> >> * @DAMOS_PAGEOUT: Reclaim the region.
> >> * @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE.
> >> * @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE.
> >> + * @DAMOS_COLLAPSE: Call ``madvise()`` for the region with MADV_COLLAPSE.
> >> * @DAMOS_LRU_PRIO: Prioritize the region on its LRU lists.
> >> * @DAMOS_LRU_DEPRIO: Deprioritize the region on its LRU lists.
> >> * @DAMOS_MIGRATE_HOT: Migrate the regions prioritizing warmer regions.
> >> @@ -140,6 +141,7 @@ enum damos_action {
> >> DAMOS_PAGEOUT,
> >> DAMOS_HUGEPAGE,
> >> DAMOS_NOHUGEPAGE,
> >> + DAMOS_COLLAPSE,
> >> DAMOS_LRU_PRIO,
> >> DAMOS_LRU_DEPRIO,
> >> DAMOS_MIGRATE_HOT,
> >> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> >> index 5186966dafb3..aa08a8f885fb 100644
> >> --- a/mm/damon/sysfs-schemes.c
> >> +++ b/mm/damon/sysfs-schemes.c
> >> @@ -2041,6 +2041,10 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
> >> .action = DAMOS_NOHUGEPAGE,
> >> .name = "nohugepage",
> >> },
> >> + {
> >> + .action = DAMOS_COLLAPSE,
> >> + .name = "collapse",
> >> + },
> >> {
> >> .action = DAMOS_LRU_PRIO,
> >> .name = "lru_prio",
> >> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> >> index b069dbc7e3d2..dd5f2d7027ac 100644
> >> --- a/mm/damon/vaddr.c
> >> +++ b/mm/damon/vaddr.c
> >> @@ -903,6 +903,9 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx,
> >> case DAMOS_NOHUGEPAGE:
> >> madv_action = MADV_NOHUGEPAGE;
> >> break;
> >> + case DAMOS_COLLAPSE:
> >> + madv_action = MADV_COLLAPSE;
> >> + break;
> >> case DAMOS_MIGRATE_HOT:
> >> case DAMOS_MIGRATE_COLD:
> >> return damos_va_migrate(t, r, scheme, sz_filter_passed);
> >> diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
> >> index 3aa5c91548a5..c6476e63f4fb 100755
> >> --- a/tools/testing/selftests/damon/sysfs.py
> >> +++ b/tools/testing/selftests/damon/sysfs.py
> >> @@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
> >> 'pageout': 2,
> >> 'hugepage': 3,
> >> 'nohugeapge': 4,
> >> - 'lru_prio': 5,
> >> - 'lru_deprio': 6,
> >> - 'migrate_hot': 7,
> >> - 'migrate_cold': 8,
> >> - 'stat': 9,
> >> + 'collapse': 5
> >
> > Comman is missed?
> >
> >> + 'lru_prio': 6,
> >> + 'lru_deprio': 7,
> >> + 'migrate_hot': 8,
> >> + 'migrate_cold': 9,
> >> + 'stat': 10,
> >> }
> >> assert_true(dump['action'] == action_val[scheme.action], 'action', dump)
> >> assert_true(dump['apply_interval_us'] == scheme. apply_interval_us,
> >> --
> >> 2.43.0
> >
> > Other than the selftest part, code looks good. Please consider dropping RFC
> > tag from the next spin. Clarifying more details about the test would be
> > helpful, though.
> >
> > [1] https://docs.kernel.org/process/submitting-patches.html#commentary
> >
> >
> > Thanks,
> > SJ
> >
>
> SJ, should I remove the RFC tag for the next version?
If you feel comfortable with it, please do so.
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE.
2026-03-24 14:12 ` SeongJae Park
@ 2026-03-24 15:01 ` Gutierrez Asier
2026-03-25 1:29 ` SeongJae Park
0 siblings, 1 reply; 15+ messages in thread
From: Gutierrez Asier @ 2026-03-24 15:01 UTC (permalink / raw)
To: SeongJae Park
Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1,
zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka, rppt, surenb,
mhocko, corbet, skhan, linux-doc, linux-mm, linux-kernel
On 3/24/2026 5:12 PM, SeongJae Park wrote:
> On Tue, 24 Mar 2026 16:57:22 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote:
>
>>
>>
>> On 3/24/2026 3:39 AM, SeongJae Park wrote:
>>> Hello Asier,
>>>
>>> On Mon, 23 Mar 2026 14:56:45 +0000 <gutierrez.asier@huawei-partners.com> wrote:
>>>
>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>>>>
>>>> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
>>>> working, since it relies on hugepage_madvise to add a new slot. This
>>>> slot should be picked up by khugepaged and eventually collapse (or
>>>> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
>>>> enabled, khugepaged will not be working, and therefore no collapse
>>>> will happen.
>>>>
>>>> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
>>>> the address range synchronously.
>>>>
>>>> This new action may be required to support autotuning with hugepage as
>>>> a goal[1].
>>>>
>>>> [1]: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
>>>>
>>>> ---------
>>>> Benchmarks:
>>>>
>>>> T n: THP never
>>>> T m: THP madvise
>>>> D h: DAMON action hugepage
>>>> D c: DAMON action collapse
>>>>
>>>> +------------------+----------+----------+----------+
>>>> | | T n, D h | T m, D h | T n, D c |
>>>> +------------------+----------+----------+----------+
>>>> | Total memory use | 2.07 | 2.09 | 2.07 |
>>>> | Huge pages | 0 | 1.3 | 1.25 |
>>>> +------------------+----------+----------+----------+
>>>
>>> Thank you for sharing the benchmark results! But, I'm having a hard time to
>>> understand what this really means. Could you please further clarify the setup
>>> of the benchmarks and interpretation of the results?
>> I will fix the cover in the next version, which I will submit soon.
>>
>> I tested the patch in a physical server with MariaDB 10.5. I run
>> sysbench to load the server.
>>
>> I check 3 scenarios:
>> - DAMON action hugepage for the database task, THP as never
>> - DAMON action hugepage, THP madvise
>> - DAMON action collapse, THP never
>>
>> I compared the memory consumption, both in overall in the server and
>> anonymous huge page consumption. The results are in the table
>>
>> T n: THP never
>> T m: THP madvise
>> D h: DAMON action hugepage
>> D c: DAMON action collapse
>
> Thank you for sharing the details of the setup, Asier.
>
>>
>> +------------------+----------+----------+----------+
>> | | T n, D h | T m, D h | T n, D c |
>> +------------------+----------+----------+----------+
>> | Total memory use | 2.07 | 2.09 | 2.07 |
>> | Huge pages | 0 | 1.3 | 1.25 |
>> +------------------+----------+----------+----------+
>
> Could you please further share interpretation of the results? What these
> results mean? Does it show some benefit of DAMOS_COLLAPSE?
In the first row is the total memory consumption in GB by the server
and in the second row the huge page consumption.
What this table shows is that DAMON action "hugepage" doesn't lead
to any hugepage collapse unless THP is set to madvise. If DAMON
action is set to "collapse", hugepage collapses happen, even when
THP is disabled. The memory consumption for DAMON "collapse" is
slightly lower than with "hugepage", since madvise applies to the
entire server and other application may request to collapse pages
through madvise.
Regarding the performance, I saw improvement from no hugepage at all
to use of hugepages. No significant difference between "hugepage" and
"collapse" actions. I will have a look to the logs and publish it a bit
later.
> Also, how is the performance? Does it show some difference?
>
>>>
>>>>
>>>> Changes
>>>> ---------
>>>> v1-v2:
>>>> Added benchmarks
>>>> Added damos_filter_type documentation for new action to fix kernel-doc
>>>
>>> Please add Changelog on the commentary section [1]. Also, please consider
>>> adding links to previous versions.
>>>
>>>>
>>>> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>>>> ---
>>>> Documentation/mm/damon/design.rst | 4 ++++
>>>> include/linux/damon.h | 2 ++
>>>> mm/damon/sysfs-schemes.c | 4 ++++
>>>> mm/damon/vaddr.c | 3 +++
>>>> tools/testing/selftests/damon/sysfs.py | 11 ++++++-----
>>>> 5 files changed, 19 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
>>>> index 838b14d22519..405142641e55 100644
>>>> --- a/Documentation/mm/damon/design.rst
>>>> +++ b/Documentation/mm/damon/design.rst
>>>> @@ -467,6 +467,10 @@ that supports each action are as below.
>>>> Supported by ``vaddr`` and ``fvaddr`` operations set. When
>>>> TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
>>>> fail.
>>>> + - ``collapse``: Call ``madvise()`` for the region with ``MADV_COLLAPSE``.
>>>> + Supported by ``vaddr`` and ``fvaddr`` operations set. When
>>>> + TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
>>>> + fail.
>>>> - ``lru_prio``: Prioritize the region on its LRU lists.
>>>> Supported by ``paddr`` operations set.
>>>> - ``lru_deprio``: Deprioritize the region on its LRU lists.
>>>> diff --git a/include/linux/damon.h b/include/linux/damon.h
>>>> index d9a3babbafc1..6941113968ec 100644
>>>> --- a/include/linux/damon.h
>>>> +++ b/include/linux/damon.h
>>>> @@ -121,6 +121,7 @@ struct damon_target {
>>>> * @DAMOS_PAGEOUT: Reclaim the region.
>>>> * @DAMOS_HUGEPAGE: Call ``madvise()`` for the region with MADV_HUGEPAGE.
>>>> * @DAMOS_NOHUGEPAGE: Call ``madvise()`` for the region with MADV_NOHUGEPAGE.
>>>> + * @DAMOS_COLLAPSE: Call ``madvise()`` for the region with MADV_COLLAPSE.
>>>> * @DAMOS_LRU_PRIO: Prioritize the region on its LRU lists.
>>>> * @DAMOS_LRU_DEPRIO: Deprioritize the region on its LRU lists.
>>>> * @DAMOS_MIGRATE_HOT: Migrate the regions prioritizing warmer regions.
>>>> @@ -140,6 +141,7 @@ enum damos_action {
>>>> DAMOS_PAGEOUT,
>>>> DAMOS_HUGEPAGE,
>>>> DAMOS_NOHUGEPAGE,
>>>> + DAMOS_COLLAPSE,
>>>> DAMOS_LRU_PRIO,
>>>> DAMOS_LRU_DEPRIO,
>>>> DAMOS_MIGRATE_HOT,
>>>> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
>>>> index 5186966dafb3..aa08a8f885fb 100644
>>>> --- a/mm/damon/sysfs-schemes.c
>>>> +++ b/mm/damon/sysfs-schemes.c
>>>> @@ -2041,6 +2041,10 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
>>>> .action = DAMOS_NOHUGEPAGE,
>>>> .name = "nohugepage",
>>>> },
>>>> + {
>>>> + .action = DAMOS_COLLAPSE,
>>>> + .name = "collapse",
>>>> + },
>>>> {
>>>> .action = DAMOS_LRU_PRIO,
>>>> .name = "lru_prio",
>>>> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
>>>> index b069dbc7e3d2..dd5f2d7027ac 100644
>>>> --- a/mm/damon/vaddr.c
>>>> +++ b/mm/damon/vaddr.c
>>>> @@ -903,6 +903,9 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx,
>>>> case DAMOS_NOHUGEPAGE:
>>>> madv_action = MADV_NOHUGEPAGE;
>>>> break;
>>>> + case DAMOS_COLLAPSE:
>>>> + madv_action = MADV_COLLAPSE;
>>>> + break;
>>>> case DAMOS_MIGRATE_HOT:
>>>> case DAMOS_MIGRATE_COLD:
>>>> return damos_va_migrate(t, r, scheme, sz_filter_passed);
>>>> diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
>>>> index 3aa5c91548a5..c6476e63f4fb 100755
>>>> --- a/tools/testing/selftests/damon/sysfs.py
>>>> +++ b/tools/testing/selftests/damon/sysfs.py
>>>> @@ -123,11 +123,12 @@ def assert_scheme_committed(scheme, dump):
>>>> 'pageout': 2,
>>>> 'hugepage': 3,
>>>> 'nohugeapge': 4,
>>>> - 'lru_prio': 5,
>>>> - 'lru_deprio': 6,
>>>> - 'migrate_hot': 7,
>>>> - 'migrate_cold': 8,
>>>> - 'stat': 9,
>>>> + 'collapse': 5
>>>
>>> Comman is missed?
>>>
>>>> + 'lru_prio': 6,
>>>> + 'lru_deprio': 7,
>>>> + 'migrate_hot': 8,
>>>> + 'migrate_cold': 9,
>>>> + 'stat': 10,
>>>> }
>>>> assert_true(dump['action'] == action_val[scheme.action], 'action', dump)
>>>> assert_true(dump['apply_interval_us'] == scheme. apply_interval_us,
>>>> --
>>>> 2.43.0
>>>
>>> Other than the selftest part, code looks good. Please consider dropping RFC
>>> tag from the next spin. Clarifying more details about the test would be
>>> helpful, though.
>>>
>>> [1] https://docs.kernel.org/process/submitting-patches.html#commentary
>>>
>>>
>>> Thanks,
>>> SJ
>>>
>>
>> SJ, should I remove the RFC tag for the next version?
>
> If you feel comfortable with it, please do so.
>
>
> Thanks,
> SJ
>
> [...]
>
--
Asier Gutierrez
Huawei
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE.
2026-03-24 15:01 ` Gutierrez Asier
@ 2026-03-25 1:29 ` SeongJae Park
0 siblings, 0 replies; 15+ messages in thread
From: SeongJae Park @ 2026-03-25 1:29 UTC (permalink / raw)
To: Gutierrez Asier
Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
On Tue, 24 Mar 2026 18:01:23 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote:
>
>
> On 3/24/2026 5:12 PM, SeongJae Park wrote:
> > On Tue, 24 Mar 2026 16:57:22 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote:
> >
> >>
> >>
> >> On 3/24/2026 3:39 AM, SeongJae Park wrote:
> >>> Hello Asier,
> >>>
> >>> On Mon, 23 Mar 2026 14:56:45 +0000 <gutierrez.asier@huawei-partners.com> wrote:
> >>>
> >>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
> >>>>
> >>>> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
> >>>> working, since it relies on hugepage_madvise to add a new slot. This
> >>>> slot should be picked up by khugepaged and eventually collapse (or
> >>>> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
> >>>> enabled, khugepaged will not be working, and therefore no collapse
> >>>> will happen.
> >>>>
> >>>> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
> >>>> the address range synchronously.
> >>>>
> >>>> This new action may be required to support autotuning with hugepage as
> >>>> a goal[1].
> >>>>
> >>>> [1]: https://lore.kernel.org/damon/20260313000816.79933-1-sj@kernel.org/
> >>>>
> >>>> ---------
> >>>> Benchmarks:
> >>>>
> >>>> T n: THP never
> >>>> T m: THP madvise
> >>>> D h: DAMON action hugepage
> >>>> D c: DAMON action collapse
> >>>>
> >>>> +------------------+----------+----------+----------+
> >>>> | | T n, D h | T m, D h | T n, D c |
> >>>> +------------------+----------+----------+----------+
> >>>> | Total memory use | 2.07 | 2.09 | 2.07 |
> >>>> | Huge pages | 0 | 1.3 | 1.25 |
> >>>> +------------------+----------+----------+----------+
> >>>
> >>> Thank you for sharing the benchmark results! But, I'm having a hard time to
> >>> understand what this really means. Could you please further clarify the setup
> >>> of the benchmarks and interpretation of the results?
> >> I will fix the cover in the next version, which I will submit soon.
> >>
> >> I tested the patch in a physical server with MariaDB 10.5. I run
> >> sysbench to load the server.
> >>
> >> I check 3 scenarios:
> >> - DAMON action hugepage for the database task, THP as never
> >> - DAMON action hugepage, THP madvise
> >> - DAMON action collapse, THP never
> >>
> >> I compared the memory consumption, both in overall in the server and
> >> anonymous huge page consumption. The results are in the table
> >>
> >> T n: THP never
> >> T m: THP madvise
> >> D h: DAMON action hugepage
> >> D c: DAMON action collapse
> >
> > Thank you for sharing the details of the setup, Asier.
> >
> >>
> >> +------------------+----------+----------+----------+
> >> | | T n, D h | T m, D h | T n, D c |
> >> +------------------+----------+----------+----------+
> >> | Total memory use | 2.07 | 2.09 | 2.07 |
> >> | Huge pages | 0 | 1.3 | 1.25 |
> >> +------------------+----------+----------+----------+
> >
> > Could you please further share interpretation of the results? What these
> > results mean? Does it show some benefit of DAMOS_COLLAPSE?
>
> In the first row is the total memory consumption in GB by the server
> and in the second row the huge page consumption.
>
> What this table shows is that DAMON action "hugepage" doesn't lead
> to any hugepage collapse unless THP is set to madvise. If DAMON
> action is set to "collapse", hugepage collapses happen, even when
> THP is disabled. The memory consumption for DAMON "collapse" is
> slightly lower than with "hugepage", since madvise applies to the
> entire server and other application may request to collapse pages
> through madvise.
>
> Regarding the performance, I saw improvement from no hugepage at all
> to use of hugepages. No significant difference between "hugepage" and
> "collapse" actions. I will have a look to the logs and publish it a bit
> later.
Makes sense, thank you for clarification Asier!
So this result shows the functionality well. Meanwhile, it doesn't clearly
show performance gain. Given the small size of the change and rationale of
MADV_COLLAPSE that I believe explored when it was introduced, I think this test
result is also good. I wouldn't strongly require more tests for this patch.
That said, if you find some more interesting thing from logs, please share, by
or after the next version of this patch.
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
2026-03-18 0:52 ` SeongJae Park
@ 2026-03-18 14:41 ` Gutierrez Asier
0 siblings, 0 replies; 15+ messages in thread
From: Gutierrez Asier @ 2026-03-18 14:41 UTC (permalink / raw)
To: SeongJae Park
Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1,
zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka, rppt, surenb,
mhocko, corbet, skhan, linux-doc, linux-mm, linux-kernel
On 3/18/2026 3:52 AM, SeongJae Park wrote:
> On Tue, 17 Mar 2026 09:52:09 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote:
>
>> Hi SJ,
>>
>> First of all, I just noticed that this was sent as v2 RFC, while
>> it should be v1. Bear in mind that the next series will also be
>> v2.
>
> No worry :)
>
>>
>> On 3/17/2026 3:32 AM, SeongJae Park wrote:
>>> Hello Asier,
>>>
>>> On Mon, 16 Mar 2026 18:38:05 +0000 <gutierrez.asier@huawei-partners.com> wrote:
>>>
>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>>>>
>>>> This patch set introces a new action: DAMOS_COLLAPSE.
>>>>
>>>> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
>>>> working, since it relies on hugepage_madvise to add a new slot. This
>>>> slot should be picked up by khugepaged and eventually collapse (or
>>>> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
>>>> enabled, khugepaged will not be working, and therefore no collapse
>>>> will happen.
>>>>
>>>> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
>>>> the address range synchronously.
>>>>
>>>> This new action may be required to support autotuning with hugepage as
>>>> a goal.
>>>
>>> Above all makes sense. Thank you for posting this patch.
>>>
>>> Do you have some test results that you can also share together? It would be
>>> nice if it can demonstrate the benefit of DAMOS_COLLAPSE over DAMOS_HUGEPAGE.
>> I will run some tests and benchmarks.
>
> Looking forward to.
>
>>>
>>>>
>>>> [1] https://lore.kernel.org/lkml/20260314165156.86647-1-sj@kernel.org/
>>>
>>> Seems the above link is just added by a mistake? If not, please clarify.
>> Yes, it looks like I copied the wrong link.
>>>>
>>>> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>>>> Reviewed-by: SeongJae Park <sj@kernel.org>
>>>> ---
>>>> Documentation/mm/damon/design.rst | 4 ++++
>>>> include/linux/damon.h | 1 +
>>>> mm/damon/sysfs-schemes.c | 4 ++++
>>>> mm/damon/vaddr.c | 3 +++
>>>> 4 files changed, 12 insertions(+)
>>> [...]
>>>> diff --git a/include/linux/damon.h b/include/linux/damon.h
>>>> index 3a441fbca170..6720dc70c487 100644
>>>> --- a/include/linux/damon.h
>>>> +++ b/include/linux/damon.h
>>>> @@ -140,6 +140,7 @@ enum damos_action {
>>>> DAMOS_PAGEOUT,
>>>> DAMOS_HUGEPAGE,
>>>> DAMOS_NOHUGEPAGE,
>>>> + DAMOS_COLLAPSE,
>>>> DAMOS_LRU_PRIO,
>>>> DAMOS_LRU_DEPRIO,
>>>> DAMOS_MIGRATE_HOT,
>>>
>>> sashiko.dev adds [1] below comments. Let me also add my comments in line.
>>>
>>> : This isn't a bug, but should a kernel-doc entry for @DAMOS_COLLAPSE be added
>>> : to the comment block above this enum?
>>>
>>> Makes sense. 'make htmldocs' may complain otherwise. Asier, could you please
>>> add the kernel-doc comment for DAMOS_COLLAPSE in the next spin?
>> OK, I will split this patch into 2: one with the code and the other one with
>> the documentation.
>
> Does the 'documentation' mean the change for 'design.rst'? Or, the kernel-doc
> comment? If that's the former case (separating 'design.rst' side change as
> another patch), that's completely good for me.
I meant the doc/mm/damon/design.rst
>
> If that's the latter case (separating kernel-doc comment addition as another
> patch), that will make the commit trigger document build error, and the error
> will be fixed only after the followup commit is applied. Please ensure keeping
> 'damon.h' side changes as a single patch, and therefore no warning or breaks in
> the middle of the patch series is introduced (and later fixed).
>
>>> :
>>> : Also, does inserting DAMOS_COLLAPSE here shift the integer values of the
>>> : subsequent enum entries like DAMOS_STAT?
>>> :
>>> : The DAMON sysfs selftest script (tools/testing/selftests/damon/sysfs.py) uses
>>> : a hardcoded dictionary action_val to map string names to their integer enum
>>> : values.
>>> :
>>> : If the enum values shift, the test's assertion:
>>> :
>>> : assert_true(dump['action'] == action_val[scheme.action])
>>> :
>>> : might fail when checking the struct memory via drgn. Could the python test
>>> : dictionary be updated to reflect the new values, or could the new action be
>>> : added at the end of the enum list?
>>>
>>> There is no test that uses DAMOS actions that defined after DAMOS_NOHUGEPAGE,
>>> so no real test will break. But this is a good point. It would be better to
>>> update the hard-coded value together. Asier, could you also update the
>>> 'action_val' dict of assert_scheme_committed() function in
>>> tools/testing/selftets/damon/sysfs.py for the updated enum value in the next
>>> version?
>> OK, I will do it.
>
> Thank you :)
>
>>>
>>> [1] https://sashiko.dev/#/patchset/20260316183805.2090297-1-gutierrez.asier@huawei-partners.com
>>>
>>>
>>> Thanks,
>>> SJ
>>>
>>> [...]
>>>
>> Thanks for the feedback.
>
> My pleasure.
>
>
> Thanks,
> SJ
>
> [...]
>
--
Asier Gutierrez
Huawei
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
2026-03-17 6:52 ` Gutierrez Asier
@ 2026-03-18 0:52 ` SeongJae Park
2026-03-18 14:41 ` Gutierrez Asier
0 siblings, 1 reply; 15+ messages in thread
From: SeongJae Park @ 2026-03-18 0:52 UTC (permalink / raw)
To: Gutierrez Asier
Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
On Tue, 17 Mar 2026 09:52:09 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote:
> Hi SJ,
>
> First of all, I just noticed that this was sent as v2 RFC, while
> it should be v1. Bear in mind that the next series will also be
> v2.
No worry :)
>
> On 3/17/2026 3:32 AM, SeongJae Park wrote:
> > Hello Asier,
> >
> > On Mon, 16 Mar 2026 18:38:05 +0000 <gutierrez.asier@huawei-partners.com> wrote:
> >
> >> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
> >>
> >> This patch set introces a new action: DAMOS_COLLAPSE.
> >>
> >> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
> >> working, since it relies on hugepage_madvise to add a new slot. This
> >> slot should be picked up by khugepaged and eventually collapse (or
> >> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
> >> enabled, khugepaged will not be working, and therefore no collapse
> >> will happen.
> >>
> >> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
> >> the address range synchronously.
> >>
> >> This new action may be required to support autotuning with hugepage as
> >> a goal.
> >
> > Above all makes sense. Thank you for posting this patch.
> >
> > Do you have some test results that you can also share together? It would be
> > nice if it can demonstrate the benefit of DAMOS_COLLAPSE over DAMOS_HUGEPAGE.
> I will run some tests and benchmarks.
Looking forward to.
> >
> >>
> >> [1] https://lore.kernel.org/lkml/20260314165156.86647-1-sj@kernel.org/
> >
> > Seems the above link is just added by a mistake? If not, please clarify.
> Yes, it looks like I copied the wrong link.
> >>
> >> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
> >> Reviewed-by: SeongJae Park <sj@kernel.org>
> >> ---
> >> Documentation/mm/damon/design.rst | 4 ++++
> >> include/linux/damon.h | 1 +
> >> mm/damon/sysfs-schemes.c | 4 ++++
> >> mm/damon/vaddr.c | 3 +++
> >> 4 files changed, 12 insertions(+)
> > [...]
> >> diff --git a/include/linux/damon.h b/include/linux/damon.h
> >> index 3a441fbca170..6720dc70c487 100644
> >> --- a/include/linux/damon.h
> >> +++ b/include/linux/damon.h
> >> @@ -140,6 +140,7 @@ enum damos_action {
> >> DAMOS_PAGEOUT,
> >> DAMOS_HUGEPAGE,
> >> DAMOS_NOHUGEPAGE,
> >> + DAMOS_COLLAPSE,
> >> DAMOS_LRU_PRIO,
> >> DAMOS_LRU_DEPRIO,
> >> DAMOS_MIGRATE_HOT,
> >
> > sashiko.dev adds [1] below comments. Let me also add my comments in line.
> >
> > : This isn't a bug, but should a kernel-doc entry for @DAMOS_COLLAPSE be added
> > : to the comment block above this enum?
> >
> > Makes sense. 'make htmldocs' may complain otherwise. Asier, could you please
> > add the kernel-doc comment for DAMOS_COLLAPSE in the next spin?
> OK, I will split this patch into 2: one with the code and the other one with
> the documentation.
Does the 'documentation' mean the change for 'design.rst'? Or, the kernel-doc
comment? If that's the former case (separating 'design.rst' side change as
another patch), that's completely good for me.
If that's the latter case (separating kernel-doc comment addition as another
patch), that will make the commit trigger document build error, and the error
will be fixed only after the followup commit is applied. Please ensure keeping
'damon.h' side changes as a single patch, and therefore no warning or breaks in
the middle of the patch series is introduced (and later fixed).
> > :
> > : Also, does inserting DAMOS_COLLAPSE here shift the integer values of the
> > : subsequent enum entries like DAMOS_STAT?
> > :
> > : The DAMON sysfs selftest script (tools/testing/selftests/damon/sysfs.py) uses
> > : a hardcoded dictionary action_val to map string names to their integer enum
> > : values.
> > :
> > : If the enum values shift, the test's assertion:
> > :
> > : assert_true(dump['action'] == action_val[scheme.action])
> > :
> > : might fail when checking the struct memory via drgn. Could the python test
> > : dictionary be updated to reflect the new values, or could the new action be
> > : added at the end of the enum list?
> >
> > There is no test that uses DAMOS actions that defined after DAMOS_NOHUGEPAGE,
> > so no real test will break. But this is a good point. It would be better to
> > update the hard-coded value together. Asier, could you also update the
> > 'action_val' dict of assert_scheme_committed() function in
> > tools/testing/selftets/damon/sysfs.py for the updated enum value in the next
> > version?
> OK, I will do it.
Thank you :)
> >
> > [1] https://sashiko.dev/#/patchset/20260316183805.2090297-1-gutierrez.asier@huawei-partners.com
> >
> >
> > Thanks,
> > SJ
> >
> > [...]
> >
> Thanks for the feedback.
My pleasure.
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
2026-03-17 0:32 ` SeongJae Park
@ 2026-03-17 6:52 ` Gutierrez Asier
2026-03-18 0:52 ` SeongJae Park
0 siblings, 1 reply; 15+ messages in thread
From: Gutierrez Asier @ 2026-03-17 6:52 UTC (permalink / raw)
To: SeongJae Park
Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1,
zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka, rppt, surenb,
mhocko, corbet, skhan, linux-doc, linux-mm, linux-kernel
Hi SJ,
First of all, I just noticed that this was sent as v2 RFC, while
it should be v1. Bear in mind that the next series will also be
v2.
On 3/17/2026 3:32 AM, SeongJae Park wrote:
> Hello Asier,
>
> On Mon, 16 Mar 2026 18:38:05 +0000 <gutierrez.asier@huawei-partners.com> wrote:
>
>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>>
>> This patch set introces a new action: DAMOS_COLLAPSE.
>>
>> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
>> working, since it relies on hugepage_madvise to add a new slot. This
>> slot should be picked up by khugepaged and eventually collapse (or
>> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
>> enabled, khugepaged will not be working, and therefore no collapse
>> will happen.
>>
>> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
>> the address range synchronously.
>>
>> This new action may be required to support autotuning with hugepage as
>> a goal.
>
> Above all makes sense. Thank you for posting this patch.
>
> Do you have some test results that you can also share together? It would be
> nice if it can demonstrate the benefit of DAMOS_COLLAPSE over DAMOS_HUGEPAGE.
I will run some tests and benchmarks.
>
>>
>> [1] https://lore.kernel.org/lkml/20260314165156.86647-1-sj@kernel.org/
>
> Seems the above link is just added by a mistake? If not, please clarify.
Yes, it looks like I copied the wrong link.
>>
>> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>> Reviewed-by: SeongJae Park <sj@kernel.org>
>> ---
>> Documentation/mm/damon/design.rst | 4 ++++
>> include/linux/damon.h | 1 +
>> mm/damon/sysfs-schemes.c | 4 ++++
>> mm/damon/vaddr.c | 3 +++
>> 4 files changed, 12 insertions(+)
> [...]
>> diff --git a/include/linux/damon.h b/include/linux/damon.h
>> index 3a441fbca170..6720dc70c487 100644
>> --- a/include/linux/damon.h
>> +++ b/include/linux/damon.h
>> @@ -140,6 +140,7 @@ enum damos_action {
>> DAMOS_PAGEOUT,
>> DAMOS_HUGEPAGE,
>> DAMOS_NOHUGEPAGE,
>> + DAMOS_COLLAPSE,
>> DAMOS_LRU_PRIO,
>> DAMOS_LRU_DEPRIO,
>> DAMOS_MIGRATE_HOT,
>
> sashiko.dev adds [1] below comments. Let me also add my comments in line.
>
> : This isn't a bug, but should a kernel-doc entry for @DAMOS_COLLAPSE be added
> : to the comment block above this enum?
>
> Makes sense. 'make htmldocs' may complain otherwise. Asier, could you please
> add the kernel-doc comment for DAMOS_COLLAPSE in the next spin?
OK, I will split this patch into 2: one with the code and the other one with
the documentation.
> :
> : Also, does inserting DAMOS_COLLAPSE here shift the integer values of the
> : subsequent enum entries like DAMOS_STAT?
> :
> : The DAMON sysfs selftest script (tools/testing/selftests/damon/sysfs.py) uses
> : a hardcoded dictionary action_val to map string names to their integer enum
> : values.
> :
> : If the enum values shift, the test's assertion:
> :
> : assert_true(dump['action'] == action_val[scheme.action])
> :
> : might fail when checking the struct memory via drgn. Could the python test
> : dictionary be updated to reflect the new values, or could the new action be
> : added at the end of the enum list?
>
> There is no test that uses DAMOS actions that defined after DAMOS_NOHUGEPAGE,
> so no real test will break. But this is a good point. It would be better to
> update the hard-coded value together. Asier, could you also update the
> 'action_val' dict of assert_scheme_committed() function in
> tools/testing/selftets/damon/sysfs.py for the updated enum value in the next
> version?
OK, I will do it.
>
> [1] https://sashiko.dev/#/patchset/20260316183805.2090297-1-gutierrez.asier@huawei-partners.com
>
>
> Thanks,
> SJ
>
> [...]
>
Thanks for the feedback.
--
Asier Gutierrez
Huawei
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
2026-03-16 18:38 [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action gutierrez.asier
@ 2026-03-17 0:32 ` SeongJae Park
2026-03-17 6:52 ` Gutierrez Asier
0 siblings, 1 reply; 15+ messages in thread
From: SeongJae Park @ 2026-03-17 0:32 UTC (permalink / raw)
To: gutierrez.asier
Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
Hello Asier,
On Mon, 16 Mar 2026 18:38:05 +0000 <gutierrez.asier@huawei-partners.com> wrote:
> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>
> This patch set introces a new action: DAMOS_COLLAPSE.
>
> For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
> working, since it relies on hugepage_madvise to add a new slot. This
> slot should be picked up by khugepaged and eventually collapse (or
> not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
> enabled, khugepaged will not be working, and therefore no collapse
> will happen.
>
> DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
> the address range synchronously.
>
> This new action may be required to support autotuning with hugepage as
> a goal.
Above all makes sense. Thank you for posting this patch.
Do you have some test results that you can also share together? It would be
nice if it can demonstrate the benefit of DAMOS_COLLAPSE over DAMOS_HUGEPAGE.
>
> [1] https://lore.kernel.org/lkml/20260314165156.86647-1-sj@kernel.org/
Seems the above link is just added by a mistake? If not, please clarify.
>
> Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
> Reviewed-by: SeongJae Park <sj@kernel.org>
> ---
> Documentation/mm/damon/design.rst | 4 ++++
> include/linux/damon.h | 1 +
> mm/damon/sysfs-schemes.c | 4 ++++
> mm/damon/vaddr.c | 3 +++
> 4 files changed, 12 insertions(+)
[...]
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index 3a441fbca170..6720dc70c487 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -140,6 +140,7 @@ enum damos_action {
> DAMOS_PAGEOUT,
> DAMOS_HUGEPAGE,
> DAMOS_NOHUGEPAGE,
> + DAMOS_COLLAPSE,
> DAMOS_LRU_PRIO,
> DAMOS_LRU_DEPRIO,
> DAMOS_MIGRATE_HOT,
sashiko.dev adds [1] below comments. Let me also add my comments in line.
: This isn't a bug, but should a kernel-doc entry for @DAMOS_COLLAPSE be added
: to the comment block above this enum?
Makes sense. 'make htmldocs' may complain otherwise. Asier, could you please
add the kernel-doc comment for DAMOS_COLLAPSE in the next spin?
:
: Also, does inserting DAMOS_COLLAPSE here shift the integer values of the
: subsequent enum entries like DAMOS_STAT?
:
: The DAMON sysfs selftest script (tools/testing/selftests/damon/sysfs.py) uses
: a hardcoded dictionary action_val to map string names to their integer enum
: values.
:
: If the enum values shift, the test's assertion:
:
: assert_true(dump['action'] == action_val[scheme.action])
:
: might fail when checking the struct memory via drgn. Could the python test
: dictionary be updated to reflect the new values, or could the new action be
: added at the end of the enum list?
There is no test that uses DAMOS actions that defined after DAMOS_NOHUGEPAGE,
so no real test will break. But this is a good point. It would be better to
update the hard-coded value together. Asier, could you also update the
'action_val' dict of assert_scheme_committed() function in
tools/testing/selftets/damon/sysfs.py for the updated enum value in the next
version?
[1] https://sashiko.dev/#/patchset/20260316183805.2090297-1-gutierrez.asier@huawei-partners.com
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 15+ messages in thread
* [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action
@ 2026-03-16 18:38 gutierrez.asier
2026-03-17 0:32 ` SeongJae Park
0 siblings, 1 reply; 15+ messages in thread
From: gutierrez.asier @ 2026-03-16 18:38 UTC (permalink / raw)
To: gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
yanquanmin1, zuoze1, damon, sj, akpm, ljs, Liam.Howlett, vbabka,
rppt, surenb, mhocko, corbet, skhan, linux-doc, linux-mm,
linux-kernel
From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
This patch set introces a new action: DAMOS_COLLAPSE.
For DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE to work, khugepaged should be
working, since it relies on hugepage_madvise to add a new slot. This
slot should be picked up by khugepaged and eventually collapse (or
not, if we are using DAMOS_NOHUGEPAGE) the pages. If THP is not
enabled, khugepaged will not be working, and therefore no collapse
will happen.
DAMOS_COLLAPSE eventually calls madvise_collapse, which will collapse
the address range synchronously.
This new action may be required to support autotuning with hugepage as
a goal.
[1] https://lore.kernel.org/lkml/20260314165156.86647-1-sj@kernel.org/
Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 4 ++++
include/linux/damon.h | 1 +
mm/damon/sysfs-schemes.c | 4 ++++
mm/damon/vaddr.c | 3 +++
4 files changed, 12 insertions(+)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 29fff20b3c2a..3b1461f42987 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -463,6 +463,10 @@ that supports each action are as below.
Supported by ``vaddr`` and ``fvaddr`` operations set.
- ``nohugepage``: Call ``madvise()`` for the region with ``MADV_NOHUGEPAGE``.
Supported by ``vaddr`` and ``fvaddr`` operations set.
+ - ``collapse``: Call ``madvise()`` for the region with ``MADV_COLLAPSE``.
+ Supported by ``vaddr`` and ``fvaddr`` operations set. When
+ TRANSPARENT_HUGEPAGE is disabled, the application of the action will just
+ fail.
- ``lru_prio``: Prioritize the region on its LRU lists.
Supported by ``paddr`` operations set.
- ``lru_deprio``: Deprioritize the region on its LRU lists.
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 3a441fbca170..6720dc70c487 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -140,6 +140,7 @@ enum damos_action {
DAMOS_PAGEOUT,
DAMOS_HUGEPAGE,
DAMOS_NOHUGEPAGE,
+ DAMOS_COLLAPSE,
DAMOS_LRU_PRIO,
DAMOS_LRU_DEPRIO,
DAMOS_MIGRATE_HOT,
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 5186966dafb3..aa08a8f885fb 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2041,6 +2041,10 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
.action = DAMOS_NOHUGEPAGE,
.name = "nohugepage",
},
+ {
+ .action = DAMOS_COLLAPSE,
+ .name = "collapse",
+ },
{
.action = DAMOS_LRU_PRIO,
.name = "lru_prio",
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index b069dbc7e3d2..dd5f2d7027ac 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -903,6 +903,9 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx,
case DAMOS_NOHUGEPAGE:
madv_action = MADV_NOHUGEPAGE;
break;
+ case DAMOS_COLLAPSE:
+ madv_action = MADV_COLLAPSE;
+ break;
case DAMOS_MIGRATE_HOT:
case DAMOS_MIGRATE_COLD:
return damos_va_migrate(t, r, scheme, sz_filter_passed);
--
2.43.0
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-03-25 1:30 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-23 14:56 [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE gutierrez.asier
2026-03-23 14:56 ` [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action gutierrez.asier
2026-03-24 0:29 ` (sashiko review) " SeongJae Park
2026-03-24 0:41 ` SeongJae Park
2026-03-24 13:49 ` Gutierrez Asier
2026-03-24 0:39 ` [RFC PATCH v1 1/1] This patch set introces a new action: DAMOS_COLLAPSE SeongJae Park
2026-03-24 13:57 ` Gutierrez Asier
2026-03-24 14:12 ` SeongJae Park
2026-03-24 15:01 ` Gutierrez Asier
2026-03-25 1:29 ` SeongJae Park
-- strict thread matches above, loose matches on Subject: below --
2026-03-16 18:38 [RFC PATCH v2 1/1] mm/damon: support MADV_COLLAPSE via DAMOS_COLLAPSE scheme action gutierrez.asier
2026-03-17 0:32 ` SeongJae Park
2026-03-17 6:52 ` Gutierrez Asier
2026-03-18 0:52 ` SeongJae Park
2026-03-18 14:41 ` Gutierrez Asier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox