public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH v1] mm/damon: guard THP-specific DAMOS actions with CONFIG_TRANSPARENT_HUGEPAGE
@ 2026-03-14  9:38 gutierrez.asier
  2026-03-14 16:51 ` SeongJae Park
  0 siblings, 1 reply; 3+ messages in thread
From: gutierrez.asier @ 2026-03-14  9:38 UTC (permalink / raw)
  To: gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang,
	yanquanmin1, zuoze1, damon, sj, akpm, linux-mm, linux-kernel

From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>

MADV_HUGEPAGE and MADV_NOHUGEPAGE are guarded and they are not
available when compiling the kernel without TRANSPARENT_HUGEPAGE
option. Therefore, DAMOS_HUGEPAGE and DAMOS_NOHUGEPAGE shouldn't be
available to the user either.

Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
---
 Documentation/mm/damon/design.rst | 6 ++++--
 include/linux/damon.h             | 2 ++
 mm/damon/sysfs-schemes.c          | 2 ++
 mm/damon/vaddr.c                  | 2 ++
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 29fff20b3c2a..207219ee10d4 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -460,9 +460,11 @@ that supports each action are as below.
  - ``pageout``: Reclaim the region.
    Supported by ``vaddr``, ``fvaddr`` and ``paddr`` operations set.
  - ``hugepage``: Call ``madvise()`` for the region with ``MADV_HUGEPAGE``.
-   Supported by ``vaddr`` and ``fvaddr`` operations set.
+   Supported by ``vaddr`` and ``fvaddr`` operations set when
+   TRANSPARENT_HUGEPAGE is enabled.
  - ``nohugepage``: Call ``madvise()`` for the region with ``MADV_NOHUGEPAGE``.
-   Supported by ``vaddr`` and ``fvaddr`` operations set.
+   Supported by ``vaddr`` and ``fvaddr`` operations set when
+   TRANSPARENT_HUGEPAGE is enabled.
  - ``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..b3fcbe84b5d7 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -138,8 +138,10 @@ enum damos_action {
 	DAMOS_WILLNEED,
 	DAMOS_COLD,
 	DAMOS_PAGEOUT,
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	DAMOS_HUGEPAGE,
 	DAMOS_NOHUGEPAGE,
+#endif
 	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..05e57c7ca2b6 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2033,6 +2033,7 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
 		.action = DAMOS_PAGEOUT,
 		.name = "pageout",
 	},
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	{
 		.action = DAMOS_HUGEPAGE,
 		.name = "hugepage",
@@ -2041,6 +2042,7 @@ static struct damos_sysfs_action_name damos_sysfs_action_names[] = {
 		.action = DAMOS_NOHUGEPAGE,
 		.name = "nohugepage",
 	},
+#endif
 	{
 		.action = DAMOS_LRU_PRIO,
 		.name = "lru_prio",
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index b069dbc7e3d2..19c488660027 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -897,12 +897,14 @@ static unsigned long damon_va_apply_scheme(struct damon_ctx *ctx,
 	case DAMOS_PAGEOUT:
 		madv_action = MADV_PAGEOUT;
 		break;
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	case DAMOS_HUGEPAGE:
 		madv_action = MADV_HUGEPAGE;
 		break;
 	case DAMOS_NOHUGEPAGE:
 		madv_action = MADV_NOHUGEPAGE;
 		break;
+#endif
 	case DAMOS_MIGRATE_HOT:
 	case DAMOS_MIGRATE_COLD:
 		return damos_va_migrate(t, r, scheme, sz_filter_passed);
-- 
2.43.0



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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-14  9:38 [PATCH v1] mm/damon: guard THP-specific DAMOS actions with CONFIG_TRANSPARENT_HUGEPAGE gutierrez.asier
2026-03-14 16:51 ` SeongJae Park
2026-03-16  7:03   ` Gutierrez Asier

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