[RFC PATCH v2 0/4] mm/damon: Support hot application detections

gutierrez.asier
2026-03-10T16:25:36Z

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

Overview
----------

This patch set introduces a new dynamic mechanism for detecting hot applications
and hot regions in those applications.

Motivation
-----------

Since TLB is a bottleneck for many systems, a way to optimize TLB misses (or
hits) is to use huge pages. Unfortunately, using "always" in THP leads to memory
fragmentation and memory waste. For this reason, most application guides and
system administrators suggest to disable THP.

Solution
-----------

A new Linux kernel module that uses DAMON to detect hot regions and collapse
those regions into huge pages. The user supplies a set of PIDs using a module
parameter, and then, the module launches a new kdamond thread to monitor each
of the tasks.

In each kdamond, we start with a high min_access value. Our goal is to find the
"maximum" min_access value at which point the DAMON action is applied. In each
cycle, if no action is applied, we lower the min_access.

Regarding the action, we introduce a new action: DAMOS_COLLAPSE. This allows us
collapse synchronously and avoid polluting khugepaged and other parts of the MM
subsystem with DAMON stuff. DAMOS_HUGEPAGE eventually calls hugepage_madvise,
which needs the correct vm_flags_t set.

-----------
Changes in v2:
- Previously there was a mechanism to automatically detect hot applications.
Based on SeongJae Park's feedback [1], this was removed from the module, leaving
it entirely to the user space.
- All allocations now use kzalloc_obj.
- Since the user space provides now the list of pids to monitor, a commit_input
parameter is added to allow changing the pids while the module runs.
- Renamed the module from dynamic_hugepages to hugepages

[1]: https://lore.kernel.org/all/20260211150902.70066-1-sj@kernel.org/

Asier Gutierrez (4):
Damon_modules_new_paddr_ctx_target. This works only for physical
contexts. In case of virtual addresses, we should duplicate the
code.
Support for huge pages collapse, which will be used by
dynamic_hugepages module.
This new module launches a new kdamond thread for each of them. The
purpose is to detect hot regions in a given list of tasks and
collapse them into huge pages.
DAMON_HOT_HUGEPAGE documentation

.../admin-guide/mm/damon/hugepage.rst (new) | 186 ++++++++
include/linux/damon.h | 1 +
mm/damon/Kconfig | 7 +
mm/damon/Makefile | 1 +
mm/damon/hugepage.c (new) | 441 ++++++++++++++++++
mm/damon/lru_sort.c | 5 +-
mm/damon/modules-common.c | 6 +-
mm/damon/modules-common.h | 4 +-
mm/damon/reclaim.c | 5 +-
mm/damon/vaddr.c | 3 +
10 files changed, 650 insertions(+), 9 deletions(-)
create mode 100644 Documentation/admin-guide/mm/damon/hugepage.rst
create mode 100644 mm/damon/hugepage.c

--
2.43.0