[RFC PATCH v1 2/4] mm/damon: Support for synchrounous huge pages collapse
From: gutierrez.asier
Date: Mon Feb 02 2026 - 10:00:41 EST
From: Asier Gutierrez <gutierrez.asier@xxxxxxxxxxxxxxxxxxx>
* Support for huge pages collapse, which will be used by
dynamic_hugepages module.
* Include the new module for compilation
Signed-off-by: Asier Gutierrez <gutierrez.asier@xxxxxxxxxxxxxxxxxxx>
Co-developed-by: Anatoly Stepanov <stepanov.anatoly@xxxxxxxxxx>
---
include/linux/damon.h | 1 +
mm/damon/Kconfig | 7 +++++++
mm/damon/Makefile | 1 +
mm/damon/vaddr.c | 3 +++
4 files changed, 12 insertions(+)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 3813373a9200..de5a994f92c2 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -142,6 +142,7 @@ enum damos_action {
DAMOS_LRU_DEPRIO,
DAMOS_MIGRATE_HOT,
DAMOS_MIGRATE_COLD,
+ DAMOS_COLLAPSE,
DAMOS_STAT, /* Do nothing but only record the stat */
NR_DAMOS_ACTIONS,
};
diff --git a/mm/damon/Kconfig b/mm/damon/Kconfig
index 8c868f7035fc..2355aacb6d12 100644
--- a/mm/damon/Kconfig
+++ b/mm/damon/Kconfig
@@ -110,4 +110,11 @@ config DAMON_STAT_ENABLED_DEFAULT
Whether to enable DAMON_STAT by default. Users can disable it in
boot or runtime using its 'enabled' parameter.
+config DAMON_HOT_HUGEPAGE
+ bool "Build DAMON-based collapse of hot regions (DAMON_HOT_HUGEPAGES)"
+ depends on DAMON_VADDR
+ help
+ Collapse hot region into huge pages. Hot regions are determined by
+ DAMON-based sampling
+
endmenu
diff --git a/mm/damon/Makefile b/mm/damon/Makefile
index d8d6bf5f8bff..998bddc17819 100644
--- a/mm/damon/Makefile
+++ b/mm/damon/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_DAMON_SYSFS) += sysfs-common.o sysfs-schemes.o sysfs.o
obj-$(CONFIG_DAMON_RECLAIM) += modules-common.o reclaim.o
obj-$(CONFIG_DAMON_LRU_SORT) += modules-common.o lru_sort.o
obj-$(CONFIG_DAMON_STAT) += modules-common.o stat.o
+obj-$(CONFIG_DAMON_HOT_HUGEPAGE) += modules-common.o dynamic_hugepages.o
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index 23ed738a0bd6..4acbc1a6a5be 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -970,6 +970,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