Re: [RFC PATCH v3 3/4] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing
From: SeongJae Park
Date: Thu Jun 04 2026 - 21:22:42 EST
On Thu, 4 Jun 2026 15:03:36 +0000 <gutierrez.asier@xxxxxxxxxxxxxxxxxxx> wrote:
> From: Asier Gutierrez <gutierrez.asier@xxxxxxxxxxxxxxxxxxx>
>
> This patch introduces a new DAMON module (SAMPLE_DAMON_HUGEPAGE)
Could we make the name shorter, to look more consistent with other sample
modules? E.g., SAMPLE_DAMON_HPAGE?
> which collapses hot regions into huge pages.
>
> SAMPLE_DAMON_HUGEPAGE operates in the virtual memory space, for a
> specific task. The user is expected to supply the PID of the task
> that is going to be monitored through the monitored_pid module
> variable.
>
> SAMPLE_DAMON_HUGEPAGE uses the hugepage auto-tune mechanism to
> increase or decrease the aggressiveness of page collapsing. User
> autotuning is also available for additional tuning aggressiveness
> control.
>
> The module also includes changes to the DAMON compilation, so that
> the module can be enabled or disabled.
>
> Signed-off-by: Asier Gutierrez <gutierrez.asier@xxxxxxxxxxxxxxxxxxx>
> ---
> mm/damon/Makefile | 8 +-
> samples/damon/Kconfig | 12 ++
> samples/damon/Makefile | 2 +
> samples/damon/hugepage.c (new) | 350 +++++++++++++++++++++++++++++++++
> 4 files changed, 368 insertions(+), 4 deletions(-)
>
> diff --git a/mm/damon/Makefile b/mm/damon/Makefile
> index d8d6bf5f8bff..16459ce40304 100644
> --- a/mm/damon/Makefile
> +++ b/mm/damon/Makefile
> @@ -1,9 +1,9 @@
> # SPDX-License-Identifier: GPL-2.0
>
> -obj-y := core.o
> +obj-y := core.o modules-common.o
> obj-$(CONFIG_DAMON_VADDR) += ops-common.o vaddr.o
> obj-$(CONFIG_DAMON_PADDR) += ops-common.o paddr.o
> 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_RECLAIM) += reclaim.o
> +obj-$(CONFIG_DAMON_LRU_SORT) += lru_sort.o
> +obj-$(CONFIG_DAMON_STAT) += stat.o
This is for letting the new sample module use the code in ops-common.o, right?
I'd like to keep sample modules simple and isolated under samples/ directory.
Could you please make the sample module simpler and remove the above change?
> diff --git a/samples/damon/Kconfig b/samples/damon/Kconfig
> index cbf96fd8a8bf..512f150aaabb 100644
> --- a/samples/damon/Kconfig
> +++ b/samples/damon/Kconfig
> @@ -40,4 +40,16 @@ config SAMPLE_DAMON_MTIER
>
> If unsure, say N.
>
> +config SAMPLE_DAMON_HUGEPAGE
> + bool "Build DAMON-based collapse of hot regions (SAMPLE_DAMON_HUGEPAGE)"
Can this be more consistent with other sample modules? E.g.,
DAMON sample module for auto-tuned THP collapsing ?
> + depends on DAMON && DAMON_VADDR
> + help
> + This module monitors a certain PID provided by the user through
> + monitored_pid attribute. Hot regions are determined by DAMON-based
> + sampling. Collapsing occurs according to the quota goal using total
> + memory usage to huge page usage ratio. The ratio is set by the user
> + through a module attribute.
> +
> + If unsure, say N.
> +
> endmenu
> diff --git a/samples/damon/Makefile b/samples/damon/Makefile
> index 72f68cbf422a..f90845faec85 100644
> --- a/samples/damon/Makefile
> +++ b/samples/damon/Makefile
> @@ -3,3 +3,5 @@
> obj-$(CONFIG_SAMPLE_DAMON_WSSE) += wsse.o
> obj-$(CONFIG_SAMPLE_DAMON_PRCL) += prcl.o
> obj-$(CONFIG_SAMPLE_DAMON_MTIER) += mtier.o
> +obj-$(CONFIG_SAMPLE_DAMON_HUGEPAGE) += hugepage.o
> +ccflags-$(CONFIG_SAMPLE_DAMON_HUGEPAGE) += -I$(srctree)/mm/damon
As I mentioned above, let's not mix samples/ with mm/damon/
> diff --git a/samples/damon/hugepage.c b/samples/damon/hugepage.c
> new file mode 100644
> index 000000000000..e24562c92348
> --- /dev/null
> +++ b/samples/damon/hugepage.c
> @@ -0,0 +1,350 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2026 HUAWEI, Inc.
> + * https://www.huawei.com
> + *
> + * Author: Asier Gutierrez <gutierrez.asier@xxxxxxxxxxxxxxxxxxx>
> + */
> +
> +#define pr_fmt(fmt) "damon-hugepage: " fmt
Apparently this module's source code is following patterns of reclaim.c and
lru_sort.c. That's for non-sample modules. Could you please rewrite this
sample module following patterns in sample modules, like that for wsse.c or
prcl.c ?
Thanks,
SJ
[...]