* [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning
@ 2026-06-16 15:03 gutierrez.asier
2026-06-16 15:03 ` [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE " gutierrez.asier
` (3 more replies)
0 siblings, 4 replies; 37+ messages in thread
From: gutierrez.asier @ 2026-06-16 15:03 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>
Overview
========
This patch set introduces a new autotuning which allows to collapse
hot regions into hugepages.
Motivation
==========
Since TLB is a bottleneck for many systems[1], 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.
Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE.
However, there is no way to tune the settings. It will collapse all the
hot regions that meet the access pattern. If the server is a bare metal
database or big data server, this will also lead to eventual fragmentation.
Additionally, currently THP is set globally. Ideally, there should be a
way to control which tasks can use huge pages.
Solution
========
DAMON has now a way to autotune some of the variables and adjust quotas
automatically, so that DAMON is fired only under the right circumstances.
It would be nice to have something similar, but for huge pages.
A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced,
which checks the huge page consumption to total memory consumption. This
new quota mechanism reuses current autotuning architecture.
A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate
the use of huge pages collapse autotuning. The goal is to collapse hot
regions of a given process into huge pages. The sample module launches
a kdamond thread for a certain task provided by the user through
taget_pid module argument. Hugepage goal autotuning will automatically
adjust the aggressiveness of hot region collapses.
This sample module also has a user autotuning knob which allows the
user to adjust the aggressiveness of page collapsing.
Benchmarks
==========
Huge page collapse autotuning was tested in a physicial machine with
MariaDB 10.5.29 and sysbench as the benchmark framework.
The hugepage module was set up in the following way:
# echo 1000 > min_age
# echo 1000 > quota_percentage_hugepage
# echo $(pidof mariadbd) > taget_pid
# echo on > enabled
The goal was to achieve 5% of the total memory used as hugepage.
Since the database was not very big, we may not be able to achieve
high amount of huge pages per total memory consumption ratio.
The table below shows the memory consumption over time. Timestamp is in
second and the memory usage in is MBytes. Gaps in the timestamp means
that no changes in the hugepage consumption happened over that period
of time in MB. The total used memory is calculated as
mem_total - mem free. The huge page used is calculated as
huge_page_anon + huge_page_shmem + huge_page_file. The table also
shows the huge pages to total memory ratio.
Hugepage autotune benchmark:
+-----------+----------------+----------------+----------------------+
| timestamp | total mem used | huge page used | percentage hugepage |
+-----------+----------------+----------------+----------------------+
| 0 | 3044.988281 | 0 | 0% |
| 22 | 3160.207031 | 2 | 0.06% |
| 30 | 3250.90625 | 4 | 0.12% |
| 69 | 3781.238281 | 6 | 0.16% |
| 71 | 3822.226563 | 8 | 0.21% |
| 72 | 3846.578125 | 10 | 0.26% |
| 73 | 3852.402344 | 12 | 0.31% |
| 74 | 3868 | 14 | 0.36% |
| 75 | 3881.84375 | 104 | 2.68% |
| 275 | 4194.175781 | 106 | 2.52% |
+-----------+----------------+----------------+----------------------+
After second 275, no more pages are collapsed into hugepages
THP (always) benchmark:
+-----------+----------------+----------------+---------------------+
| timestamp | total mem used | huge page used | percentage hugepage |
+-----------+----------------+----------------+---------------------+
| 1 | 4489.320313 | 184 | 4.098615986 |
| 15 | 4581.871094 | 214 | 4.670580984 |
| 30 | 4757.742188 | 376 | 7.902908253 |
| 45 | 4937.574219 | 558 | 11.30109595 |
| 60 | 5147.867188 | 728 | 14.14177898 |
| 75 | 5407.0625 | 918 | 16.97779524 |
| 95 | 5668.796875 | 1040 | 18.34604455 |
| 105 | 5723.839844 | 1056 | 18.44915352 |
| 115 | 5736.84375 | 1072 | 18.68623317 |
| 125 | 5732.042969 | 1088 | 18.98101612 |
| 186 | 5753.601563 | 1184 | 20.57841488 |
| 246 | 5746.398438 | 1280 | 22.27482159 |
| 306 | 5752.128906 | 1376 | 23.92157795 |
| 367 | 5772.5625 | 1472 | 25.49994045 |
| 427 | 5832.019531 | 1568 | 26.88605536 |
| 488 | 5813.246094 | 1664 | 28.62428277 |
| 548 | 5807.621094 | 1760 | 30.30500736 |
| 598 | 5841.253906 | 1822 | 31.19193292 |
| 669 | 5982.160156 | 1854 | 30.99214918 |
| 931 | 5946.605469 | 1868 | 31.41287933 |
| 981 | 6020.207031 | 1896 | 31.49393352 |
| 991 | 5988.445313 | 1910 | 31.89475566 |
| 1011 | 5988.570313 | 1926 | 32.16126554 |
| 1032 | 6016.039063 | 1936 | 32.18064211 |
| 1575 | 6057.289063 | 1968 | 32.48978181 |
| 1606 | 6026.167969 | 2000 | 33.18858702 |
+-----------+----------------+----------------+---------------------+
I ignored some points to make the table shorter. Anyway, the amount
of memory consumption, total and huge pages, is a lot higher than
with DAMON hugepage autotuning.
Performance:
Baseline (no THP, module off) -> 18,162.45 transactions per second
Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement)
THP always -> 18,388.3 (+1.24%)
THP madvise -> 18,179.25 (+0.09%)
Improvement is due to lower TLB misses
Patches Sequence
================
Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning
Patch 2 -> Module that demonstrates how to use
DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL
Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes
Changes from previous versions
==============================
RFC 4[3] -> v1
- Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and
functions to damon_sample_hpage_...
- Make the module depend on TRANSPARENT_HUGEPAGE, since
the module will need some THP functions anyway
- Removed documentation, since this is just a sample module
- Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from
damos_sysfs_add_quota_score
- Added a short description of the module in Kconfig
RFC 3[4] -> RFC 4
- Simplified the module
- Removed unnecessary parameters
- Renamed DAMOS_QUOTA_HUGEPAGE_MEM_BP to unify the
naming style
- Switched to DAMOS_QUOTA_GOAL_TUNER_TEMPORAL
- Updated the documentation
- Removed new interface for context creation with
DAMON_OPS_VADDR
RFC 2[5] -> RFC 3
- Module moved to samples
- Change autotune to monitor total memory and hugepage
- Added performnace benchmarks to the cover letter
- Bail out gracefully when trying to start disable
the module after the monitored task exited. This
issue was discovered by sashiko [6]
- Fixed typos and added quota_sz to the documentation
discovered by sashiko [7]
RFC 1[8] -> RFC 2
- Rebased into mm-new
- Use DAMOS_COLLAPSE instead of DAMOS_HUGEPAGE
- Fixed an issue that returned silently an error when the PID
didn't exist in the system.[9]
[1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227
[2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com
[3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com
[4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com
[5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com
[6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org
[7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org
[8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com
[9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/
Asier Gutierrez (3):
mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing
mm/damon/sysfs: support hugepage_mem_bp quota goal metric
include/linux/damon.h | 2 ++
mm/damon/core.c | 14 ++++++++++++++
mm/damon/sysfs-schemes.c | 4 ++++
samples/damon/Kconfig | 14 ++++++++++++++
samples/damon/Makefile | 1 +
5 files changed, 35 insertions(+)
--
2.43.0
^ permalink raw reply [flat|nested] 37+ messages in thread* [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning 2026-06-16 15:03 [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning gutierrez.asier @ 2026-06-16 15:03 ` gutierrez.asier 2026-06-16 15:20 ` sashiko-bot 2026-06-17 3:31 ` SeongJae Park 2026-06-16 15:03 ` [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing gutierrez.asier ` (2 subsequent siblings) 3 siblings, 2 replies; 37+ messages in thread From: gutierrez.asier @ 2026-06-16 15:03 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> Introduce DAMOS_QUOTA_HUGEPAGE auto tuning Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio. Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com> --- include/linux/damon.h | 2 ++ mm/damon/core.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 6f7edb3590ef..23a9cec05033 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -162,6 +162,7 @@ enum damos_action { * @DAMOS_QUOTA_INACTIVE_MEM_BP: Inactive to total LRU memory ratio. * @DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP: Scheme-eligible memory ratio of a * node in basis points (0-10000). + * @DAMOS_QUOTA_HUGEPAGE_MEM_BP: Huge page to total used memory ratio. * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. * * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupported. @@ -176,6 +177,7 @@ enum damos_quota_goal_metric { DAMOS_QUOTA_ACTIVE_MEM_BP, DAMOS_QUOTA_INACTIVE_MEM_BP, DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, + DAMOS_QUOTA_HUGEPAGE_MEM_BP, NR_DAMOS_QUOTA_GOAL_METRICS, }; diff --git a/mm/damon/core.c b/mm/damon/core.c index 7e4b9affc5b0..b001f80681b1 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2795,6 +2795,17 @@ static unsigned int damos_get_in_active_mem_bp(bool active_ratio) return mult_frac(inactive, 10000, total); } +static unsigned int damos_hugepage_mem_bp(void) +{ + unsigned long thp, total; + + thp = global_node_page_state(NR_ANON_THPS) + + global_node_page_state(NR_SHMEM_THPS) + + global_node_page_state(NR_FILE_THPS); + total = totalram_pages() - global_zone_page_state(NR_FREE_PAGES); + return mult_frac(thp, 10000, total); +} + static void damos_set_quota_goal_current_value(struct damon_ctx *c, struct damos *s, struct damos_quota_goal *goal) { @@ -2826,6 +2837,9 @@ static void damos_set_quota_goal_current_value(struct damon_ctx *c, goal->current_value = damos_get_node_eligible_mem_bp(c, s, goal->nid); break; + case DAMOS_QUOTA_HUGEPAGE_MEM_BP: + goal->current_value = damos_hugepage_mem_bp(); + break; default: break; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning 2026-06-16 15:03 ` [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE " gutierrez.asier @ 2026-06-16 15:20 ` sashiko-bot 2026-06-16 19:33 ` Gutierrez Asier 2026-06-17 3:31 ` SeongJae Park 1 sibling, 1 reply; 37+ messages in thread From: sashiko-bot @ 2026-06-16 15:20 UTC (permalink / raw) To: gutierrez.asier; +Cc: damon Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: New issues: - [High] The `mult_frac(thp, 10000, total)` macro call silently overflows `unsigned long` on 32-bit architectures, yielding incorrect DAMOS quota metrics. Pre-existing issues: - [Critical] The `damos_get_in_active_mem_bp()` function can trigger a divide-by-zero exception if there are no active and inactive LRU pages. -- commit 812a9d3523a15be0a409c86d1076f2098e299808 Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning This commit introduces a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio. [ ... ] > diff --git a/mm/damon/core.c b/mm/damon/core.c > index 7e4b9affc5b06..b001f80681b12 100644 > --- a/mm/damon/core.c > +++ b/mm/damon/core.c > @@ -2795,6 +2795,17 @@ static unsigned int damos_get_in_active_mem_bp(bool active_ratio) > return mult_frac(inactive, 10000, total); [Severity: Critical] This is a pre-existing issue, but can this divide by zero if there are no active and inactive LRU pages? If a system has no active or inactive anonymous/file LRU pages (for example, immediately after early boot before userspace populates the LRU), total evaluates to exactly 0. The mult_frac macro performs division by total, which would trigger a divide-by-zero hardware exception. > } > > +static unsigned int damos_hugepage_mem_bp(void) > +{ > + unsigned long thp, total; > + > + thp = global_node_page_state(NR_ANON_THPS) + > + global_node_page_state(NR_SHMEM_THPS) + > + global_node_page_state(NR_FILE_THPS); > + total = totalram_pages() - global_zone_page_state(NR_FREE_PAGES); > + return mult_frac(thp, 10000, total); [Severity: High] Does this calculation silently overflow unsigned long on 32-bit architectures? The mult_frac(x, n, d) macro computes (x / d) * n + (x % d) * n / d. Because thp is always less than or equal to total, thp / total evaluates to 0, leaving (thp * 10000) / total. Both thp and 10000 evaluate as 32-bit unsigned long on 32-bit systems, so the intermediate multiplication thp * 10000 will wrap around if thp exceeds roughly 1.75 GB (429,496 pages). This would cause the metric to under-report hugepage usage. > +} -- Sashiko AI review · https://sashiko.dev/#/patchset/20260616150316.580819-1-gutierrez.asier@huawei-partners.com?part=1 ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning 2026-06-16 15:20 ` sashiko-bot @ 2026-06-16 19:33 ` Gutierrez Asier 0 siblings, 0 replies; 37+ messages in thread From: Gutierrez Asier @ 2026-06-16 19:33 UTC (permalink / raw) To: sashiko-reviews; +Cc: damon On 6/16/2026 6:20 PM, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: > > New issues: > - [High] The `mult_frac(thp, 10000, total)` macro call silently overflows `unsigned long` on 32-bit architectures, yielding incorrect DAMOS quota metrics. > > Pre-existing issues: > - [Critical] The `damos_get_in_active_mem_bp()` function can trigger a divide-by-zero exception if there are no active and inactive LRU pages. > -- > > commit 812a9d3523a15be0a409c86d1076f2098e299808 > Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning > > This commit introduces a new DAMOS quota goal metric to measure the amount > of huge page consumption to total memory consumption ratio. > > [ ... ] > >> diff --git a/mm/damon/core.c b/mm/damon/core.c >> index 7e4b9affc5b06..b001f80681b12 100644 >> --- a/mm/damon/core.c >> +++ b/mm/damon/core.c >> @@ -2795,6 +2795,17 @@ static unsigned int damos_get_in_active_mem_bp(bool active_ratio) >> return mult_frac(inactive, 10000, total); > > [Severity: Critical] > This is a pre-existing issue, but can this divide by zero if there are no > active and inactive LRU pages? > > If a system has no active or inactive anonymous/file LRU pages (for example, > immediately after early boot before userspace populates the LRU), total > evaluates to exactly 0. The mult_frac macro performs division by total, > which would trigger a divide-by-zero hardware exception. As described in a previous patch set[1], total will never be 0, since the module will only be enabled after the system is fully loaded. >> } >> >> +static unsigned int damos_hugepage_mem_bp(void) >> +{ >> + unsigned long thp, total; >> + >> + thp = global_node_page_state(NR_ANON_THPS) + >> + global_node_page_state(NR_SHMEM_THPS) + >> + global_node_page_state(NR_FILE_THPS); >> + total = totalram_pages() - global_zone_page_state(NR_FREE_PAGES); >> + return mult_frac(thp, 10000, total); > > [Severity: High] > Does this calculation silently overflow unsigned long on 32-bit > architectures? > > The mult_frac(x, n, d) macro computes (x / d) * n + (x % d) * n / d. Because > thp is always less than or equal to total, thp / total evaluates to 0, > leaving (thp * 10000) / total. > > Both thp and 10000 evaluate as 32-bit unsigned long on 32-bit systems, so > the intermediate multiplication thp * 10000 will wrap around if thp exceeds > roughly 1.75 GB (429,496 pages). This would cause the metric to under-report > hugepage usage. As discussed before, we will leave this behaviour as it is.[2] >> +} > [1] https://lore.kernel.org/all/20260611152146.AD2821F00898@smtp.kernel.org/ [2] https://lore.kernel.org/all/20260609145240.69552-1-sj@kernel.org -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning 2026-06-16 15:03 ` [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE " gutierrez.asier 2026-06-16 15:20 ` sashiko-bot @ 2026-06-17 3:31 ` SeongJae Park 1 sibling, 0 replies; 37+ messages in thread From: SeongJae Park @ 2026-06-17 3:31 UTC (permalink / raw) To: gutierrez.asier Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Tue, 16 Jun 2026 15:03:14 +0000 <gutierrez.asier@huawei-partners.com> wrote: > From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > Introduce DAMOS_QUOTA_HUGEPAGE auto tuning Add a new Please fix the name of the quota, and add the ending period after 'tuning'. > DAMOS quota goal metric to measure the amount of huge page > consumption to total memory consumption ratio. > > Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > --- > include/linux/damon.h | 2 ++ > mm/damon/core.c | 14 ++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/linux/damon.h b/include/linux/damon.h > index 6f7edb3590ef..23a9cec05033 100644 > --- a/include/linux/damon.h > +++ b/include/linux/damon.h > @@ -162,6 +162,7 @@ enum damos_action { > * @DAMOS_QUOTA_INACTIVE_MEM_BP: Inactive to total LRU memory ratio. > * @DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP: Scheme-eligible memory ratio of a > * node in basis points (0-10000). > + * @DAMOS_QUOTA_HUGEPAGE_MEM_BP: Huge page to total used memory ratio. > * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. > * > * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupported. > @@ -176,6 +177,7 @@ enum damos_quota_goal_metric { > DAMOS_QUOTA_ACTIVE_MEM_BP, > DAMOS_QUOTA_INACTIVE_MEM_BP, > DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, > + DAMOS_QUOTA_HUGEPAGE_MEM_BP, > NR_DAMOS_QUOTA_GOAL_METRICS, > }; > > diff --git a/mm/damon/core.c b/mm/damon/core.c > index 7e4b9affc5b0..b001f80681b1 100644 > --- a/mm/damon/core.c > +++ b/mm/damon/core.c > @@ -2795,6 +2795,17 @@ static unsigned int damos_get_in_active_mem_bp(bool active_ratio) > return mult_frac(inactive, 10000, total); > } > > +static unsigned int damos_hugepage_mem_bp(void) > +{ > + unsigned long thp, total; > + > + thp = global_node_page_state(NR_ANON_THPS) + > + global_node_page_state(NR_SHMEM_THPS) + > + global_node_page_state(NR_FILE_THPS); > + total = totalram_pages() - global_zone_page_state(NR_FREE_PAGES); > + return mult_frac(thp, 10000, total); > +} > + > static void damos_set_quota_goal_current_value(struct damon_ctx *c, > struct damos *s, struct damos_quota_goal *goal) > { > @@ -2826,6 +2837,9 @@ static void damos_set_quota_goal_current_value(struct damon_ctx *c, > goal->current_value = damos_get_node_eligible_mem_bp(c, s, > goal->nid); > break; > + case DAMOS_QUOTA_HUGEPAGE_MEM_BP: > + goal->current_value = damos_hugepage_mem_bp(); > + break; > default: > break; > } > -- > 2.43.0 Code looks good to me. Thanks, SJ ^ permalink raw reply [flat|nested] 37+ messages in thread
* [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-16 15:03 [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning gutierrez.asier 2026-06-16 15:03 ` [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE " gutierrez.asier @ 2026-06-16 15:03 ` gutierrez.asier 2026-06-16 15:21 ` sashiko-bot ` (2 more replies) 2026-06-16 15:03 ` [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric gutierrez.asier 2026-06-17 1:44 ` [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning SeongJae Park 3 siblings, 3 replies; 37+ messages in thread From: gutierrez.asier @ 2026-06-16 15:03 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> This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) which collapses hot regions into huge pages. SAMPLE_DAMON_HPAGE 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 target_pid module variable. SAMPLE_DAMON_HPAGE 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@huawei-partners.com> --- samples/damon/Kconfig | 14 +++ samples/damon/Makefile | 1 + samples/damon/hpage.c (new) | 207 ++++++++++++++++++++++++++++++++++++ 3 files changed, 222 insertions(+) diff --git a/samples/damon/Kconfig b/samples/damon/Kconfig index cbf96fd8a8bf..1ef0b12c32e6 100644 --- a/samples/damon/Kconfig +++ b/samples/damon/Kconfig @@ -40,4 +40,18 @@ config SAMPLE_DAMON_MTIER If unsure, say N. +config SAMPLE_DAMON_HPAGE + bool "Build DAMON-based collapse of hot regions (SAMPLE_DAMON_HPAGE)" + depends on DAMON && DAMON_VADDR && TRANSPARENT_HUGEPAGE + help + This builds DAMON sample module for collapsing regions into huge pages. + + This module monitors a certain PID provided by the user through + target_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..a348dc74ddcb 100644 --- a/samples/damon/Makefile +++ b/samples/damon/Makefile @@ -3,3 +3,4 @@ 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) += hpage.o diff --git a/samples/damon/hpage.c b/samples/damon/hpage.c new file mode 100644 index 000000000000..ebbe5e1be1a1 --- /dev/null +++ b/samples/damon/hpage.c @@ -0,0 +1,207 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2026 HUAWEI, Inc. + * https://www.huawei.com + * + * Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> + */ + +#define pr_fmt(fmt) "damon_sample_hpage: " fmt + +#include <linux/damon.h> +#include <linux/kstrtox.h> +#include <linux/module.h> + +#ifdef MODULE_PARAM_PREFIX +#undef MODULE_PARAM_PREFIX +#endif +#define MODULE_PARAM_PREFIX "damon_sample_hpage." + +static bool enabled __read_mostly; + +static unsigned long target_pid; +module_param(target_pid, ulong, 0600); + +/* By default, total huge pages to system memory usage ratio set to 10% */ +static unsigned long quota_percentage_hugepage __read_mostly = 1000; +module_param(quota_percentage_hugepage, ulong, 0600); + +static unsigned long quota_autotune_feedback __read_mostly; +module_param(quota_autotune_feedback, ulong, 0600); + +static struct damon_ctx *ctx; +static struct pid *target_pidp; + +static int damon_sample_hpage_damon_call_fn(void *data) +{ + struct damon_ctx *c = data; + struct damon_target *t; + + damon_for_each_target(t, c) { + struct damon_region *r; + unsigned long hugepages = 0; + + damon_for_each_region(r, t) { + if (r->nr_accesses > 0) + hugepages += r->ar.end - r->ar.start; + } + hugepages = hugepages / HPAGE_PMD_SIZE; + pr_info("hugepage: %lu\n", hugepages); + } + return 0; +} + +static struct damon_call_control call_control = { + .fn = damon_sample_hpage_damon_call_fn, + .repeat = true, +}; + +static int damon_sample_hpage_start(void) +{ + int err; + struct damon_target *target; + struct damos *scheme; + struct damos_quota_goal *goal; + + pr_info("start\n"); + + + ctx = damon_new_ctx(); + if (!ctx) + return -ENOMEM; + if (damon_select_ops(ctx, DAMON_OPS_VADDR)) { + damon_destroy_ctx(ctx); + return -EINVAL; + } + + target = damon_new_target(); + if (!target) { + damon_destroy_ctx(ctx); + return -ENOMEM; + } + damon_add_target(ctx, target); + target_pidp = find_get_pid(target_pid); + if (!target_pidp) { + damon_destroy_ctx(ctx); + return -EINVAL; + } + target->pid = target_pidp; + + scheme = damon_new_scheme(&(struct damos_access_pattern) { + .min_sz_region = HPAGE_PMD_SIZE, + .max_sz_region = ULONG_MAX, + .min_nr_accesses = 0, + .max_nr_accesses = UINT_MAX, + .min_age_region = 50, + .max_age_region = UINT_MAX}, + DAMOS_COLLAPSE, 0, + &(struct damos_quota) { + .ms = 10, + .sz = 128 * 1024 * 1024, + .reset_interval = 1000, + .weight_sz = 0, + .weight_nr_accesses = 1, + .weight_age = 1, + .goal_tuner = DAMOS_QUOTA_GOAL_TUNER_TEMPORAL}, + &(struct damos_watermarks){}, NUMA_NO_NODE); + if (!scheme) { + damon_destroy_ctx(ctx); + return -ENOMEM; + } + damon_set_schemes(ctx, &scheme, 1); + goal = damos_new_quota_goal(DAMOS_QUOTA_HUGEPAGE_MEM_BP, + quota_percentage_hugepage); + if (!goal) { + damon_destroy_ctx(ctx); + return -ENOMEM; + } + damos_add_quota_goal(&scheme->quota, goal); + + if (quota_autotune_feedback) { + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); + if (!goal) { + damon_destroy_ctx(ctx); + return -ENOMEM; + } + goal->current_value = quota_autotune_feedback; + damos_add_quota_goal(&scheme->quota, goal); + } + + err = damon_start(&ctx, 1, true); + if (err) { + damon_destroy_ctx(ctx); + return err; + } + + call_control.data = ctx; + err = damon_call(ctx, &call_control); + if (err) { + damon_stop(&ctx, 1); + damon_destroy_ctx(ctx); + } + return err; +} + +static void damon_sample_hpage_stop(void) +{ + pr_info("stop\n"); + if (ctx) { + damon_stop(&ctx, 1); + damon_destroy_ctx(ctx); + } +} +static int damon_sample_hpage_enabled_store(const char *val, + const struct kernel_param *kp) +{ + bool is_enabled = enabled; + int err; + + err = kstrtobool(val, &enabled); + if (err) + return err; + + if (enabled == is_enabled) + return 0; + + if (!damon_initialized()) + return 0; + + if (enabled) { + err = damon_sample_hpage_start(); + if (err) + enabled = false; + return err; + } + damon_sample_hpage_stop(); + return 0; +} + +static const struct kernel_param_ops enabled_param_ops = { + .set = damon_sample_hpage_enabled_store, + .get = param_get_bool, +}; + +module_param_cb(enabled, &enabled_param_ops, &enabled, 0600); +MODULE_PARM_DESC(enabled, + "Enable or disable DAMON_HUGEPAGE (default: disabled)"); + +static int __init damon_sample_hpage_init(void) +{ + int err = 0; + + if (!damon_initialized()) { + if (enabled) + enabled = false; + pr_warn("Module not initialized\n"); + return -ENOMEM; + } + + if (enabled) { + err = damon_sample_hpage_start(); + if (err) + enabled = false; + } + return err; +} + +module_init(damon_sample_hpage_init); -- 2.43.0 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-16 15:03 ` [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing gutierrez.asier @ 2026-06-16 15:21 ` sashiko-bot 2026-06-16 19:27 ` Gutierrez Asier 2026-06-17 4:04 ` SeongJae Park 2026-06-17 16:12 ` Julian Braha 2 siblings, 1 reply; 37+ messages in thread From: sashiko-bot @ 2026-06-16 15:21 UTC (permalink / raw) To: gutierrez.asier; +Cc: damon Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] The `DAMOS_QUOTA_USER_INPUT` goal tuner feedback mechanism is statically stuck because `current_value` is never dynamically updated. - [Medium] The scheme applies the DAMOS_COLLAPSE action to all regions including completely cold ones, contradicting the patch description. - [Low] The module cannot be compiled due to a naming mismatch between the Kconfig symbol and the Makefile variable. -- commit 7e15caa860a55beb8439fc6bb5f299c5c42fb138 Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) which collapses hot regions into huge pages. The module monitors a specific task using DAMON-based sampling and applies collapsing based on memory usage. > diff --git a/samples/damon/Makefile b/samples/damon/Makefile > index 72f68cbf422aa..a348dc74ddcb1 100644 > --- a/samples/damon/Makefile > +++ b/samples/damon/Makefile > @@ -3,3 +3,4 @@ > 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) += hpage.o [Severity: Low] Does this prevent the module from building? The Kconfig file defines the configuration option as SAMPLE_DAMON_HPAGE, but the Makefile evaluates CONFIG_SAMPLE_DAMON_HUGEPAGE. This mismatch means the build system might silently skip compiling hpage.o. > diff --git a/samples/damon/hpage.c b/samples/damon/hpage.c > new file mode 100644 > index 0000000000000..ebbe5e1be1a1d > --- /dev/null > +++ b/samples/damon/hpage.c [ ... ] > + scheme = damon_new_scheme(&(struct damos_access_pattern) { > + .min_sz_region = HPAGE_PMD_SIZE, > + .max_sz_region = ULONG_MAX, > + .min_nr_accesses = 0, > + .max_nr_accesses = UINT_MAX, [Severity: Medium] Will this apply the collapse action to completely cold regions? The commit message states this module collapses "hot regions", but setting min_nr_accesses to 0 instructs DAMON to apply the action to all regions that meet the age threshold, including those with no accesses at all. Should this be set to a value strictly greater than 0 to only target heavily accessed regions? [ ... ] > + if (quota_autotune_feedback) { > + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); > + if (!goal) { > + damon_destroy_ctx(ctx); > + return -ENOMEM; > + } > + goal->current_value = quota_autotune_feedback; > + damos_add_quota_goal(&scheme->quota, goal); > + } [Severity: Medium] Is there a missing mechanism to dynamically update this feedback value? Since the module parameter is assigned to current_value exactly once at startup, without a dynamic update path while running, the auto-tuner will receive a constant error value. Won't this continuously push the quota aggressiveness in one direction until it hits the limits, rather than forming a proper feedback loop? -- Sashiko AI review · https://sashiko.dev/#/patchset/20260616150316.580819-1-gutierrez.asier@huawei-partners.com?part=2 ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-16 15:21 ` sashiko-bot @ 2026-06-16 19:27 ` Gutierrez Asier 2026-06-17 4:09 ` SeongJae Park 0 siblings, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-06-16 19:27 UTC (permalink / raw) To: sashiko-reviews; +Cc: damon On 6/16/2026 6:21 PM, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: > - [Medium] The `DAMOS_QUOTA_USER_INPUT` goal tuner feedback mechanism is statically stuck because `current_value` is never dynamically updated. > - [Medium] The scheme applies the DAMOS_COLLAPSE action to all regions including completely cold ones, contradicting the patch description. > - [Low] The module cannot be compiled due to a naming mismatch between the Kconfig symbol and the Makefile variable. > -- > > commit 7e15caa860a55beb8439fc6bb5f299c5c42fb138 > Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing > > This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) > which collapses hot regions into huge pages. The module monitors > a specific task using DAMON-based sampling and applies collapsing > based on memory usage. > >> diff --git a/samples/damon/Makefile b/samples/damon/Makefile >> index 72f68cbf422aa..a348dc74ddcb1 100644 >> --- a/samples/damon/Makefile >> +++ b/samples/damon/Makefile >> @@ -3,3 +3,4 @@ >> 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) += hpage.o > > [Severity: Low] > Does this prevent the module from building? > > The Kconfig file defines the configuration option as SAMPLE_DAMON_HPAGE, > but the Makefile evaluates CONFIG_SAMPLE_DAMON_HUGEPAGE. This mismatch > means the build system might silently skip compiling hpage.o. Yes, my bad when moving around code from different branches. Will be fixed in v2. >> diff --git a/samples/damon/hpage.c b/samples/damon/hpage.c >> new file mode 100644 >> index 0000000000000..ebbe5e1be1a1d >> --- /dev/null >> +++ b/samples/damon/hpage.c > > [ ... ] > >> + scheme = damon_new_scheme(&(struct damos_access_pattern) { >> + .min_sz_region = HPAGE_PMD_SIZE, >> + .max_sz_region = ULONG_MAX, >> + .min_nr_accesses = 0, >> + .max_nr_accesses = UINT_MAX, > > [Severity: Medium] > Will this apply the collapse action to completely cold regions? > > The commit message states this module collapses "hot regions", but setting > min_nr_accesses to 0 instructs DAMON to apply the action to all regions > that meet the age threshold, including those with no accesses at all. > > Should this be set to a value strictly greater than 0 to only target > heavily accessed regions? Good catch. I will update it to 1. > [ ... ] > >> + if (quota_autotune_feedback) { >> + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); >> + if (!goal) { >> + damon_destroy_ctx(ctx); >> + return -ENOMEM; >> + } >> + goal->current_value = quota_autotune_feedback; >> + damos_add_quota_goal(&scheme->quota, goal); >> + } > > [Severity: Medium] > Is there a missing mechanism to dynamically update this feedback value? > > Since the module parameter is assigned to current_value exactly once at > startup, without a dynamic update path while running, the auto-tuner will > receive a constant error value. > > Won't this continuously push the quota aggressiveness in one direction > until it hits the limits, rather than forming a proper feedback loop? > This is a sample module. There is no commit mechanism as in the usual DAMON modules. It should be set up before enabling the module. I will document this behaviour in the documentation. -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-16 19:27 ` Gutierrez Asier @ 2026-06-17 4:09 ` SeongJae Park 0 siblings, 0 replies; 37+ messages in thread From: SeongJae Park @ 2026-06-17 4:09 UTC (permalink / raw) To: Gutierrez Asier; +Cc: SeongJae Park, sashiko-reviews, damon On Tue, 16 Jun 2026 22:27:41 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > On 6/16/2026 6:21 PM, sashiko-bot@kernel.org wrote: > > Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: > > - [Medium] The `DAMOS_QUOTA_USER_INPUT` goal tuner feedback mechanism is statically stuck because `current_value` is never dynamically updated. > > - [Medium] The scheme applies the DAMOS_COLLAPSE action to all regions including completely cold ones, contradicting the patch description. > > - [Low] The module cannot be compiled due to a naming mismatch between the Kconfig symbol and the Makefile variable. > > -- > > > > commit 7e15caa860a55beb8439fc6bb5f299c5c42fb138 > > Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > > > mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing > > > > This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) > > which collapses hot regions into huge pages. The module monitors > > a specific task using DAMON-based sampling and applies collapsing > > based on memory usage. > > > >> diff --git a/samples/damon/Makefile b/samples/damon/Makefile > >> index 72f68cbf422aa..a348dc74ddcb1 100644 > >> --- a/samples/damon/Makefile > >> +++ b/samples/damon/Makefile > >> @@ -3,3 +3,4 @@ > >> 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) += hpage.o > > > > [Severity: Low] > > Does this prevent the module from building? > > > > The Kconfig file defines the configuration option as SAMPLE_DAMON_HPAGE, > > but the Makefile evaluates CONFIG_SAMPLE_DAMON_HUGEPAGE. This mismatch > > means the build system might silently skip compiling hpage.o. > Yes, my bad when moving around code from different branches. Will > be fixed in v2. > >> diff --git a/samples/damon/hpage.c b/samples/damon/hpage.c > >> new file mode 100644 > >> index 0000000000000..ebbe5e1be1a1d > >> --- /dev/null > >> +++ b/samples/damon/hpage.c > > > > [ ... ] > > > >> + scheme = damon_new_scheme(&(struct damos_access_pattern) { > >> + .min_sz_region = HPAGE_PMD_SIZE, > >> + .max_sz_region = ULONG_MAX, > >> + .min_nr_accesses = 0, > >> + .max_nr_accesses = UINT_MAX, > > > > [Severity: Medium] > > Will this apply the collapse action to completely cold regions? > > > > The commit message states this module collapses "hot regions", but setting > > min_nr_accesses to 0 instructs DAMON to apply the action to all regions > > that meet the age threshold, including those with no accesses at all. > > > > Should this be set to a value strictly greater than 0 to only target > > heavily accessed regions? > Good catch. I will update it to 1. I was assuming you intentionally set it to 0, since quota's access hotness based prioritization will anyway cut out cold regions. But if it was not the intention, please feel free to update. > > [ ... ] > > > >> + if (quota_autotune_feedback) { > >> + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); > >> + if (!goal) { > >> + damon_destroy_ctx(ctx); > >> + return -ENOMEM; > >> + } > >> + goal->current_value = quota_autotune_feedback; > >> + damos_add_quota_goal(&scheme->quota, goal); > >> + } > > > > [Severity: Medium] > > Is there a missing mechanism to dynamically update this feedback value? > > > > Since the module parameter is assigned to current_value exactly once at > > startup, without a dynamic update path while running, the auto-tuner will > > receive a constant error value. > > > > Won't this continuously push the quota aggressiveness in one direction > > until it hits the limits, rather than forming a proper feedback loop? > > > This is a sample module. There is no commit mechanism as in the usual > DAMON modules. It should be set up before enabling the module. It means the user feedback is not really working. > > I will document this behaviour in the documentation. I'd suggest to just drop this unused and untested feature. Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-16 15:03 ` [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing gutierrez.asier 2026-06-16 15:21 ` sashiko-bot @ 2026-06-17 4:04 ` SeongJae Park 2026-06-18 0:16 ` SeongJae Park 2026-06-17 16:12 ` Julian Braha 2 siblings, 1 reply; 37+ messages in thread From: SeongJae Park @ 2026-06-17 4:04 UTC (permalink / raw) To: gutierrez.asier Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Tue, 16 Jun 2026 15:03:15 +0000 <gutierrez.asier@huawei-partners.com> wrote: > From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) > which collapses hot regions into huge pages. > > SAMPLE_DAMON_HPAGE 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 target_pid module > variable. s/variable/parameter/ ? > > SAMPLE_DAMON_HPAGE 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. Is the user autotuning really needed for this sample module? I'm concerned if it is unnecessarily making the code complicated. Can we drop this? > > The module also includes changes to the DAMON compilation, I think this is not true? > so that > the module can be enabled or disabled. > > Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > --- > samples/damon/Kconfig | 14 +++ > samples/damon/Makefile | 1 + > samples/damon/hpage.c (new) | 207 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 222 insertions(+) > > diff --git a/samples/damon/Kconfig b/samples/damon/Kconfig > index cbf96fd8a8bf..1ef0b12c32e6 100644 > --- a/samples/damon/Kconfig > +++ b/samples/damon/Kconfig > @@ -40,4 +40,18 @@ config SAMPLE_DAMON_MTIER > > If unsure, say N. > > +config SAMPLE_DAMON_HPAGE > + bool "Build DAMON-based collapse of hot regions (SAMPLE_DAMON_HPAGE)" Please make this be consistent to other sample modules. E.g., DAMON sample module for ... > + depends on DAMON && DAMON_VADDR && TRANSPARENT_HUGEPAGE > + help > + This builds DAMON sample module for collapsing regions into huge pages. ... for huge pages collapsing? > + > + This module monitors a certain PID provided by the user through > + target_pid attribute. Hot regions are determined by DAMON-based Please use two spaces between sentences, consistent to others. > + sampling. Collapsing occurs according to the quota goal using total "DAMON-based sampling" sounds verbose and technically not making much sense. How about just "DAMON"? > + memory usage to huge page usage ratio. The ratio is set by the user huge page to total memory usage ratio? > + through a module attribute. s/attribute/parameter/ ? > + > + If unsure, say N. > + > endmenu > diff --git a/samples/damon/Makefile b/samples/damon/Makefile > index 72f68cbf422a..a348dc74ddcb 100644 > --- a/samples/damon/Makefile > +++ b/samples/damon/Makefile > @@ -3,3 +3,4 @@ > 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) += hpage.o ... Can this be compiled...? > diff --git a/samples/damon/hpage.c b/samples/damon/hpage.c > new file mode 100644 > index 000000000000..ebbe5e1be1a1 > --- /dev/null > +++ b/samples/damon/hpage.c > @@ -0,0 +1,207 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2026 HUAWEI, Inc. > + * https://www.huawei.com > + * > + * Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > + */ > + > +#define pr_fmt(fmt) "damon_sample_hpage: " fmt > + > +#include <linux/damon.h> > +#include <linux/kstrtox.h> > +#include <linux/module.h> > + > +#ifdef MODULE_PARAM_PREFIX > +#undef MODULE_PARAM_PREFIX > +#endif > +#define MODULE_PARAM_PREFIX "damon_sample_hpage." > + > +static bool enabled __read_mostly; > + > +static unsigned long target_pid; > +module_param(target_pid, ulong, 0600); Why 'ulong'? I think 'int' is enough? > + > +/* By default, total huge pages to system memory usage ratio set to 10% */ > +static unsigned long quota_percentage_hugepage __read_mostly = 1000; > +module_param(quota_percentage_hugepage, ulong, 0600); "percentage" in the name sounds weird. What about hugepage_mem_bp or target_hugepage_mem_bp? > + > +static unsigned long quota_autotune_feedback __read_mostly; > +module_param(quota_autotune_feedback, ulong, 0600); I'm not really sure if this is really needed. If not, could we drop this? > + > +static struct damon_ctx *ctx; > +static struct pid *target_pidp; > + > +static int damon_sample_hpage_damon_call_fn(void *data) > +{ > + struct damon_ctx *c = data; > + struct damon_target *t; > + > + damon_for_each_target(t, c) { > + struct damon_region *r; > + unsigned long hugepages = 0; > + > + damon_for_each_region(r, t) { > + if (r->nr_accesses > 0) > + hugepages += r->ar.end - r->ar.start; > + } > + hugepages = hugepages / HPAGE_PMD_SIZE; > + pr_info("hugepage: %lu\n", hugepages); > + } > + return 0; > +} What's the purpose of this function? If not really needed, can we drop? > + > +static struct damon_call_control call_control = { > + .fn = damon_sample_hpage_damon_call_fn, > + .repeat = true, > +}; > + > +static int damon_sample_hpage_start(void) > +{ > + int err; > + struct damon_target *target; > + struct damos *scheme; > + struct damos_quota_goal *goal; > + > + pr_info("start\n"); > + > + Let's have only one blank line. > + ctx = damon_new_ctx(); > + if (!ctx) > + return -ENOMEM; > + if (damon_select_ops(ctx, DAMON_OPS_VADDR)) { > + damon_destroy_ctx(ctx); > + return -EINVAL; > + } > + > + target = damon_new_target(); > + if (!target) { > + damon_destroy_ctx(ctx); > + return -ENOMEM; > + } > + damon_add_target(ctx, target); > + target_pidp = find_get_pid(target_pid); > + if (!target_pidp) { > + damon_destroy_ctx(ctx); > + return -EINVAL; > + } > + target->pid = target_pidp; > + > + scheme = damon_new_scheme(&(struct damos_access_pattern) { > + .min_sz_region = HPAGE_PMD_SIZE, > + .max_sz_region = ULONG_MAX, > + .min_nr_accesses = 0, > + .max_nr_accesses = UINT_MAX, > + .min_age_region = 50, > + .max_age_region = UINT_MAX}, > + DAMOS_COLLAPSE, 0, > + &(struct damos_quota) { > + .ms = 10, I don't really suggest time quota to people nowadays. Size quota is easier to understand and sufficient in many cases in my humble opinion. Did you find it is really helpful and essential for this module? If not, could we unset time quota? > + .sz = 128 * 1024 * 1024, > + .reset_interval = 1000, > + .weight_sz = 0, > + .weight_nr_accesses = 1, > + .weight_age = 1, > + .goal_tuner = DAMOS_QUOTA_GOAL_TUNER_TEMPORAL}, > + &(struct damos_watermarks){}, NUMA_NO_NODE); > + if (!scheme) { > + damon_destroy_ctx(ctx); > + return -ENOMEM; > + } > + damon_set_schemes(ctx, &scheme, 1); > + goal = damos_new_quota_goal(DAMOS_QUOTA_HUGEPAGE_MEM_BP, > + quota_percentage_hugepage); > + if (!goal) { > + damon_destroy_ctx(ctx); > + return -ENOMEM; > + } > + damos_add_quota_goal(&scheme->quota, goal); > + > + if (quota_autotune_feedback) { > + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); > + if (!goal) { > + damon_destroy_ctx(ctx); > + return -ENOMEM; > + } > + goal->current_value = quota_autotune_feedback; > + damos_add_quota_goal(&scheme->quota, goal); > + } Seems this module is not really utilizing the user input feedback. To use that in real, the module should periodically read user's input and feed that to DAMON core. I find no code doing that in this module. If it is not really being used, I'd suggest to drop this. > + > + err = damon_start(&ctx, 1, true); > + if (err) { > + damon_destroy_ctx(ctx); > + return err; > + } > + > + call_control.data = ctx; > + err = damon_call(ctx, &call_control); > + if (err) { > + damon_stop(&ctx, 1); > + damon_destroy_ctx(ctx); > + } > + return err; > +} > + > +static void damon_sample_hpage_stop(void) > +{ > + pr_info("stop\n"); > + if (ctx) { > + damon_stop(&ctx, 1); > + damon_destroy_ctx(ctx); > + } > +} > +static int damon_sample_hpage_enabled_store(const char *val, > + const struct kernel_param *kp) > +{ > + bool is_enabled = enabled; > + int err; > + > + err = kstrtobool(val, &enabled); > + if (err) > + return err; > + > + if (enabled == is_enabled) > + return 0; > + > + if (!damon_initialized()) > + return 0; > + > + if (enabled) { > + err = damon_sample_hpage_start(); > + if (err) > + enabled = false; > + return err; > + } > + damon_sample_hpage_stop(); > + return 0; > +} > + > +static const struct kernel_param_ops enabled_param_ops = { > + .set = damon_sample_hpage_enabled_store, > + .get = param_get_bool, > +}; > + > +module_param_cb(enabled, &enabled_param_ops, &enabled, 0600); > +MODULE_PARM_DESC(enabled, > + "Enable or disable DAMON_HUGEPAGE (default: disabled)"); s/DAMON_HUGEPAGE/DAMON_SAMPLE_HPAGE/ ? "(default: disabled)" seems unnecessary. Could you please remove that? > + > +static int __init damon_sample_hpage_init(void) > +{ > + int err = 0; > + > + if (!damon_initialized()) { > + if (enabled) > + enabled = false; > + pr_warn("Module not initialized\n"); > + return -ENOMEM; > + } > + > + if (enabled) { > + err = damon_sample_hpage_start(); > + if (err) > + enabled = false; > + } > + return err; > +} > + > +module_init(damon_sample_hpage_init); > -- > 2.43.0 Thanks, SJ ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-17 4:04 ` SeongJae Park @ 2026-06-18 0:16 ` SeongJae Park 2026-06-18 0:19 ` SeongJae Park 2026-06-18 11:51 ` Gutierrez Asier 0 siblings, 2 replies; 37+ messages in thread From: SeongJae Park @ 2026-06-18 0:16 UTC (permalink / raw) To: SeongJae Park Cc: gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Tue, 16 Jun 2026 21:04:52 -0700 SeongJae Park <sj@kernel.org> wrote: > On Tue, 16 Jun 2026 15:03:15 +0000 <gutierrez.asier@huawei-partners.com> wrote: > > > From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > > > This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) > > which collapses hot regions into huge pages. As I mentioned on the previous version of this series, this sample module looks much better than the initial shape to my humble eyes. Much smaller and simpler. I really appreciate Asier's efforts on making this. However... I was asking myself if this module is really needed last night, and still got not real good and confident answer. After all, this is a sample module. The purpose is to show sample code thhat helps people understanding how they can use DAMON API. Maybe we can argue this module can be helpful at understanding how DAMOS quota goal can be used. But, mtier is already showing that. So I cannot say what new advantage this module is really bringing. Meanwhile, this patch adds ~200 lines of code. It is a very small and simple sample module, but still we should maintain it. I, to be honest, getting little bit concerned about the maintenance overhead now. So, if Asier has a good reason to add this module that I'm missing, I'd like to humbly ask to consider dropping of this module for now. I'm so sorry for raising this concern this late. But, Asier, may I ask what do you think? Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-18 0:16 ` SeongJae Park @ 2026-06-18 0:19 ` SeongJae Park 2026-06-18 11:51 ` Gutierrez Asier 1 sibling, 0 replies; 37+ messages in thread From: SeongJae Park @ 2026-06-18 0:19 UTC (permalink / raw) To: SeongJae Park Cc: gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Wed, 17 Jun 2026 17:16:20 -0700 SeongJae Park <sj@kernel.org> wrote: > On Tue, 16 Jun 2026 21:04:52 -0700 SeongJae Park <sj@kernel.org> wrote: > > > On Tue, 16 Jun 2026 15:03:15 +0000 <gutierrez.asier@huawei-partners.com> wrote: > > > > > From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > > > > > This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) > > > which collapses hot regions into huge pages. > > As I mentioned on the previous version of this series, this sample module looks > much better than the initial shape to my humble eyes. Much smaller and > simpler. I really appreciate Asier's efforts on making this. > > However... I was asking myself if this module is really needed last night, and > still got not real good and confident answer. > > After all, this is a sample module. The purpose is to show sample code thhat > helps people understanding how they can use DAMON API. Maybe we can argue this > module can be helpful at understanding how DAMOS quota goal can be used. But, > mtier is already showing that. So I cannot say what new advantage this module > is really bringing. > > Meanwhile, this patch adds ~200 lines of code. It is a very small and simple > sample module, but still we should maintain it. I, to be honest, getting > little bit concerned about the maintenance overhead now. > > So, if Asier has a good reason to add this module that I'm missing, I'd like to s/if/unless/ Sorry. > humbly ask to consider dropping of this module for now. I'm so sorry for > raising this concern this late. But, Asier, may I ask what do you think? > > > Thanks, > SJ > > [...] Thanks, SJ ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-18 0:16 ` SeongJae Park 2026-06-18 0:19 ` SeongJae Park @ 2026-06-18 11:51 ` Gutierrez Asier 2026-06-18 14:57 ` SeongJae Park 1 sibling, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-06-18 11:51 UTC (permalink / raw) To: SeongJae Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel Hi SJ, On 6/18/2026 3:16 AM, SeongJae Park wrote: > On Tue, 16 Jun 2026 21:04:52 -0700 SeongJae Park <sj@kernel.org> wrote: > >> On Tue, 16 Jun 2026 15:03:15 +0000 <gutierrez.asier@huawei-partners.com> wrote: >> >>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >>> >>> This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) >>> which collapses hot regions into huge pages. > > As I mentioned on the previous version of this series, this sample module looks > much better than the initial shape to my humble eyes. Much smaller and > simpler. I really appreciate Asier's efforts on making this. > > However... I was asking myself if this module is really needed last night, and > still got not real good and confident answer. > > After all, this is a sample module. The purpose is to show sample code thhat > helps people understanding how they can use DAMON API. Maybe we can argue this > module can be helpful at understanding how DAMOS quota goal can be used. But, > mtier is already showing that. So I cannot say what new advantage this module > is really bringing. You are right, the main goal was to show how this quota goal can be used. > Meanwhile, this patch adds ~200 lines of code. It is a very small and simple > sample module, but still we should maintain it. I, to be honest, getting > little bit concerned about the maintenance overhead now. I understand your concerns. I know code need maintenance, and DAMON is already growing significantly. > So, if Asier has a good reason to add this module that I'm missing, I'd like to > humbly ask to consider dropping of this module for now. I'm so sorry for > raising this concern this late. But, Asier, may I ask what do you think? So, are you suggesting to drop the module and upstreaming only the DAMOS quota goal stuff?> > Thanks, > SJ > > [...] > -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-18 11:51 ` Gutierrez Asier @ 2026-06-18 14:57 ` SeongJae Park 2026-06-18 14:59 ` Gutierrez Asier 0 siblings, 1 reply; 37+ messages in thread From: SeongJae Park @ 2026-06-18 14:57 UTC (permalink / raw) To: Gutierrez Asier Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Thu, 18 Jun 2026 14:51:42 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > Hi SJ, > > On 6/18/2026 3:16 AM, SeongJae Park wrote: > > On Tue, 16 Jun 2026 21:04:52 -0700 SeongJae Park <sj@kernel.org> wrote: > > > >> On Tue, 16 Jun 2026 15:03:15 +0000 <gutierrez.asier@huawei-partners.com> wrote: > >> > >>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > >>> > >>> This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) > >>> which collapses hot regions into huge pages. > > > > As I mentioned on the previous version of this series, this sample module looks > > much better than the initial shape to my humble eyes. Much smaller and > > simpler. I really appreciate Asier's efforts on making this. > > > > However... I was asking myself if this module is really needed last night, and > > still got not real good and confident answer. > > > > After all, this is a sample module. The purpose is to show sample code thhat > > helps people understanding how they can use DAMON API. Maybe we can argue this > > module can be helpful at understanding how DAMOS quota goal can be used. But, > > mtier is already showing that. So I cannot say what new advantage this module > > is really bringing. > You are right, the main goal was to show how this quota goal can be used. > > Meanwhile, this patch adds ~200 lines of code. It is a very small and simple > > sample module, but still we should maintain it. I, to be honest, getting > > little bit concerned about the maintenance overhead now. > I understand your concerns. I know code need maintenance, and DAMON is already > growing significantly. > > So, if Asier has a good reason to add this module that I'm missing, I'd like to > > humbly ask to consider dropping of this module for now. I'm so sorry for > > raising this concern this late. But, Asier, may I ask what do you think? > So, are you suggesting to drop the module and upstreaming only the DAMOS quota > goal stuff?> Yes, if you don't mind. Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-18 14:57 ` SeongJae Park @ 2026-06-18 14:59 ` Gutierrez Asier 2026-06-18 15:08 ` SeongJae Park 0 siblings, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-06-18 14:59 UTC (permalink / raw) To: SeongJae Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On 6/18/2026 5:57 PM, SeongJae Park wrote: > On Thu, 18 Jun 2026 14:51:42 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > >> Hi SJ, >> >> On 6/18/2026 3:16 AM, SeongJae Park wrote: >>> On Tue, 16 Jun 2026 21:04:52 -0700 SeongJae Park <sj@kernel.org> wrote: >>> >>>> On Tue, 16 Jun 2026 15:03:15 +0000 <gutierrez.asier@huawei-partners.com> wrote: >>>> >>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >>>>> >>>>> This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) >>>>> which collapses hot regions into huge pages. >>> >>> As I mentioned on the previous version of this series, this sample module looks >>> much better than the initial shape to my humble eyes. Much smaller and >>> simpler. I really appreciate Asier's efforts on making this. >>> >>> However... I was asking myself if this module is really needed last night, and >>> still got not real good and confident answer. >>> >>> After all, this is a sample module. The purpose is to show sample code thhat >>> helps people understanding how they can use DAMON API. Maybe we can argue this >>> module can be helpful at understanding how DAMOS quota goal can be used. But, >>> mtier is already showing that. So I cannot say what new advantage this module >>> is really bringing. >> You are right, the main goal was to show how this quota goal can be used. >>> Meanwhile, this patch adds ~200 lines of code. It is a very small and simple >>> sample module, but still we should maintain it. I, to be honest, getting >>> little bit concerned about the maintenance overhead now. >> I understand your concerns. I know code need maintenance, and DAMON is already >> growing significantly. >>> So, if Asier has a good reason to add this module that I'm missing, I'd like to >>> humbly ask to consider dropping of this module for now. I'm so sorry for >>> raising this concern this late. But, Asier, may I ask what do you think? >> So, are you suggesting to drop the module and upstreaming only the DAMOS quota >> goal stuff?> > > Yes, if you don't mind. Sure. I will do it a bit later. Thanks a lot for your help reviewing the code so far. > > Thanks, > SJ > > [...] > -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-18 14:59 ` Gutierrez Asier @ 2026-06-18 15:08 ` SeongJae Park 0 siblings, 0 replies; 37+ messages in thread From: SeongJae Park @ 2026-06-18 15:08 UTC (permalink / raw) To: Gutierrez Asier Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Thu, 18 Jun 2026 17:59:36 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > On 6/18/2026 5:57 PM, SeongJae Park wrote: > > On Thu, 18 Jun 2026 14:51:42 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > >> Hi SJ, > >> > >> On 6/18/2026 3:16 AM, SeongJae Park wrote: > >>> On Tue, 16 Jun 2026 21:04:52 -0700 SeongJae Park <sj@kernel.org> wrote: > >>> > >>>> On Tue, 16 Jun 2026 15:03:15 +0000 <gutierrez.asier@huawei-partners.com> wrote: > >>>> > >>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > >>>>> > >>>>> This patch introduces a new DAMON module (SAMPLE_DAMON_HPAGE) > >>>>> which collapses hot regions into huge pages. > >>> > >>> As I mentioned on the previous version of this series, this sample module looks > >>> much better than the initial shape to my humble eyes. Much smaller and > >>> simpler. I really appreciate Asier's efforts on making this. > >>> > >>> However... I was asking myself if this module is really needed last night, and > >>> still got not real good and confident answer. > >>> > >>> After all, this is a sample module. The purpose is to show sample code thhat > >>> helps people understanding how they can use DAMON API. Maybe we can argue this > >>> module can be helpful at understanding how DAMOS quota goal can be used. But, > >>> mtier is already showing that. So I cannot say what new advantage this module > >>> is really bringing. > >> You are right, the main goal was to show how this quota goal can be used. > >>> Meanwhile, this patch adds ~200 lines of code. It is a very small and simple > >>> sample module, but still we should maintain it. I, to be honest, getting > >>> little bit concerned about the maintenance overhead now. > >> I understand your concerns. I know code need maintenance, and DAMON is already > >> growing significantly. > >>> So, if Asier has a good reason to add this module that I'm missing, I'd like to > >>> humbly ask to consider dropping of this module for now. I'm so sorry for > >>> raising this concern this late. But, Asier, may I ask what do you think? > >> So, are you suggesting to drop the module and upstreaming only the DAMOS quota > >> goal stuff?> > > > > Yes, if you don't mind. > Sure. I will do it a bit later. Thank you for kindly accepting my humble suggestion, Asier! > > Thanks a lot for your help reviewing the code so far. I sincerely appreciate your contributions, too. Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-16 15:03 ` [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing gutierrez.asier 2026-06-16 15:21 ` sashiko-bot 2026-06-17 4:04 ` SeongJae Park @ 2026-06-17 16:12 ` Julian Braha 2026-06-18 0:18 ` SeongJae Park 2 siblings, 1 reply; 37+ messages in thread From: Julian Braha @ 2026-06-17 16:12 UTC (permalink / raw) To: gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, sj, akpm, linux-mm, linux-kernel Hi Asier, On 6/16/26 16:03, gutierrez.asier@huawei-partners.com wrote: > +config SAMPLE_DAMON_HPAGE > + bool "Build DAMON-based collapse of hot regions (SAMPLE_DAMON_HPAGE)" > + depends on DAMON && DAMON_VADDR && TRANSPARENT_HUGEPAGE The dependency on DAMON is unnecessary because you already depend on DAMON_VADDR. - Julian Braha ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing 2026-06-17 16:12 ` Julian Braha @ 2026-06-18 0:18 ` SeongJae Park 0 siblings, 0 replies; 37+ messages in thread From: SeongJae Park @ 2026-06-18 0:18 UTC (permalink / raw) To: Julian Braha Cc: SeongJae Park, gutierrez.asier, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Wed, 17 Jun 2026 17:12:45 +0100 Julian Braha <julianbraha@gmail.com> wrote: > Hi Asier, > > On 6/16/26 16:03, gutierrez.asier@huawei-partners.com wrote: > > > +config SAMPLE_DAMON_HPAGE > > + bool "Build DAMON-based collapse of hot regions (SAMPLE_DAMON_HPAGE)" > > + depends on DAMON && DAMON_VADDR && TRANSPARENT_HUGEPAGE > The dependency on DAMON is unnecessary because you already depend on > DAMON_VADDR. Nice findiing! There are similar duplicated conditions for other sample modules, too. If anyone willing to, please feel free to post patches for cleaning those out. Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric 2026-06-16 15:03 [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning gutierrez.asier 2026-06-16 15:03 ` [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE " gutierrez.asier 2026-06-16 15:03 ` [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing gutierrez.asier @ 2026-06-16 15:03 ` gutierrez.asier 2026-06-16 15:21 ` sashiko-bot 2026-06-17 4:16 ` SeongJae Park 2026-06-17 1:44 ` [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning SeongJae Park 3 siblings, 2 replies; 37+ messages in thread From: gutierrez.asier @ 2026-06-16 15:03 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> DAMOS has a new autotune policy metric: DAMOS_QUOTA_HUGEPAGE_MEM_BP. This patch exposes DAMOS_QUOTA_HUGEPAGE_MEM_BP through sysfs. Add the "hugepage_mem_bp" to the sysfs-schemes interface. Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com> --- mm/damon/sysfs-schemes.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 329cfd0bbe9f..4b5429a5b415 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1267,6 +1267,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = { .metric = DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, .name = "node_eligible_mem_bp", }, + { + .metric = DAMOS_QUOTA_HUGEPAGE_MEM_BP, + .name = "hugepage_mem_bp", + }, }; static ssize_t target_metric_show(struct kobject *kobj, -- 2.43.0 ^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric 2026-06-16 15:03 ` [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric gutierrez.asier @ 2026-06-16 15:21 ` sashiko-bot 2026-06-16 19:35 ` Gutierrez Asier 2026-06-17 4:16 ` SeongJae Park 1 sibling, 1 reply; 37+ messages in thread From: sashiko-bot @ 2026-06-16 15:21 UTC (permalink / raw) To: gutierrez.asier; +Cc: damon Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: New issues: - [Low] The new `DAMOS_QUOTA_HUGEPAGE_MEM_BP` metric is exposed via sysfs but lacks required documentation updates. Pre-existing issues: - [Critical] Potential divide-by-zero in `damos_hugepage_mem_bp()` and `damos_get_in_active_mem_bp()` due to an unhandled zero denominator. - [High] 32-bit integer overflow in `damos_hugepage_mem_bp()` and `damos_get_in_active_mem_bp()` when calculating memory ratios. -- commit be304699fb94d4d73bd979237fb4d7b08b7216f7 Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> mm/damon/sysfs: support hugepage_mem_bp quota goal metric DAMOS has a new autotune policy metric: DAMOS_QUOTA_HUGEPAGE_MEM_BP. This patch exposes DAMOS_QUOTA_HUGEPAGE_MEM_BP through sysfs. > diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c > index 329cfd0bbe9f3..4b5429a5b4158 100644 > --- a/mm/damon/sysfs-schemes.c > +++ b/mm/damon/sysfs-schemes.c > @@ -1267,6 +1267,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = { > .metric = DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, > .name = "node_eligible_mem_bp", > }, > + { > + .metric = DAMOS_QUOTA_HUGEPAGE_MEM_BP, > + .name = "hugepage_mem_bp", > + }, [Severity: Critical] This isn't a bug introduced by this patch, but exposing this metric directly to userspace makes a potential divide-by-zero triggerable by users configuring DAMON quotas. In mm/damon/core.c:damos_hugepage_mem_bp(), the denominator is computed as: total = totalram_pages() - global_zone_page_state(NR_FREE_PAGES); Due to per-CPU vmstat lag or an idle system, the free pages counter can equal totalram_pages(), resulting in total being 0. This is then passed to mult_frac(): return mult_frac(thp, 10000, total); This inherently computes thp / total, causing a strict division by zero and a kernel panic. The same issue exists in damos_get_in_active_mem_bp() where total = active + inactive, which can be 0 if the LRU lists are empty. Should a zero-check on total be added before performing the division? [Severity: High] This is a pre-existing issue, but exposing this metric also surfaces a 32-bit integer overflow in mm/damon/core.c:damos_hugepage_mem_bp(). The mult_frac(x, n, d) macro performs the multiplication (x % d) * n. Here x is thp, which is an unsigned long. On 32-bit systems, if thp exceeds ~429,496 pages (around 1.75 GB), (thp % total) * 10000 will silently overflow the 32-bit unsigned long type. This wrap-around yields an erroneously low ratio instead of the correct value. The same overflow applies to damos_get_in_active_mem_bp() if the active or inactive pages exceed 1.75 GB. Could this be fixed by casting the first argument to u64 to prevent the overflow? [Severity: Low] Does this patch also require an update to the authoritative DAMON sysfs documentation? Documentation/mm/damon/design.rst explicitly lists all valid string values for the target_metric sysfs file, but does not include hugepage_mem_bp. Without documenting the new metric, it may remain undiscoverable for users. > }; > > static ssize_t target_metric_show(struct kobject *kobj, -- Sashiko AI review · https://sashiko.dev/#/patchset/20260616150316.580819-1-gutierrez.asier@huawei-partners.com?part=3 ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric 2026-06-16 15:21 ` sashiko-bot @ 2026-06-16 19:35 ` Gutierrez Asier 2026-06-17 4:15 ` SeongJae Park 0 siblings, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-06-16 19:35 UTC (permalink / raw) To: sashiko-reviews; +Cc: damon On 6/16/2026 6:21 PM, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: > > New issues: > - [Low] The new `DAMOS_QUOTA_HUGEPAGE_MEM_BP` metric is exposed via sysfs but lacks required documentation updates. > > Pre-existing issues: > - [Critical] Potential divide-by-zero in `damos_hugepage_mem_bp()` and `damos_get_in_active_mem_bp()` due to an unhandled zero denominator. > - [High] 32-bit integer overflow in `damos_hugepage_mem_bp()` and `damos_get_in_active_mem_bp()` when calculating memory ratios. > -- > > commit be304699fb94d4d73bd979237fb4d7b08b7216f7 > Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > mm/damon/sysfs: support hugepage_mem_bp quota goal metric > > DAMOS has a new autotune policy metric: DAMOS_QUOTA_HUGEPAGE_MEM_BP. > This patch exposes DAMOS_QUOTA_HUGEPAGE_MEM_BP through sysfs. > >> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c >> index 329cfd0bbe9f3..4b5429a5b4158 100644 >> --- a/mm/damon/sysfs-schemes.c >> +++ b/mm/damon/sysfs-schemes.c >> @@ -1267,6 +1267,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = { >> .metric = DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, >> .name = "node_eligible_mem_bp", >> }, >> + { >> + .metric = DAMOS_QUOTA_HUGEPAGE_MEM_BP, >> + .name = "hugepage_mem_bp", >> + }, > > [Severity: Critical] > This isn't a bug introduced by this patch, but exposing this metric directly > to userspace makes a potential divide-by-zero triggerable by users > configuring DAMON quotas. > > In mm/damon/core.c:damos_hugepage_mem_bp(), the denominator is computed as: > > total = totalram_pages() - global_zone_page_state(NR_FREE_PAGES); > > Due to per-CPU vmstat lag or an idle system, the free pages counter can equal > totalram_pages(), resulting in total being 0. This is then passed to > mult_frac(): > > return mult_frac(thp, 10000, total); > > This inherently computes thp / total, causing a strict division by zero and a > kernel panic. The same issue exists in damos_get_in_active_mem_bp() where > total = active + inactive, which can be 0 if the LRU lists are empty. > > Should a zero-check on total be added before performing the division? DAMON is enabled after the system is fully loaded. total will not be 0 by then. > [Severity: High] > This is a pre-existing issue, but exposing this metric also surfaces a 32-bit > integer overflow in mm/damon/core.c:damos_hugepage_mem_bp(). > > The mult_frac(x, n, d) macro performs the multiplication (x % d) * n. Here x > is thp, which is an unsigned long. > > On 32-bit systems, if thp exceeds ~429,496 pages (around 1.75 GB), > (thp % total) * 10000 will silently overflow the 32-bit unsigned long type. > > This wrap-around yields an erroneously low ratio instead of the correct value. > The same overflow applies to damos_get_in_active_mem_bp() if the active or > inactive pages exceed 1.75 GB. > > Could this be fixed by casting the first argument to u64 to prevent the > overflow? As described in this patch set, this will be the default behaviour in that case. > [Severity: Low] > Does this patch also require an update to the authoritative DAMON sysfs > documentation? > > Documentation/mm/damon/design.rst explicitly lists all valid string values > for the target_metric sysfs file, but does not include hugepage_mem_bp. > Without documenting the new metric, it may remain undiscoverable for users. I will update the documentation. >> }; >> >> static ssize_t target_metric_show(struct kobject *kobj, > -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric 2026-06-16 19:35 ` Gutierrez Asier @ 2026-06-17 4:15 ` SeongJae Park 0 siblings, 0 replies; 37+ messages in thread From: SeongJae Park @ 2026-06-17 4:15 UTC (permalink / raw) To: Gutierrez Asier; +Cc: SeongJae Park, sashiko-reviews, damon On Tue, 16 Jun 2026 22:35:21 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > On 6/16/2026 6:21 PM, sashiko-bot@kernel.org wrote: > > Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: > > > > New issues: > > - [Low] The new `DAMOS_QUOTA_HUGEPAGE_MEM_BP` metric is exposed via sysfs but lacks required documentation updates. > > > > Pre-existing issues: > > - [Critical] Potential divide-by-zero in `damos_hugepage_mem_bp()` and `damos_get_in_active_mem_bp()` due to an unhandled zero denominator. > > - [High] 32-bit integer overflow in `damos_hugepage_mem_bp()` and `damos_get_in_active_mem_bp()` when calculating memory ratios. > > -- > > > > commit be304699fb94d4d73bd979237fb4d7b08b7216f7 > > Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > > > mm/damon/sysfs: support hugepage_mem_bp quota goal metric > > > > DAMOS has a new autotune policy metric: DAMOS_QUOTA_HUGEPAGE_MEM_BP. > > This patch exposes DAMOS_QUOTA_HUGEPAGE_MEM_BP through sysfs. > > > >> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c > >> index 329cfd0bbe9f3..4b5429a5b4158 100644 > >> --- a/mm/damon/sysfs-schemes.c > >> +++ b/mm/damon/sysfs-schemes.c > >> @@ -1267,6 +1267,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = { > >> .metric = DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, > >> .name = "node_eligible_mem_bp", > >> }, > >> + { > >> + .metric = DAMOS_QUOTA_HUGEPAGE_MEM_BP, > >> + .name = "hugepage_mem_bp", > >> + }, > > > > [Severity: Critical] > > This isn't a bug introduced by this patch, but exposing this metric directly > > to userspace makes a potential divide-by-zero triggerable by users > > configuring DAMON quotas. > > > > In mm/damon/core.c:damos_hugepage_mem_bp(), the denominator is computed as: > > > > total = totalram_pages() - global_zone_page_state(NR_FREE_PAGES); > > > > Due to per-CPU vmstat lag or an idle system, the free pages counter can equal > > totalram_pages(), resulting in total being 0. This is then passed to > > mult_frac(): > > > > return mult_frac(thp, 10000, total); > > > > This inherently computes thp / total, causing a strict division by zero and a > > kernel panic. The same issue exists in damos_get_in_active_mem_bp() where > > total = active + inactive, which can be 0 if the LRU lists are empty. > > > > Should a zero-check on total be added before performing the division? > DAMON is enabled after the system is fully loaded. total will not be 0 by then. Could you please further clarify what "system is fully loaded" means, reaards to what Sashiko is claiming, particularly the per-CPU vmstat lag? Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric 2026-06-16 15:03 ` [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric gutierrez.asier 2026-06-16 15:21 ` sashiko-bot @ 2026-06-17 4:16 ` SeongJae Park 1 sibling, 0 replies; 37+ messages in thread From: SeongJae Park @ 2026-06-17 4:16 UTC (permalink / raw) To: gutierrez.asier Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Tue, 16 Jun 2026 15:03:16 +0000 <gutierrez.asier@huawei-partners.com> wrote: > From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > DAMOS has a new autotune policy metric: DAMOS_QUOTA_HUGEPAGE_MEM_BP. > This patch exposes DAMOS_QUOTA_HUGEPAGE_MEM_BP through sysfs. > > Add the "hugepage_mem_bp" to the sysfs-schemes interface. > > Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com> Reviewed-by: SeongJae Park <sj@kernel.org> Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-06-16 15:03 [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning gutierrez.asier ` (2 preceding siblings ...) 2026-06-16 15:03 ` [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric gutierrez.asier @ 2026-06-17 1:44 ` SeongJae Park 2026-06-20 17:11 ` Gutierrez Asier 3 siblings, 1 reply; 37+ messages in thread From: SeongJae Park @ 2026-06-17 1:44 UTC (permalink / raw) To: gutierrez.asier Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: > From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > > Overview > ======== > > This patch set introduces a new autotuning which allows to collapse > hot regions into hugepages. > > Motivation > ========== > > Since TLB is a bottleneck for many systems[1], 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. > > Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. > However, there is no way to tune the settings. It will collapse all the > hot regions that meet the access pattern. If the server is a bare metal > database or big data server, this will also lead to eventual fragmentation. > > Additionally, currently THP is set globally. Ideally, there should be a > way to control which tasks can use huge pages. Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control cases, as we discussed [1] on RFC v3? > > Solution > ======== > > DAMON has now a way to autotune some of the variables and adjust quotas > automatically, so that DAMON is fired only under the right circumstances. > It would be nice to have something similar, but for huge pages. > > A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, > which checks the huge page consumption to total memory consumption. This > new quota mechanism reuses current autotuning architecture. > > A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate > the use of huge pages collapse autotuning. The goal is to collapse hot > regions of a given process into huge pages. The sample module launches > a kdamond thread for a certain task provided by the user through > taget_pid module argument. Hugepage goal autotuning will automatically > adjust the aggressiveness of hot region collapses. > > This sample module also has a user autotuning knob which allows the > user to adjust the aggressiveness of page collapsing. > > Benchmarks > ========== > > Huge page collapse autotuning was tested in a physicial machine with > MariaDB 10.5.29 and sysbench as the benchmark framework. > > The hugepage module was set up in the following way: > > # echo 1000 > min_age > # echo 1000 > quota_percentage_hugepage I guess this is the quota goal? What is the unit? I guess it is aparently not percentage? The name doesn't sound like very consistent or intuitive. How about hugepage_mem_bp or target_hugepage_mem_bp? > # echo $(pidof mariadbd) > taget_pid > # echo on > enabled > > The goal was to achieve 5% of the total memory used as hugepage. I guess this is what the above example is setting using 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this correct...? > Since the database was not very big, we may not be able to achieve > high amount of huge pages per total memory consumption ratio. I believe this patch series will work as you explained. But, it seems bit weird to show a test result that doesn't demonstrate what this patch is aimed to achive. Could you increase the size of the database? IIRC, you were able to show the percentage is over-achived case in an early version. > > The table below shows the memory consumption over time. Timestamp is in > second and the memory usage in is MBytes. Gaps in the timestamp means > that no changes in the hugepage consumption happened over that period > of time in MB. The total used memory is calculated as > mem_total - mem free. The huge page used is calculated as > huge_page_anon + huge_page_shmem + huge_page_file. The table also > shows the huge pages to total memory ratio. > > Hugepage autotune benchmark: > +-----------+----------------+----------------+----------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+----------------------+ > | 0 | 3044.988281 | 0 | 0% | > | 22 | 3160.207031 | 2 | 0.06% | > | 30 | 3250.90625 | 4 | 0.12% | > | 69 | 3781.238281 | 6 | 0.16% | > | 71 | 3822.226563 | 8 | 0.21% | > | 72 | 3846.578125 | 10 | 0.26% | > | 73 | 3852.402344 | 12 | 0.31% | > | 74 | 3868 | 14 | 0.36% | > | 75 | 3881.84375 | 104 | 2.68% | > | 275 | 4194.175781 | 106 | 2.52% | > +-----------+----------------+----------------+----------------------+ > After second 275, no more pages are collapsed into hugepages > > > THP (always) benchmark: > +-----------+----------------+----------------+---------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+---------------------+ > | 1 | 4489.320313 | 184 | 4.098615986 | > | 15 | 4581.871094 | 214 | 4.670580984 | > | 30 | 4757.742188 | 376 | 7.902908253 | > | 45 | 4937.574219 | 558 | 11.30109595 | > | 60 | 5147.867188 | 728 | 14.14177898 | > | 75 | 5407.0625 | 918 | 16.97779524 | > | 95 | 5668.796875 | 1040 | 18.34604455 | > | 105 | 5723.839844 | 1056 | 18.44915352 | > | 115 | 5736.84375 | 1072 | 18.68623317 | > | 125 | 5732.042969 | 1088 | 18.98101612 | > | 186 | 5753.601563 | 1184 | 20.57841488 | > | 246 | 5746.398438 | 1280 | 22.27482159 | > | 306 | 5752.128906 | 1376 | 23.92157795 | > | 367 | 5772.5625 | 1472 | 25.49994045 | > | 427 | 5832.019531 | 1568 | 26.88605536 | > | 488 | 5813.246094 | 1664 | 28.62428277 | > | 548 | 5807.621094 | 1760 | 30.30500736 | > | 598 | 5841.253906 | 1822 | 31.19193292 | > | 669 | 5982.160156 | 1854 | 30.99214918 | > | 931 | 5946.605469 | 1868 | 31.41287933 | > | 981 | 6020.207031 | 1896 | 31.49393352 | > | 991 | 5988.445313 | 1910 | 31.89475566 | > | 1011 | 5988.570313 | 1926 | 32.16126554 | > | 1032 | 6016.039063 | 1936 | 32.18064211 | > | 1575 | 6057.289063 | 1968 | 32.48978181 | > | 1606 | 6026.167969 | 2000 | 33.18858702 | > +-----------+----------------+----------------+---------------------+ > I ignored some points to make the table shorter. Anyway, the amount > of memory consumption, total and huge pages, is a lot higher than > with DAMON hugepage autotuning. Could you further clarify why it is, and what this means? > > > Performance: > Baseline (no THP, module off) -> 18,162.45 transactions per second > Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) > THP always -> 18,388.3 (+1.24%) > THP madvise -> 18,179.25 (+0.09%) > > Improvement is due to lower TLB misses So this result says THP always is much better than the Hugepage autotune in terms of the performance. Maybe you want to claim Hugepage autotune is better in terms of the memory efficiency? Could you please clarify further? > > Patches Sequence > ================ > Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning > Patch 2 -> Module that demonstrates how to use > DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL > Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes > > Changes from previous versions > ============================== > RFC 4[3] -> v1 > - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and > functions to damon_sample_hpage_... > - Make the module depend on TRANSPARENT_HUGEPAGE, since > the module will need some THP functions anyway > - Removed documentation, since this is just a sample module > - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from > damos_sysfs_add_quota_score > - Added a short description of the module in Kconfig Thank you for continuing this work! [...] > [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 > [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com > [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com > [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com > [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com > [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org > [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org > [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com > [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-06-17 1:44 ` [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning SeongJae Park @ 2026-06-20 17:11 ` Gutierrez Asier 2026-06-20 20:02 ` SeongJae Park 2026-07-06 15:03 ` Gutierrez Asier 0 siblings, 2 replies; 37+ messages in thread From: Gutierrez Asier @ 2026-06-20 17:11 UTC (permalink / raw) To: SeongJae Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel Hi SJ, So sorry, I missed your email. I just found it. Sorry for the late answer. On 6/17/2026 4:44 AM, SeongJae Park wrote: > On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: > >> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >> >> Overview >> ======== >> >> This patch set introduces a new autotuning which allows to collapse >> hot regions into hugepages. >> >> Motivation >> ========== >> >> Since TLB is a bottleneck for many systems[1], 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. >> >> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. >> However, there is no way to tune the settings. It will collapse all the >> hot regions that meet the access pattern. If the server is a bare metal >> database or big data server, this will also lead to eventual fragmentation. >> >> Additionally, currently THP is set globally. Ideally, there should be a >> way to control which tasks can use huge pages. > > Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control > cases, as we discussed [1] on RFC v3? > >> >> Solution >> ======== >> >> DAMON has now a way to autotune some of the variables and adjust quotas >> automatically, so that DAMON is fired only under the right circumstances. >> It would be nice to have something similar, but for huge pages. >> >> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, >> which checks the huge page consumption to total memory consumption. This >> new quota mechanism reuses current autotuning architecture. >> >> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate >> the use of huge pages collapse autotuning. The goal is to collapse hot >> regions of a given process into huge pages. The sample module launches >> a kdamond thread for a certain task provided by the user through >> taget_pid module argument. Hugepage goal autotuning will automatically >> adjust the aggressiveness of hot region collapses. >> >> This sample module also has a user autotuning knob which allows the >> user to adjust the aggressiveness of page collapsing. >> >> Benchmarks >> ========== >> >> Huge page collapse autotuning was tested in a physicial machine with >> MariaDB 10.5.29 and sysbench as the benchmark framework. >> >> The hugepage module was set up in the following way: >> >> # echo 1000 > min_age >> # echo 1000 > quota_percentage_hugepage > > I guess this is the quota goal? What is the unit? I guess it is aparently not > percentage? The name doesn't sound like very consistent or intuitive. How > about hugepage_mem_bp or target_hugepage_mem_bp? Right, we agreed to change the name. I will correct it. >> # echo $(pidof mariadbd) > taget_pid >> # echo on > enabled >> >> The goal was to achieve 5% of the total memory used as hugepage. > > I guess this is what the above example is setting using > 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this > correct...? I actually set it to 500. I will update the cover letter. >> Since the database was not very big, we may not be able to achieve >> high amount of huge pages per total memory consumption ratio. > > I believe this patch series will work as you explained. But, it seems bit > weird to show a test result that doesn't demonstrate what this patch is aimed > to achive. Could you increase the size of the database? IIRC, you were able > to show the percentage is over-achived case in an early version. Actually, this is what I got using the TEMPORAL quota goals. With the regular quota goals, it actually over-achieves the goal. Is this an actual bug in the TEMPORAL quota goal? >> >> The table below shows the memory consumption over time. Timestamp is in >> second and the memory usage in is MBytes. Gaps in the timestamp means >> that no changes in the hugepage consumption happened over that period >> of time in MB. The total used memory is calculated as >> mem_total - mem free. The huge page used is calculated as >> huge_page_anon + huge_page_shmem + huge_page_file. The table also >> shows the huge pages to total memory ratio. >> >> Hugepage autotune benchmark: >> +-----------+----------------+----------------+----------------------+ >> | timestamp | total mem used | huge page used | percentage hugepage | >> +-----------+----------------+----------------+----------------------+ >> | 0 | 3044.988281 | 0 | 0% | >> | 22 | 3160.207031 | 2 | 0.06% | >> | 30 | 3250.90625 | 4 | 0.12% | >> | 69 | 3781.238281 | 6 | 0.16% | >> | 71 | 3822.226563 | 8 | 0.21% | >> | 72 | 3846.578125 | 10 | 0.26% | >> | 73 | 3852.402344 | 12 | 0.31% | >> | 74 | 3868 | 14 | 0.36% | >> | 75 | 3881.84375 | 104 | 2.68% | >> | 275 | 4194.175781 | 106 | 2.52% | >> +-----------+----------------+----------------+----------------------+ >> After second 275, no more pages are collapsed into hugepages >> >> >> THP (always) benchmark: >> +-----------+----------------+----------------+---------------------+ >> | timestamp | total mem used | huge page used | percentage hugepage | >> +-----------+----------------+----------------+---------------------+ >> | 1 | 4489.320313 | 184 | 4.098615986 | >> | 15 | 4581.871094 | 214 | 4.670580984 | >> | 30 | 4757.742188 | 376 | 7.902908253 | >> | 45 | 4937.574219 | 558 | 11.30109595 | >> | 60 | 5147.867188 | 728 | 14.14177898 | >> | 75 | 5407.0625 | 918 | 16.97779524 | >> | 95 | 5668.796875 | 1040 | 18.34604455 | >> | 105 | 5723.839844 | 1056 | 18.44915352 | >> | 115 | 5736.84375 | 1072 | 18.68623317 | >> | 125 | 5732.042969 | 1088 | 18.98101612 | >> | 186 | 5753.601563 | 1184 | 20.57841488 | >> | 246 | 5746.398438 | 1280 | 22.27482159 | >> | 306 | 5752.128906 | 1376 | 23.92157795 | >> | 367 | 5772.5625 | 1472 | 25.49994045 | >> | 427 | 5832.019531 | 1568 | 26.88605536 | >> | 488 | 5813.246094 | 1664 | 28.62428277 | >> | 548 | 5807.621094 | 1760 | 30.30500736 | >> | 598 | 5841.253906 | 1822 | 31.19193292 | >> | 669 | 5982.160156 | 1854 | 30.99214918 | >> | 931 | 5946.605469 | 1868 | 31.41287933 | >> | 981 | 6020.207031 | 1896 | 31.49393352 | >> | 991 | 5988.445313 | 1910 | 31.89475566 | >> | 1011 | 5988.570313 | 1926 | 32.16126554 | >> | 1032 | 6016.039063 | 1936 | 32.18064211 | >> | 1575 | 6057.289063 | 1968 | 32.48978181 | >> | 1606 | 6026.167969 | 2000 | 33.18858702 | >> +-----------+----------------+----------------+---------------------+ >> I ignored some points to make the table shorter. Anyway, the amount >> of memory consumption, total and huge pages, is a lot higher than >> with DAMON hugepage autotuning. > > Could you further clarify why it is, and what this means Memory fragmentation. I will add information about memory fragmentation in the next cover letter. >> >> >> Performance: >> Baseline (no THP, module off) -> 18,162.45 transactions per second >> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) >> THP always -> 18,388.3 (+1.24%) >> THP madvise -> 18,179.25 (+0.09%) >> >> Improvement is due to lower TLB misses > > So this result says THP always is much better than the Hugepage autotune in > terms of the performance. Maybe you want to claim Hugepage autotune is better > in terms of the memory efficiency? Could you please clarify further? It's better than THP "never", but worse than THP "always". THP "always" is worse in terms of memory consumption, "always" is worse. >> >> Patches Sequence >> ================ >> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning >> Patch 2 -> Module that demonstrates how to use >> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL >> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes >> >> Changes from previous versions >> ============================== >> RFC 4[3] -> v1 >> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and >> functions to damon_sample_hpage_... >> - Make the module depend on TRANSPARENT_HUGEPAGE, since >> the module will need some THP functions anyway >> - Removed documentation, since this is just a sample module >> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from >> damos_sysfs_add_quota_score >> - Added a short description of the module in Kconfig > > Thank you for continuing this work! > > [...] > >> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 >> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com >> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com >> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com >> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com >> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org >> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org >> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com >> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ > > [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com > > > Thanks, > SJ > > [...] > SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix it with your feedback. -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-06-20 17:11 ` Gutierrez Asier @ 2026-06-20 20:02 ` SeongJae Park 2026-07-07 13:31 ` Gutierrez Asier 2026-07-06 15:03 ` Gutierrez Asier 1 sibling, 1 reply; 37+ messages in thread From: SeongJae Park @ 2026-06-20 20:02 UTC (permalink / raw) To: Gutierrez Asier Cc: SeongJae Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Sat, 20 Jun 2026 20:11:46 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > Hi SJ, > > So sorry, I missed your email. I just found it. Sorry for the late answer. > > On 6/17/2026 4:44 AM, SeongJae Park wrote: > > On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: > > > >> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > >> > >> Overview > >> ======== > >> > >> This patch set introduces a new autotuning which allows to collapse > >> hot regions into hugepages. > >> > >> Motivation > >> ========== > >> > >> Since TLB is a bottleneck for many systems[1], 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. > >> > >> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. > >> However, there is no way to tune the settings. It will collapse all the > >> hot regions that meet the access pattern. If the server is a bare metal > >> database or big data server, this will also lead to eventual fragmentation. > >> > >> Additionally, currently THP is set globally. Ideally, there should be a > >> way to control which tasks can use huge pages. > > > > Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control > > cases, as we discussed [1] on RFC v3? > > > >> > >> Solution > >> ======== > >> > >> DAMON has now a way to autotune some of the variables and adjust quotas > >> automatically, so that DAMON is fired only under the right circumstances. > >> It would be nice to have something similar, but for huge pages. > >> > >> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, > >> which checks the huge page consumption to total memory consumption. This > >> new quota mechanism reuses current autotuning architecture. > >> > >> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate > >> the use of huge pages collapse autotuning. The goal is to collapse hot > >> regions of a given process into huge pages. The sample module launches > >> a kdamond thread for a certain task provided by the user through > >> taget_pid module argument. Hugepage goal autotuning will automatically > >> adjust the aggressiveness of hot region collapses. > >> > >> This sample module also has a user autotuning knob which allows the > >> user to adjust the aggressiveness of page collapsing. > >> > >> Benchmarks > >> ========== > >> > >> Huge page collapse autotuning was tested in a physicial machine with > >> MariaDB 10.5.29 and sysbench as the benchmark framework. > >> > >> The hugepage module was set up in the following way: > >> > >> # echo 1000 > min_age > >> # echo 1000 > quota_percentage_hugepage > > > > I guess this is the quota goal? What is the unit? I guess it is aparently not > > percentage? The name doesn't sound like very consistent or intuitive. How > > about hugepage_mem_bp or target_hugepage_mem_bp? > Right, we agreed to change the name. I will correct it. Thank you. Because we agreed to drop the module, this could simply be dropped? > >> # echo $(pidof mariadbd) > taget_pid > >> # echo on > enabled > >> > >> The goal was to achieve 5% of the total memory used as hugepage. > > > > I guess this is what the above example is setting using > > 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this > > correct...? > I actually set it to 500. I will update the cover letter. I think changes of this series is matured and very close to land. Discrepancies in the cover letter and commit messages are my concern that blocking this series. Please keep everything up to date and in high quality, from the next version. > >> Since the database was not very big, we may not be able to achieve > >> high amount of huge pages per total memory consumption ratio. > > > > I believe this patch series will work as you explained. But, it seems bit > > weird to show a test result that doesn't demonstrate what this patch is aimed > > to achive. Could you increase the size of the database? IIRC, you were able > > to show the percentage is over-achived case in an early version. > Actually, this is what I got using the TEMPORAL quota goals. With the regular > quota goals, it actually over-achieves the goal. > > Is this an actual bug in the TEMPORAL quota goal? You mentioned "Since the database was not very big, we may not be able to ...". Based on that, I was assuming you will be able to make the goal achieved, by increasing the database size. Now you are saying about the goal. Do you mean the database size is not expected to contributed to this result? Of course TEMPORAL goal might have bugs. I find no clue from this datta, though. Do you have some evidences that make you suspect it? If so, could you please share? > >> > >> The table below shows the memory consumption over time. Timestamp is in > >> second and the memory usage in is MBytes. Gaps in the timestamp means > >> that no changes in the hugepage consumption happened over that period > >> of time in MB. The total used memory is calculated as > >> mem_total - mem free. The huge page used is calculated as > >> huge_page_anon + huge_page_shmem + huge_page_file. The table also > >> shows the huge pages to total memory ratio. > >> > >> Hugepage autotune benchmark: > >> +-----------+----------------+----------------+----------------------+ > >> | timestamp | total mem used | huge page used | percentage hugepage | > >> +-----------+----------------+----------------+----------------------+ > >> | 0 | 3044.988281 | 0 | 0% | > >> | 22 | 3160.207031 | 2 | 0.06% | > >> | 30 | 3250.90625 | 4 | 0.12% | > >> | 69 | 3781.238281 | 6 | 0.16% | > >> | 71 | 3822.226563 | 8 | 0.21% | > >> | 72 | 3846.578125 | 10 | 0.26% | > >> | 73 | 3852.402344 | 12 | 0.31% | > >> | 74 | 3868 | 14 | 0.36% | > >> | 75 | 3881.84375 | 104 | 2.68% | > >> | 275 | 4194.175781 | 106 | 2.52% | > >> +-----------+----------------+----------------+----------------------+ > >> After second 275, no more pages are collapsed into hugepages > >> > >> > >> THP (always) benchmark: > >> +-----------+----------------+----------------+---------------------+ > >> | timestamp | total mem used | huge page used | percentage hugepage | > >> +-----------+----------------+----------------+---------------------+ > >> | 1 | 4489.320313 | 184 | 4.098615986 | > >> | 15 | 4581.871094 | 214 | 4.670580984 | > >> | 30 | 4757.742188 | 376 | 7.902908253 | > >> | 45 | 4937.574219 | 558 | 11.30109595 | > >> | 60 | 5147.867188 | 728 | 14.14177898 | > >> | 75 | 5407.0625 | 918 | 16.97779524 | > >> | 95 | 5668.796875 | 1040 | 18.34604455 | > >> | 105 | 5723.839844 | 1056 | 18.44915352 | > >> | 115 | 5736.84375 | 1072 | 18.68623317 | > >> | 125 | 5732.042969 | 1088 | 18.98101612 | > >> | 186 | 5753.601563 | 1184 | 20.57841488 | > >> | 246 | 5746.398438 | 1280 | 22.27482159 | > >> | 306 | 5752.128906 | 1376 | 23.92157795 | > >> | 367 | 5772.5625 | 1472 | 25.49994045 | > >> | 427 | 5832.019531 | 1568 | 26.88605536 | > >> | 488 | 5813.246094 | 1664 | 28.62428277 | > >> | 548 | 5807.621094 | 1760 | 30.30500736 | > >> | 598 | 5841.253906 | 1822 | 31.19193292 | > >> | 669 | 5982.160156 | 1854 | 30.99214918 | > >> | 931 | 5946.605469 | 1868 | 31.41287933 | > >> | 981 | 6020.207031 | 1896 | 31.49393352 | > >> | 991 | 5988.445313 | 1910 | 31.89475566 | > >> | 1011 | 5988.570313 | 1926 | 32.16126554 | > >> | 1032 | 6016.039063 | 1936 | 32.18064211 | > >> | 1575 | 6057.289063 | 1968 | 32.48978181 | > >> | 1606 | 6026.167969 | 2000 | 33.18858702 | > >> +-----------+----------------+----------------+---------------------+ > >> I ignored some points to make the table shorter. Anyway, the amount > >> of memory consumption, total and huge pages, is a lot higher than > >> with DAMON hugepage autotuning. > > > > Could you further clarify why it is, and what this means > Memory fragmentation. I will add information about memory fragmentation > in the next cover letter. >> Yes, please. Let's make the complete story of the benchmark. > >> > >> Performance: > >> Baseline (no THP, module off) -> 18,162.45 transactions per second > >> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) > >> THP always -> 18,388.3 (+1.24%) > >> THP madvise -> 18,179.25 (+0.09%) > >> > >> Improvement is due to lower TLB misses > > > > So this result says THP always is much better than the Hugepage autotune in > > terms of the performance. Maybe you want to claim Hugepage autotune is better > > in terms of the memory efficiency? Could you please clarify further? > It's better than THP "never", but worse than THP "always". THP "always" is worse > in terms of memory consumption, "always" is worse. I think it is arguable, but yes, please make the argument clear. We can discuss only after that. Since we agreed to drop the module, you may need to do the benchmark again, using DAMON sysfs interface of 'damo'. I'd encourage 'damo' path. Extending it for ddamos_quota_hugepage_mem_bp should be easy. Let me know if you need my help. Because the change is simple, I wouldn't request you to show clear performance benefit. But I want it to clearly show the functionality. That is, by applying the new feature, we should be able to show the hugepage memory ratio is controllable. > >> > >> Patches Sequence > >> ================ > >> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning > >> Patch 2 -> Module that demonstrates how to use > >> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL > >> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes > >> > >> Changes from previous versions > >> ============================== > >> RFC 4[3] -> v1 > >> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and > >> functions to damon_sample_hpage_... > >> - Make the module depend on TRANSPARENT_HUGEPAGE, since > >> the module will need some THP functions anyway > >> - Removed documentation, since this is just a sample module > >> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from > >> damos_sysfs_add_quota_score > >> - Added a short description of the module in Kconfig > > > > Thank you for continuing this work! > > > > [...] > > > >> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 > >> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com > >> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com > >> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com > >> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com > >> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org > >> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org > >> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com > >> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ > > > > [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com > > > > > > Thanks, > > SJ > > > > [...] > > > > SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix > it with your feedback. No worries. Thank you for your grateful continued work on this. Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-06-20 20:02 ` SeongJae Park @ 2026-07-07 13:31 ` Gutierrez Asier 2026-07-07 14:10 ` SJ Park 0 siblings, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-07-07 13:31 UTC (permalink / raw) To: SeongJae Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On 6/20/2026 11:02 PM, SeongJae Park wrote: > On Sat, 20 Jun 2026 20:11:46 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > >> Hi SJ, >> >> So sorry, I missed your email. I just found it. Sorry for the late answer. >> >> On 6/17/2026 4:44 AM, SeongJae Park wrote: >>> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: >>> >>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >>>> >>>> Overview >>>> ======== >>>> >>>> This patch set introduces a new autotuning which allows to collapse >>>> hot regions into hugepages. >>>> >>>> Motivation >>>> ========== >>>> >>>> Since TLB is a bottleneck for many systems[1], 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. >>>> >>>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. >>>> However, there is no way to tune the settings. It will collapse all the >>>> hot regions that meet the access pattern. If the server is a bare metal >>>> database or big data server, this will also lead to eventual fragmentation. >>>> >>>> Additionally, currently THP is set globally. Ideally, there should be a >>>> way to control which tasks can use huge pages. >>> >>> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control >>> cases, as we discussed [1] on RFC v3? >>> >>>> >>>> Solution >>>> ======== >>>> >>>> DAMON has now a way to autotune some of the variables and adjust quotas >>>> automatically, so that DAMON is fired only under the right circumstances. >>>> It would be nice to have something similar, but for huge pages. >>>> >>>> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, >>>> which checks the huge page consumption to total memory consumption. This >>>> new quota mechanism reuses current autotuning architecture. >>>> >>>> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate >>>> the use of huge pages collapse autotuning. The goal is to collapse hot >>>> regions of a given process into huge pages. The sample module launches >>>> a kdamond thread for a certain task provided by the user through >>>> taget_pid module argument. Hugepage goal autotuning will automatically >>>> adjust the aggressiveness of hot region collapses. >>>> >>>> This sample module also has a user autotuning knob which allows the >>>> user to adjust the aggressiveness of page collapsing. >>>> >>>> Benchmarks >>>> ========== >>>> >>>> Huge page collapse autotuning was tested in a physicial machine with >>>> MariaDB 10.5.29 and sysbench as the benchmark framework. >>>> >>>> The hugepage module was set up in the following way: >>>> >>>> # echo 1000 > min_age >>>> # echo 1000 > quota_percentage_hugepage >>> >>> I guess this is the quota goal? What is the unit? I guess it is aparently not >>> percentage? The name doesn't sound like very consistent or intuitive. How >>> about hugepage_mem_bp or target_hugepage_mem_bp? >> Right, we agreed to change the name. I will correct it. > > Thank you. Because we agreed to drop the module, this could simply be dropped? > >>>> # echo $(pidof mariadbd) > taget_pid >>>> # echo on > enabled >>>> >>>> The goal was to achieve 5% of the total memory used as hugepage. >>> >>> I guess this is what the above example is setting using >>> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this >>> correct...? >> I actually set it to 500. I will update the cover letter. > > I think changes of this series is matured and very close to land. > Discrepancies in the cover letter and commit messages are my concern that > blocking this series. Please keep everything up to date and in high quality, > from the next version. I will test it with a bigger database. >>>> Since the database was not very big, we may not be able to achieve >>>> high amount of huge pages per total memory consumption ratio. >>> >>> I believe this patch series will work as you explained. But, it seems bit >>> weird to show a test result that doesn't demonstrate what this patch is aimed >>> to achive. Could you increase the size of the database? IIRC, you were able >>> to show the percentage is over-achived case in an early version. >> Actually, this is what I got using the TEMPORAL quota goals. With the regular >> quota goals, it actually over-achieves the goal. >> >> Is this an actual bug in the TEMPORAL quota goal? > > You mentioned "Since the database was not very big, we may not be able to ...". > Based on that, I was assuming you will be able to make the goal achieved, by > increasing the database size. Now you are saying about the goal. > > Do you mean the database size is not expected to contributed to this result? > > Of course TEMPORAL goal might have bugs. I find no clue from this datta, > though. Do you have some evidences that make you suspect it? If so, could you > please share? > >>>> >>>> The table below shows the memory consumption over time. Timestamp is in >>>> second and the memory usage in is MBytes. Gaps in the timestamp means >>>> that no changes in the hugepage consumption happened over that period >>>> of time in MB. The total used memory is calculated as >>>> mem_total - mem free. The huge page used is calculated as >>>> huge_page_anon + huge_page_shmem + huge_page_file. The table also >>>> shows the huge pages to total memory ratio. >>>> >>>> Hugepage autotune benchmark: >>>> +-----------+----------------+----------------+----------------------+ >>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>> +-----------+----------------+----------------+----------------------+ >>>> | 0 | 3044.988281 | 0 | 0% | >>>> | 22 | 3160.207031 | 2 | 0.06% | >>>> | 30 | 3250.90625 | 4 | 0.12% | >>>> | 69 | 3781.238281 | 6 | 0.16% | >>>> | 71 | 3822.226563 | 8 | 0.21% | >>>> | 72 | 3846.578125 | 10 | 0.26% | >>>> | 73 | 3852.402344 | 12 | 0.31% | >>>> | 74 | 3868 | 14 | 0.36% | >>>> | 75 | 3881.84375 | 104 | 2.68% | >>>> | 275 | 4194.175781 | 106 | 2.52% | >>>> +-----------+----------------+----------------+----------------------+ >>>> After second 275, no more pages are collapsed into hugepages >>>> >>>> >>>> THP (always) benchmark: >>>> +-----------+----------------+----------------+---------------------+ >>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>> +-----------+----------------+----------------+---------------------+ >>>> | 1 | 4489.320313 | 184 | 4.098615986 | >>>> | 15 | 4581.871094 | 214 | 4.670580984 | >>>> | 30 | 4757.742188 | 376 | 7.902908253 | >>>> | 45 | 4937.574219 | 558 | 11.30109595 | >>>> | 60 | 5147.867188 | 728 | 14.14177898 | >>>> | 75 | 5407.0625 | 918 | 16.97779524 | >>>> | 95 | 5668.796875 | 1040 | 18.34604455 | >>>> | 105 | 5723.839844 | 1056 | 18.44915352 | >>>> | 115 | 5736.84375 | 1072 | 18.68623317 | >>>> | 125 | 5732.042969 | 1088 | 18.98101612 | >>>> | 186 | 5753.601563 | 1184 | 20.57841488 | >>>> | 246 | 5746.398438 | 1280 | 22.27482159 | >>>> | 306 | 5752.128906 | 1376 | 23.92157795 | >>>> | 367 | 5772.5625 | 1472 | 25.49994045 | >>>> | 427 | 5832.019531 | 1568 | 26.88605536 | >>>> | 488 | 5813.246094 | 1664 | 28.62428277 | >>>> | 548 | 5807.621094 | 1760 | 30.30500736 | >>>> | 598 | 5841.253906 | 1822 | 31.19193292 | >>>> | 669 | 5982.160156 | 1854 | 30.99214918 | >>>> | 931 | 5946.605469 | 1868 | 31.41287933 | >>>> | 981 | 6020.207031 | 1896 | 31.49393352 | >>>> | 991 | 5988.445313 | 1910 | 31.89475566 | >>>> | 1011 | 5988.570313 | 1926 | 32.16126554 | >>>> | 1032 | 6016.039063 | 1936 | 32.18064211 | >>>> | 1575 | 6057.289063 | 1968 | 32.48978181 | >>>> | 1606 | 6026.167969 | 2000 | 33.18858702 | >>>> +-----------+----------------+----------------+---------------------+ >>>> I ignored some points to make the table shorter. Anyway, the amount >>>> of memory consumption, total and huge pages, is a lot higher than >>>> with DAMON hugepage autotuning. >>> >>> Could you further clarify why it is, and what this means >> Memory fragmentation. I will add information about memory fragmentation >> in the next cover letter. >> > > Yes, please. Let's make the complete story of the benchmark. > >>>> >>>> Performance: >>>> Baseline (no THP, module off) -> 18,162.45 transactions per second >>>> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) >>>> THP always -> 18,388.3 (+1.24%) >>>> THP madvise -> 18,179.25 (+0.09%) >>>> >>>> Improvement is due to lower TLB misses >>> >>> So this result says THP always is much better than the Hugepage autotune in >>> terms of the performance. Maybe you want to claim Hugepage autotune is better >>> in terms of the memory efficiency? Could you please clarify further? >> It's better than THP "never", but worse than THP "always". THP "always" is worse >> in terms of memory consumption, "always" is worse. > > I think it is arguable, but yes, please make the argument clear. We can > discuss only after that. > > Since we agreed to drop the module, you may need to do the benchmark again, > using DAMON sysfs interface of 'damo'. I'd encourage 'damo' path. Extending > it for ddamos_quota_hugepage_mem_bp should be easy. Let me know if you need my > help. > > Because the change is simple, I wouldn't request you to show clear performance > benefit. But I want it to clearly show the functionality. That is, by > applying the new feature, we should be able to show the hugepage memory ratio > is controllable. I agree. I will start testing manually through sysfs first. Once it works, I will fork damo, make small changes to support the functionality and provide all the details in the cover letter using damo. >>>> >>>> Patches Sequence >>>> ================ >>>> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning >>>> Patch 2 -> Module that demonstrates how to use >>>> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL >>>> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes >>>> >>>> Changes from previous versions >>>> ============================== >>>> RFC 4[3] -> v1 >>>> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and >>>> functions to damon_sample_hpage_... >>>> - Make the module depend on TRANSPARENT_HUGEPAGE, since >>>> the module will need some THP functions anyway >>>> - Removed documentation, since this is just a sample module >>>> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from >>>> damos_sysfs_add_quota_score >>>> - Added a short description of the module in Kconfig >>> >>> Thank you for continuing this work! >>> >>> [...] >>> >>>> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 >>>> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com >>>> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com >>>> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com >>>> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com >>>> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org >>>> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org >>>> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com >>>> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ >>> >>> [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com >>> >>> >>> Thanks, >>> SJ >>> >>> [...] >>> >> >> SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix >> it with your feedback. > > No worries. Thank you for your grateful continued work on this. > > > Thanks, > SJ > > [...] > -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-07 13:31 ` Gutierrez Asier @ 2026-07-07 14:10 ` SJ Park 2026-07-07 14:25 ` Gutierrez Asier 0 siblings, 1 reply; 37+ messages in thread From: SJ Park @ 2026-07-07 14:10 UTC (permalink / raw) To: Gutierrez Asier Cc: SJ Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel Hello Gutierrez, Thank you for your replies. I still find some of my comments are not replied, acknowledged or objected. Could you please address those all before the next revision? On Tue, 7 Jul 2026 16:31:03 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > On 6/20/2026 11:02 PM, SeongJae Park wrote: > > On Sat, 20 Jun 2026 20:11:46 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > >> Hi SJ, > >> > >> So sorry, I missed your email. I just found it. Sorry for the late answer. > >> > >> On 6/17/2026 4:44 AM, SeongJae Park wrote: > >>> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: > >>> > >>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > >>>> > >>>> Overview > >>>> ======== > >>>> > >>>> This patch set introduces a new autotuning which allows to collapse > >>>> hot regions into hugepages. > >>>> > >>>> Motivation > >>>> ========== > >>>> > >>>> Since TLB is a bottleneck for many systems[1], 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. > >>>> > >>>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. > >>>> However, there is no way to tune the settings. It will collapse all the > >>>> hot regions that meet the access pattern. If the server is a bare metal > >>>> database or big data server, this will also lead to eventual fragmentation. > >>>> > >>>> Additionally, currently THP is set globally. Ideally, there should be a > >>>> way to control which tasks can use huge pages. > >>> > >>> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control > >>> cases, as we discussed [1] on RFC v3? WDYT? > >>> > >>>> > >>>> Solution > >>>> ======== > >>>> > >>>> DAMON has now a way to autotune some of the variables and adjust quotas > >>>> automatically, so that DAMON is fired only under the right circumstances. > >>>> It would be nice to have something similar, but for huge pages. > >>>> > >>>> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, > >>>> which checks the huge page consumption to total memory consumption. This > >>>> new quota mechanism reuses current autotuning architecture. > >>>> > >>>> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate > >>>> the use of huge pages collapse autotuning. The goal is to collapse hot > >>>> regions of a given process into huge pages. The sample module launches > >>>> a kdamond thread for a certain task provided by the user through > >>>> taget_pid module argument. Hugepage goal autotuning will automatically > >>>> adjust the aggressiveness of hot region collapses. > >>>> > >>>> This sample module also has a user autotuning knob which allows the > >>>> user to adjust the aggressiveness of page collapsing. > >>>> > >>>> Benchmarks > >>>> ========== > >>>> > >>>> Huge page collapse autotuning was tested in a physicial machine with > >>>> MariaDB 10.5.29 and sysbench as the benchmark framework. > >>>> > >>>> The hugepage module was set up in the following way: > >>>> > >>>> # echo 1000 > min_age > >>>> # echo 1000 > quota_percentage_hugepage > >>> > >>> I guess this is the quota goal? What is the unit? I guess it is aparently not > >>> percentage? The name doesn't sound like very consistent or intuitive. How > >>> about hugepage_mem_bp or target_hugepage_mem_bp? > >> Right, we agreed to change the name. I will correct it. > > > > Thank you. Because we agreed to drop the module, this could simply be dropped? WDYT? > > > >>>> # echo $(pidof mariadbd) > taget_pid > >>>> # echo on > enabled > >>>> > >>>> The goal was to achieve 5% of the total memory used as hugepage. > >>> > >>> I guess this is what the above example is setting using > >>> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this > >>> correct...? > >> I actually set it to 500. I will update the cover letter. > > > > I think changes of this series is matured and very close to land. > > Discrepancies in the cover letter and commit messages are my concern that > > blocking this series. Please keep everything up to date and in high quality, > > from the next version. > I will test it with a bigger database. Thank you. Couuld you further clarify what you expect to see as the result, and how it will complete the story? > >>>> Since the database was not very big, we may not be able to achieve > >>>> high amount of huge pages per total memory consumption ratio. > >>> > >>> I believe this patch series will work as you explained. But, it seems bit > >>> weird to show a test result that doesn't demonstrate what this patch is aimed > >>> to achive. Could you increase the size of the database? IIRC, you were able > >>> to show the percentage is over-achived case in an early version. > >> Actually, this is what I got using the TEMPORAL quota goals. With the regular > >> quota goals, it actually over-achieves the goal. > >> > >> Is this an actual bug in the TEMPORAL quota goal? > > > > You mentioned "Since the database was not very big, we may not be able to ...". > > Based on that, I was assuming you will be able to make the goal achieved, by > > increasing the database size. Now you are saying about the goal. > > > > Do you mean the database size is not expected to contributed to this result? > > > > Of course TEMPORAL goal might have bugs. I find no clue from this datta, > > though. Do you have some evidences that make you suspect it? If so, could you > > please share? WDYT? > > > >>>> > >>>> The table below shows the memory consumption over time. Timestamp is in > >>>> second and the memory usage in is MBytes. Gaps in the timestamp means > >>>> that no changes in the hugepage consumption happened over that period > >>>> of time in MB. The total used memory is calculated as > >>>> mem_total - mem free. The huge page used is calculated as > >>>> huge_page_anon + huge_page_shmem + huge_page_file. The table also > >>>> shows the huge pages to total memory ratio. > >>>> > >>>> Hugepage autotune benchmark: > >>>> +-----------+----------------+----------------+----------------------+ > >>>> | timestamp | total mem used | huge page used | percentage hugepage | > >>>> +-----------+----------------+----------------+----------------------+ > >>>> | 0 | 3044.988281 | 0 | 0% | > >>>> | 22 | 3160.207031 | 2 | 0.06% | > >>>> | 30 | 3250.90625 | 4 | 0.12% | > >>>> | 69 | 3781.238281 | 6 | 0.16% | > >>>> | 71 | 3822.226563 | 8 | 0.21% | > >>>> | 72 | 3846.578125 | 10 | 0.26% | > >>>> | 73 | 3852.402344 | 12 | 0.31% | > >>>> | 74 | 3868 | 14 | 0.36% | > >>>> | 75 | 3881.84375 | 104 | 2.68% | > >>>> | 275 | 4194.175781 | 106 | 2.52% | > >>>> +-----------+----------------+----------------+----------------------+ > >>>> After second 275, no more pages are collapsed into hugepages > >>>> > >>>> > >>>> THP (always) benchmark: > >>>> +-----------+----------------+----------------+---------------------+ > >>>> | timestamp | total mem used | huge page used | percentage hugepage | > >>>> +-----------+----------------+----------------+---------------------+ > >>>> | 1 | 4489.320313 | 184 | 4.098615986 | > >>>> | 15 | 4581.871094 | 214 | 4.670580984 | > >>>> | 30 | 4757.742188 | 376 | 7.902908253 | > >>>> | 45 | 4937.574219 | 558 | 11.30109595 | > >>>> | 60 | 5147.867188 | 728 | 14.14177898 | > >>>> | 75 | 5407.0625 | 918 | 16.97779524 | > >>>> | 95 | 5668.796875 | 1040 | 18.34604455 | > >>>> | 105 | 5723.839844 | 1056 | 18.44915352 | > >>>> | 115 | 5736.84375 | 1072 | 18.68623317 | > >>>> | 125 | 5732.042969 | 1088 | 18.98101612 | > >>>> | 186 | 5753.601563 | 1184 | 20.57841488 | > >>>> | 246 | 5746.398438 | 1280 | 22.27482159 | > >>>> | 306 | 5752.128906 | 1376 | 23.92157795 | > >>>> | 367 | 5772.5625 | 1472 | 25.49994045 | > >>>> | 427 | 5832.019531 | 1568 | 26.88605536 | > >>>> | 488 | 5813.246094 | 1664 | 28.62428277 | > >>>> | 548 | 5807.621094 | 1760 | 30.30500736 | > >>>> | 598 | 5841.253906 | 1822 | 31.19193292 | > >>>> | 669 | 5982.160156 | 1854 | 30.99214918 | > >>>> | 931 | 5946.605469 | 1868 | 31.41287933 | > >>>> | 981 | 6020.207031 | 1896 | 31.49393352 | > >>>> | 991 | 5988.445313 | 1910 | 31.89475566 | > >>>> | 1011 | 5988.570313 | 1926 | 32.16126554 | > >>>> | 1032 | 6016.039063 | 1936 | 32.18064211 | > >>>> | 1575 | 6057.289063 | 1968 | 32.48978181 | > >>>> | 1606 | 6026.167969 | 2000 | 33.18858702 | > >>>> +-----------+----------------+----------------+---------------------+ > >>>> I ignored some points to make the table shorter. Anyway, the amount > >>>> of memory consumption, total and huge pages, is a lot higher than > >>>> with DAMON hugepage autotuning. > >>> > >>> Could you further clarify why it is, and what this means > >> Memory fragmentation. I will add information about memory fragmentation > >> in the next cover letter. >> > > > > Yes, please. Let's make the complete story of the benchmark. I'd like to again call out I'd like to show "complete story". I don't think additional data points that look interesting but not providing a complete story is really adding much values to this work. If you want my feedback on benchmark results first, sending benchmark results (with your analysis an discussions) without the code change could be an option. > > > >>>> > >>>> Performance: > >>>> Baseline (no THP, module off) -> 18,162.45 transactions per second > >>>> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) > >>>> THP always -> 18,388.3 (+1.24%) > >>>> THP madvise -> 18,179.25 (+0.09%) > >>>> > >>>> Improvement is due to lower TLB misses > >>> > >>> So this result says THP always is much better than the Hugepage autotune in > >>> terms of the performance. Maybe you want to claim Hugepage autotune is better > >>> in terms of the memory efficiency? Could you please clarify further? > >> It's better than THP "never", but worse than THP "always". THP "always" is worse > >> in terms of memory consumption, "always" is worse. > > > > I think it is arguable, but yes, please make the argument clear. We can > > discuss only after that. > > > > Since we agreed to drop the module, you may need to do the benchmark again, > > using DAMON sysfs interface of 'damo'. I'd encourage 'damo' path. Extending > > it for ddamos_quota_hugepage_mem_bp should be easy. Let me know if you need my > > help. > > > > Because the change is simple, I wouldn't request you to show clear performance > > benefit. But I want it to clearly show the functionality. That is, by > > applying the new feature, we should be able to show the hugepage memory ratio > > is controllable. > I agree. I will start testing manually through sysfs first. Once it works, > I will fork damo, make small changes to support the functionality and provide > all the details in the cover letter using damo. For the damo side change, you could refer to this: https://github.com/damonitor/damo/commit/8b3fc4a55ead > >>>> > >>>> Patches Sequence > >>>> ================ > >>>> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning > >>>> Patch 2 -> Module that demonstrates how to use > >>>> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL > >>>> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes > >>>> > >>>> Changes from previous versions > >>>> ============================== > >>>> RFC 4[3] -> v1 > >>>> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and > >>>> functions to damon_sample_hpage_... > >>>> - Make the module depend on TRANSPARENT_HUGEPAGE, since > >>>> the module will need some THP functions anyway > >>>> - Removed documentation, since this is just a sample module > >>>> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from > >>>> damos_sysfs_add_quota_score > >>>> - Added a short description of the module in Kconfig > >>> > >>> Thank you for continuing this work! > >>> > >>> [...] > >>> > >>>> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 > >>>> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com > >>>> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com > >>>> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com > >>>> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com > >>>> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org > >>>> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org > >>>> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com > >>>> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ > >>> > >>> [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com > >>> > >>> > >>> Thanks, > >>> SJ > >>> > >>> [...] > >>> > >> > >> SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix > >> it with your feedback. > > > > No worries. Thank you for your grateful continued work on this. > > > > > > Thanks, > > SJ > > > > [...] > > > > -- > Asier Gutierrez > Huawei Thanks, SJ ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-07 14:10 ` SJ Park @ 2026-07-07 14:25 ` Gutierrez Asier 2026-07-08 1:22 ` SJ Park 0 siblings, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-07-07 14:25 UTC (permalink / raw) To: SJ Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On 7/7/2026 5:10 PM, SJ Park wrote: > Hello Gutierrez, > > > Thank you for your replies. I still find some of my comments are not replied, > acknowledged or objected. Could you please address those all before the next > revision? > > On Tue, 7 Jul 2026 16:31:03 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > >> >> >> On 6/20/2026 11:02 PM, SeongJae Park wrote: >>> On Sat, 20 Jun 2026 20:11:46 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: >>> >>>> Hi SJ, >>>> >>>> So sorry, I missed your email. I just found it. Sorry for the late answer. >>>> >>>> On 6/17/2026 4:44 AM, SeongJae Park wrote: >>>>> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: >>>>> >>>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >>>>>> >>>>>> Overview >>>>>> ======== >>>>>> >>>>>> This patch set introduces a new autotuning which allows to collapse >>>>>> hot regions into hugepages. >>>>>> >>>>>> Motivation >>>>>> ========== >>>>>> >>>>>> Since TLB is a bottleneck for many systems[1], 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. >>>>>> >>>>>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. >>>>>> However, there is no way to tune the settings. It will collapse all the >>>>>> hot regions that meet the access pattern. If the server is a bare metal >>>>>> database or big data server, this will also lead to eventual fragmentation. >>>>>> >>>>>> Additionally, currently THP is set globally. Ideally, there should be a >>>>>> way to control which tasks can use huge pages. >>>>> >>>>> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control >>>>> cases, as we discussed [1] on RFC v3? > > WDYT? Yes, we can use prctl. However, I believe DAMON is more transparent and easier for a sysadmin. I will rephrase this sentence to explain why DAMON makes sense instead of other alternative. >>>>> >>>>>> >>>>>> Solution >>>>>> ======== >>>>>> >>>>>> DAMON has now a way to autotune some of the variables and adjust quotas >>>>>> automatically, so that DAMON is fired only under the right circumstances. >>>>>> It would be nice to have something similar, but for huge pages. >>>>>> >>>>>> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, >>>>>> which checks the huge page consumption to total memory consumption. This >>>>>> new quota mechanism reuses current autotuning architecture. >>>>>> >>>>>> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate >>>>>> the use of huge pages collapse autotuning. The goal is to collapse hot >>>>>> regions of a given process into huge pages. The sample module launches >>>>>> a kdamond thread for a certain task provided by the user through >>>>>> taget_pid module argument. Hugepage goal autotuning will automatically >>>>>> adjust the aggressiveness of hot region collapses. >>>>>> >>>>>> This sample module also has a user autotuning knob which allows the >>>>>> user to adjust the aggressiveness of page collapsing. >>>>>> >>>>>> Benchmarks >>>>>> ========== >>>>>> >>>>>> Huge page collapse autotuning was tested in a physicial machine with >>>>>> MariaDB 10.5.29 and sysbench as the benchmark framework. >>>>>> >>>>>> The hugepage module was set up in the following way: >>>>>> >>>>>> # echo 1000 > min_age >>>>>> # echo 1000 > quota_percentage_hugepage >>>>> >>>>> I guess this is the quota goal? What is the unit? I guess it is aparently not >>>>> percentage? The name doesn't sound like very consistent or intuitive. How >>>>> about hugepage_mem_bp or target_hugepage_mem_bp? >>>> Right, we agreed to change the name. I will correct it. >>> >>> Thank you. Because we agreed to drop the module, this could simply be dropped? > > WDYT? Yes, I will drop it. The new patch set will not include any of these parameters, but just the target value for the quota and a new quota metric. >>> >>>>>> # echo $(pidof mariadbd) > taget_pid >>>>>> # echo on > enabled >>>>>> >>>>>> The goal was to achieve 5% of the total memory used as hugepage. >>>>> >>>>> I guess this is what the above example is setting using >>>>> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this >>>>> correct...? >>>> I actually set it to 500. I will update the cover letter. >>> >>> I think changes of this series is matured and very close to land. >>> Discrepancies in the cover letter and commit messages are my concern that >>> blocking this series. Please keep everything up to date and in high quality, >>> from the next version. >> I will test it with a bigger database. > > Thank you. Couuld you further clarify what you expect to see as the result, > and how it will complete the story? What I expect is DAMON to keep consistent huge page usage to total memory usage ration according to the target value. Should I publish these results as well? I mean showing different target values and the actually achieved values. And theses results for different database sizes. >>>>>> Since the database was not very big, we may not be able to achieve >>>>>> high amount of huge pages per total memory consumption ratio. >>>>> >>>>> I believe this patch series will work as you explained. But, it seems bit >>>>> weird to show a test result that doesn't demonstrate what this patch is aimed >>>>> to achive. Could you increase the size of the database? IIRC, you were able >>>>> to show the percentage is over-achived case in an early version. >>>> Actually, this is what I got using the TEMPORAL quota goals. With the regular >>>> quota goals, it actually over-achieves the goal. >>>> >>>> Is this an actual bug in the TEMPORAL quota goal? >>> >>> You mentioned "Since the database was not very big, we may not be able to ...". >>> Based on that, I was assuming you will be able to make the goal achieved, by >>> increasing the database size. Now you are saying about the goal. >>> >>> Do you mean the database size is not expected to contributed to this result? >>> >>> Of course TEMPORAL goal might have bugs. I find no clue from this datta, >>> though. Do you have some evidences that make you suspect it? If so, could you >>> please share? > > WDYT? I have no idea, to be honest. I will try to test with different databasesizes with temporal and consistent policies. The behaviour was weird to me, but I don't know if this was a TEMPORAL policy issue or I didn't set the DAMON parameters correctly. >>> >>>>>> >>>>>> The table below shows the memory consumption over time. Timestamp is in >>>>>> second and the memory usage in is MBytes. Gaps in the timestamp means >>>>>> that no changes in the hugepage consumption happened over that period >>>>>> of time in MB. The total used memory is calculated as >>>>>> mem_total - mem free. The huge page used is calculated as >>>>>> huge_page_anon + huge_page_shmem + huge_page_file. The table also >>>>>> shows the huge pages to total memory ratio. >>>>>> >>>>>> Hugepage autotune benchmark: >>>>>> +-----------+----------------+----------------+----------------------+ >>>>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>>>> +-----------+----------------+----------------+----------------------+ >>>>>> | 0 | 3044.988281 | 0 | 0% | >>>>>> | 22 | 3160.207031 | 2 | 0.06% | >>>>>> | 30 | 3250.90625 | 4 | 0.12% | >>>>>> | 69 | 3781.238281 | 6 | 0.16% | >>>>>> | 71 | 3822.226563 | 8 | 0.21% | >>>>>> | 72 | 3846.578125 | 10 | 0.26% | >>>>>> | 73 | 3852.402344 | 12 | 0.31% | >>>>>> | 74 | 3868 | 14 | 0.36% | >>>>>> | 75 | 3881.84375 | 104 | 2.68% | >>>>>> | 275 | 4194.175781 | 106 | 2.52% | >>>>>> +-----------+----------------+----------------+----------------------+ >>>>>> After second 275, no more pages are collapsed into hugepages >>>>>> >>>>>> >>>>>> THP (always) benchmark: >>>>>> +-----------+----------------+----------------+---------------------+ >>>>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>>>> +-----------+----------------+----------------+---------------------+ >>>>>> | 1 | 4489.320313 | 184 | 4.098615986 | >>>>>> | 15 | 4581.871094 | 214 | 4.670580984 | >>>>>> | 30 | 4757.742188 | 376 | 7.902908253 | >>>>>> | 45 | 4937.574219 | 558 | 11.30109595 | >>>>>> | 60 | 5147.867188 | 728 | 14.14177898 | >>>>>> | 75 | 5407.0625 | 918 | 16.97779524 | >>>>>> | 95 | 5668.796875 | 1040 | 18.34604455 | >>>>>> | 105 | 5723.839844 | 1056 | 18.44915352 | >>>>>> | 115 | 5736.84375 | 1072 | 18.68623317 | >>>>>> | 125 | 5732.042969 | 1088 | 18.98101612 | >>>>>> | 186 | 5753.601563 | 1184 | 20.57841488 | >>>>>> | 246 | 5746.398438 | 1280 | 22.27482159 | >>>>>> | 306 | 5752.128906 | 1376 | 23.92157795 | >>>>>> | 367 | 5772.5625 | 1472 | 25.49994045 | >>>>>> | 427 | 5832.019531 | 1568 | 26.88605536 | >>>>>> | 488 | 5813.246094 | 1664 | 28.62428277 | >>>>>> | 548 | 5807.621094 | 1760 | 30.30500736 | >>>>>> | 598 | 5841.253906 | 1822 | 31.19193292 | >>>>>> | 669 | 5982.160156 | 1854 | 30.99214918 | >>>>>> | 931 | 5946.605469 | 1868 | 31.41287933 | >>>>>> | 981 | 6020.207031 | 1896 | 31.49393352 | >>>>>> | 991 | 5988.445313 | 1910 | 31.89475566 | >>>>>> | 1011 | 5988.570313 | 1926 | 32.16126554 | >>>>>> | 1032 | 6016.039063 | 1936 | 32.18064211 | >>>>>> | 1575 | 6057.289063 | 1968 | 32.48978181 | >>>>>> | 1606 | 6026.167969 | 2000 | 33.18858702 | >>>>>> +-----------+----------------+----------------+---------------------+ >>>>>> I ignored some points to make the table shorter. Anyway, the amount >>>>>> of memory consumption, total and huge pages, is a lot higher than >>>>>> with DAMON hugepage autotuning. >>>>> >>>>> Could you further clarify why it is, and what this means >>>> Memory fragmentation. I will add information about memory fragmentation >>>> in the next cover letter. >> >>> >>> Yes, please. Let's make the complete story of the benchmark. > > I'd like to again call out I'd like to show "complete story". I don't think > additional data points that look interesting but not providing a complete story > is really adding much values to this work. > > If you want my feedback on benchmark results first, sending benchmark results > (with your analysis an discussions) without the code change could be an option. That makes sense. Maybe I will just reply for now on to get your thoughts. >>> >>>>>> >>>>>> Performance: >>>>>> Baseline (no THP, module off) -> 18,162.45 transactions per second >>>>>> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) >>>>>> THP always -> 18,388.3 (+1.24%) >>>>>> THP madvise -> 18,179.25 (+0.09%) >>>>>> >>>>>> Improvement is due to lower TLB misses >>>>> >>>>> So this result says THP always is much better than the Hugepage autotune in >>>>> terms of the performance. Maybe you want to claim Hugepage autotune is better >>>>> in terms of the memory efficiency? Could you please clarify further? >>>> It's better than THP "never", but worse than THP "always". THP "always" is worse >>>> in terms of memory consumption, "always" is worse. >>> >>> I think it is arguable, but yes, please make the argument clear. We can >>> discuss only after that. >>> >>> Since we agreed to drop the module, you may need to do the benchmark again, >>> using DAMON sysfs interface of 'damo'. I'd encourage 'damo' path. Extending >>> it for ddamos_quota_hugepage_mem_bp should be easy. Let me know if you need my >>> help. >>> >>> Because the change is simple, I wouldn't request you to show clear performance >>> benefit. But I want it to clearly show the functionality. That is, by >>> applying the new feature, we should be able to show the hugepage memory ratio >>> is controllable. >> I agree. I will start testing manually through sysfs first. Once it works, >> I will fork damo, make small changes to support the functionality and provide >> all the details in the cover letter using damo. > > For the damo side change, you could refer to this: > https://github.com/damonitor/damo/commit/8b3fc4a55ead > >>>>>> >>>>>> Patches Sequence >>>>>> ================ >>>>>> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning >>>>>> Patch 2 -> Module that demonstrates how to use >>>>>> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL >>>>>> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes >>>>>> >>>>>> Changes from previous versions >>>>>> ============================== >>>>>> RFC 4[3] -> v1 >>>>>> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and >>>>>> functions to damon_sample_hpage_... >>>>>> - Make the module depend on TRANSPARENT_HUGEPAGE, since >>>>>> the module will need some THP functions anyway >>>>>> - Removed documentation, since this is just a sample module >>>>>> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from >>>>>> damos_sysfs_add_quota_score >>>>>> - Added a short description of the module in Kconfig >>>>> >>>>> Thank you for continuing this work! >>>>> >>>>> [...] >>>>> >>>>>> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 >>>>>> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com >>>>>> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com >>>>>> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com >>>>>> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com >>>>>> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org >>>>>> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org >>>>>> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com >>>>>> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ >>>>> >>>>> [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com >>>>> >>>>> >>>>> Thanks, >>>>> SJ >>>>> >>>>> [...] >>>>> >>>> >>>> SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix >>>> it with your feedback. >>> >>> No worries. Thank you for your grateful continued work on this. >>> >>> >>> Thanks, >>> SJ >>> >>> [...] >>> >> >> -- >> Asier Gutierrez >> Huawei > > Thanks, > SJ -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-07 14:25 ` Gutierrez Asier @ 2026-07-08 1:22 ` SJ Park 2026-07-08 14:50 ` Gutierrez Asier 0 siblings, 1 reply; 37+ messages in thread From: SJ Park @ 2026-07-08 1:22 UTC (permalink / raw) To: Gutierrez Asier Cc: SJ Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Tue, 7 Jul 2026 17:25:36 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > On 7/7/2026 5:10 PM, SJ Park wrote: > > Hello Gutierrez, > > > > > > Thank you for your replies. I still find some of my comments are not replied, > > acknowledged or objected. Could you please address those all before the next > > revision? > > > > On Tue, 7 Jul 2026 16:31:03 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > >> > >> > >> On 6/20/2026 11:02 PM, SeongJae Park wrote: > >>> On Sat, 20 Jun 2026 20:11:46 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > >>> > >>>> Hi SJ, > >>>> > >>>> So sorry, I missed your email. I just found it. Sorry for the late answer. > >>>> > >>>> On 6/17/2026 4:44 AM, SeongJae Park wrote: > >>>>> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: > >>>>> > >>>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > >>>>>> > >>>>>> Overview > >>>>>> ======== > >>>>>> > >>>>>> This patch set introduces a new autotuning which allows to collapse > >>>>>> hot regions into hugepages. > >>>>>> > >>>>>> Motivation > >>>>>> ========== > >>>>>> > >>>>>> Since TLB is a bottleneck for many systems[1], 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. > >>>>>> > >>>>>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. > >>>>>> However, there is no way to tune the settings. It will collapse all the > >>>>>> hot regions that meet the access pattern. If the server is a bare metal > >>>>>> database or big data server, this will also lead to eventual fragmentation. > >>>>>> > >>>>>> Additionally, currently THP is set globally. Ideally, there should be a > >>>>>> way to control which tasks can use huge pages. > >>>>> > >>>>> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control > >>>>> cases, as we discussed [1] on RFC v3? > > > > WDYT? > Yes, we can use prctl. However, I believe DAMON is more transparent and easier > for a sysadmin. I will rephrase this sentence to explain why DAMON makes sense > instead of other alternative. Thank you, I agree to you. But I just want the pointer be clear. Your revision plan soudns like a good plan. [...] > >>>>>> Benchmarks > >>>>>> ========== > >>>>>> > >>>>>> Huge page collapse autotuning was tested in a physicial machine with > >>>>>> MariaDB 10.5.29 and sysbench as the benchmark framework. > >>>>>> > >>>>>> The hugepage module was set up in the following way: > >>>>>> > >>>>>> # echo 1000 > min_age > >>>>>> # echo 1000 > quota_percentage_hugepage > >>>>> > >>>>> I guess this is the quota goal? What is the unit? I guess it is aparently not > >>>>> percentage? The name doesn't sound like very consistent or intuitive. How > >>>>> about hugepage_mem_bp or target_hugepage_mem_bp? > >>>> Right, we agreed to change the name. I will correct it. > >>> > >>> Thank you. Because we agreed to drop the module, this could simply be dropped? > > > > WDYT? > Yes, I will drop it. The new patch set will not include any of these parameters, > but just the target value for the quota and a new quota metric. Thank you, sounds like a good revision plan. > >>> > >>>>>> # echo $(pidof mariadbd) > taget_pid > >>>>>> # echo on > enabled > >>>>>> > >>>>>> The goal was to achieve 5% of the total memory used as hugepage. > >>>>> > >>>>> I guess this is what the above example is setting using > >>>>> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this > >>>>> correct...? > >>>> I actually set it to 500. I will update the cover letter. > >>> > >>> I think changes of this series is matured and very close to land. > >>> Discrepancies in the cover letter and commit messages are my concern that > >>> blocking this series. Please keep everything up to date and in high quality, > >>> from the next version. > >> I will test it with a bigger database. > > > > Thank you. Couuld you further clarify what you expect to see as the result, > > and how it will complete the story? > What I expect is DAMON to keep consistent huge page usage to total memory > usage ration according to the target value. Makes sense, as long as we have a sound theory. But, I'm not sure if we really have such theory. Please read my comment below for why I'm not really sure. > > Should I publish these results as well? I mean showing different target > values and the actually achieved values. And theses results for different > database sizes. Feel free to add as much data as you want to show. Nonetheless, I'd recommend adding only data that gives us clear story in a condensed way. The data on the cover letter will live forever in the git history. Let's not make it unnecessarily long. If you want to share your findings in volume for discussions, please feel free to share. But not necessarily it should be the part of the permanent history. You can send it as a mail without the code diff. Sending that as a reply to the patch series could also be a good option. > >>>>>> Since the database was not very big, we may not be able to achieve > >>>>>> high amount of huge pages per total memory consumption ratio. > >>>>> > >>>>> I believe this patch series will work as you explained. But, it seems bit > >>>>> weird to show a test result that doesn't demonstrate what this patch is aimed > >>>>> to achive. Could you increase the size of the database? IIRC, you were able > >>>>> to show the percentage is over-achived case in an early version. > >>>> Actually, this is what I got using the TEMPORAL quota goals. With the regular > >>>> quota goals, it actually over-achieves the goal. > >>>> > >>>> Is this an actual bug in the TEMPORAL quota goal? > >>> > >>> You mentioned "Since the database was not very big, we may not be able to ...". > >>> Based on that, I was assuming you will be able to make the goal achieved, by > >>> increasing the database size. Now you are saying about the goal. > >>> > >>> Do you mean the database size is not expected to contributed to this result? > >>> > >>> Of course TEMPORAL goal might have bugs. I find no clue from this datta, > >>> though. Do you have some evidences that make you suspect it? If so, could you > >>> please share? > > > > WDYT? > I have no idea, to be honest. I will try to test with different databasesizes with temporal and consistent policies. The behaviour was weird to me, > but I don't know if this was a TEMPORAL policy issue or I didn't set the > DAMON parameters correctly. Thank you for transparently sharing your thought. And this is little bit concerning me. It feels like we don't really have a good theory about what change will make what results for what reason. It rather feels like we just doing random experiments and showing the random results. I understand having data first and developing the theory driven by data is also a good approach. But I feel like this is a time to step back and think about what we're doing. IIRC, your initial experiment results on the very early version of this series looked promising. But from a point, it looked like just random. Maybe I gave you wrong change request, or some test environment has unexpectedly changed. How about summarizing what tests you did so far, what changes in the kernel and the test setup has made for each iteration, and how the results have changed? If it has been too long since the older tests, just doing the tests again or dive deep into debugging of your current setup with the all mighty printk() on core DAMON internall code can be an option. Have you also monitored DAMOS stats while the tests are ongoing? Maybe that could also be a good debugging option for understanding what's going on as expected vs not. > > >>> > >>>>>> > >>>>>> The table below shows the memory consumption over time. Timestamp is in > >>>>>> second and the memory usage in is MBytes. Gaps in the timestamp means > >>>>>> that no changes in the hugepage consumption happened over that period > >>>>>> of time in MB. The total used memory is calculated as > >>>>>> mem_total - mem free. The huge page used is calculated as > >>>>>> huge_page_anon + huge_page_shmem + huge_page_file. The table also > >>>>>> shows the huge pages to total memory ratio. > >>>>>> > >>>>>> Hugepage autotune benchmark: > >>>>>> +-----------+----------------+----------------+----------------------+ > >>>>>> | timestamp | total mem used | huge page used | percentage hugepage | > >>>>>> +-----------+----------------+----------------+----------------------+ > >>>>>> | 0 | 3044.988281 | 0 | 0% | > >>>>>> | 22 | 3160.207031 | 2 | 0.06% | > >>>>>> | 30 | 3250.90625 | 4 | 0.12% | > >>>>>> | 69 | 3781.238281 | 6 | 0.16% | > >>>>>> | 71 | 3822.226563 | 8 | 0.21% | > >>>>>> | 72 | 3846.578125 | 10 | 0.26% | > >>>>>> | 73 | 3852.402344 | 12 | 0.31% | > >>>>>> | 74 | 3868 | 14 | 0.36% | > >>>>>> | 75 | 3881.84375 | 104 | 2.68% | > >>>>>> | 275 | 4194.175781 | 106 | 2.52% | > >>>>>> +-----------+----------------+----------------+----------------------+ > >>>>>> After second 275, no more pages are collapsed into hugepages > >>>>>> > >>>>>> > >>>>>> THP (always) benchmark: > >>>>>> +-----------+----------------+----------------+---------------------+ > >>>>>> | timestamp | total mem used | huge page used | percentage hugepage | > >>>>>> +-----------+----------------+----------------+---------------------+ > >>>>>> | 1 | 4489.320313 | 184 | 4.098615986 | > >>>>>> | 15 | 4581.871094 | 214 | 4.670580984 | > >>>>>> | 30 | 4757.742188 | 376 | 7.902908253 | > >>>>>> | 45 | 4937.574219 | 558 | 11.30109595 | > >>>>>> | 60 | 5147.867188 | 728 | 14.14177898 | > >>>>>> | 75 | 5407.0625 | 918 | 16.97779524 | > >>>>>> | 95 | 5668.796875 | 1040 | 18.34604455 | > >>>>>> | 105 | 5723.839844 | 1056 | 18.44915352 | > >>>>>> | 115 | 5736.84375 | 1072 | 18.68623317 | > >>>>>> | 125 | 5732.042969 | 1088 | 18.98101612 | > >>>>>> | 186 | 5753.601563 | 1184 | 20.57841488 | > >>>>>> | 246 | 5746.398438 | 1280 | 22.27482159 | > >>>>>> | 306 | 5752.128906 | 1376 | 23.92157795 | > >>>>>> | 367 | 5772.5625 | 1472 | 25.49994045 | > >>>>>> | 427 | 5832.019531 | 1568 | 26.88605536 | > >>>>>> | 488 | 5813.246094 | 1664 | 28.62428277 | > >>>>>> | 548 | 5807.621094 | 1760 | 30.30500736 | > >>>>>> | 598 | 5841.253906 | 1822 | 31.19193292 | > >>>>>> | 669 | 5982.160156 | 1854 | 30.99214918 | > >>>>>> | 931 | 5946.605469 | 1868 | 31.41287933 | > >>>>>> | 981 | 6020.207031 | 1896 | 31.49393352 | > >>>>>> | 991 | 5988.445313 | 1910 | 31.89475566 | > >>>>>> | 1011 | 5988.570313 | 1926 | 32.16126554 | > >>>>>> | 1032 | 6016.039063 | 1936 | 32.18064211 | > >>>>>> | 1575 | 6057.289063 | 1968 | 32.48978181 | > >>>>>> | 1606 | 6026.167969 | 2000 | 33.18858702 | > >>>>>> +-----------+----------------+----------------+---------------------+ > >>>>>> I ignored some points to make the table shorter. Anyway, the amount > >>>>>> of memory consumption, total and huge pages, is a lot higher than > >>>>>> with DAMON hugepage autotuning. > >>>>> > >>>>> Could you further clarify why it is, and what this means > >>>> Memory fragmentation. I will add information about memory fragmentation > >>>> in the next cover letter. >> > >>> > >>> Yes, please. Let's make the complete story of the benchmark. > > > > I'd like to again call out I'd like to show "complete story". I don't think > > additional data points that look interesting but not providing a complete story > > is really adding much values to this work. > > > > If you want my feedback on benchmark results first, sending benchmark results > > (with your analysis an discussions) without the code change could be an option. > That makes sense. Maybe I will just reply for now on to get your thoughts. I suggested to take step back and look back what we tested so far to get a better idea on theory. But, yes, adding even more data shouldn't harm us. Please feel free to share your findings. Thank you for replying to all my comments. To recap, let's keep discussing about the test. Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-08 1:22 ` SJ Park @ 2026-07-08 14:50 ` Gutierrez Asier 2026-07-09 0:52 ` SJ Park 0 siblings, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-07-08 14:50 UTC (permalink / raw) To: SJ Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel Hi SJ, On 7/8/2026 4:22 AM, SJ Park wrote: > On Tue, 7 Jul 2026 17:25:36 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > >> >> >> On 7/7/2026 5:10 PM, SJ Park wrote: >>> Hello Gutierrez, >>> >>> >>> Thank you for your replies. I still find some of my comments are not replied, >>> acknowledged or objected. Could you please address those all before the next >>> revision? >>> >>> On Tue, 7 Jul 2026 16:31:03 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: >>> >>>> >>>> >>>> On 6/20/2026 11:02 PM, SeongJae Park wrote: >>>>> On Sat, 20 Jun 2026 20:11:46 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: >>>>> >>>>>> Hi SJ, >>>>>> >>>>>> So sorry, I missed your email. I just found it. Sorry for the late answer. >>>>>> >>>>>> On 6/17/2026 4:44 AM, SeongJae Park wrote: >>>>>>> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: >>>>>>> >>>>>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >>>>>>>> >>>>>>>> Overview >>>>>>>> ======== >>>>>>>> >>>>>>>> This patch set introduces a new autotuning which allows to collapse >>>>>>>> hot regions into hugepages. >>>>>>>> >>>>>>>> Motivation >>>>>>>> ========== >>>>>>>> >>>>>>>> Since TLB is a bottleneck for many systems[1], 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. >>>>>>>> >>>>>>>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. >>>>>>>> However, there is no way to tune the settings. It will collapse all the >>>>>>>> hot regions that meet the access pattern. If the server is a bare metal >>>>>>>> database or big data server, this will also lead to eventual fragmentation. >>>>>>>> >>>>>>>> Additionally, currently THP is set globally. Ideally, there should be a >>>>>>>> way to control which tasks can use huge pages. >>>>>>> >>>>>>> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control >>>>>>> cases, as we discussed [1] on RFC v3? >>> >>> WDYT? >> Yes, we can use prctl. However, I believe DAMON is more transparent and easier >> for a sysadmin. I will rephrase this sentence to explain why DAMON makes sense >> instead of other alternative. > > Thank you, I agree to you. But I just want the pointer be clear. Your > revision plan soudns like a good plan. > > [...] >>>>>>>> Benchmarks >>>>>>>> ========== >>>>>>>> >>>>>>>> Huge page collapse autotuning was tested in a physicial machine with >>>>>>>> MariaDB 10.5.29 and sysbench as the benchmark framework. >>>>>>>> >>>>>>>> The hugepage module was set up in the following way: >>>>>>>> >>>>>>>> # echo 1000 > min_age >>>>>>>> # echo 1000 > quota_percentage_hugepage >>>>>>> >>>>>>> I guess this is the quota goal? What is the unit? I guess it is aparently not >>>>>>> percentage? The name doesn't sound like very consistent or intuitive. How >>>>>>> about hugepage_mem_bp or target_hugepage_mem_bp? >>>>>> Right, we agreed to change the name. I will correct it. >>>>> >>>>> Thank you. Because we agreed to drop the module, this could simply be dropped? >>> >>> WDYT? >> Yes, I will drop it. The new patch set will not include any of these parameters, >> but just the target value for the quota and a new quota metric. > > Thank you, sounds like a good revision plan. > >>>>> >>>>>>>> # echo $(pidof mariadbd) > taget_pid >>>>>>>> # echo on > enabled >>>>>>>> >>>>>>>> The goal was to achieve 5% of the total memory used as hugepage. >>>>>>> >>>>>>> I guess this is what the above example is setting using >>>>>>> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this >>>>>>> correct...? >>>>>> I actually set it to 500. I will update the cover letter. >>>>> >>>>> I think changes of this series is matured and very close to land. >>>>> Discrepancies in the cover letter and commit messages are my concern that >>>>> blocking this series. Please keep everything up to date and in high quality, >>>>> from the next version. >>>> I will test it with a bigger database. >>> >>> Thank you. Couuld you further clarify what you expect to see as the result, >>> and how it will complete the story? >> What I expect is DAMON to keep consistent huge page usage to total memory >> usage ration according to the target value. > > Makes sense, as long as we have a sound theory. But, I'm not sure if we really > have such theory. Please read my comment below for why I'm not really sure. > >> >> Should I publish these results as well? I mean showing different target >> values and the actually achieved values. And theses results for different >> database sizes. > > Feel free to add as much data as you want to show. Nonetheless, I'd recommend > adding only data that gives us clear story in a condensed way. The data on the > cover letter will live forever in the git history. Let's not make it > unnecessarily long. > > If you want to share your findings in volume for discussions, please feel free > to share. But not necessarily it should be the part of the permanent history. > You can send it as a mail without the code diff. Sending that as a reply to > the patch series could also be a good option. > >>>>>>>> Since the database was not very big, we may not be able to achieve >>>>>>>> high amount of huge pages per total memory consumption ratio. >>>>>>> >>>>>>> I believe this patch series will work as you explained. But, it seems bit >>>>>>> weird to show a test result that doesn't demonstrate what this patch is aimed >>>>>>> to achive. Could you increase the size of the database? IIRC, you were able >>>>>>> to show the percentage is over-achived case in an early version. >>>>>> Actually, this is what I got using the TEMPORAL quota goals. With the regular >>>>>> quota goals, it actually over-achieves the goal. >>>>>> >>>>>> Is this an actual bug in the TEMPORAL quota goal? >>>>> >>>>> You mentioned "Since the database was not very big, we may not be able to ...". >>>>> Based on that, I was assuming you will be able to make the goal achieved, by >>>>> increasing the database size. Now you are saying about the goal. >>>>> >>>>> Do you mean the database size is not expected to contributed to this result? >>>>> >>>>> Of course TEMPORAL goal might have bugs. I find no clue from this datta, >>>>> though. Do you have some evidences that make you suspect it? If so, could you >>>>> please share? >>> >>> WDYT? >> I have no idea, to be honest. I will try to test with different databasesizes with temporal and consistent policies. The behaviour was weird to me, >> but I don't know if this was a TEMPORAL policy issue or I didn't set the >> DAMON parameters correctly. > > Thank you for transparently sharing your thought. And this is little bit > concerning me. It feels like we don't really have a good theory about what > change will make what results for what reason. It rather feels like we just > doing random experiments and showing the random results. > > I understand having data first and developing the theory driven by data is also > a good approach. But I feel like this is a time to step back and think about > what we're doing. > > IIRC, your initial experiment results on the very early version of this series > looked promising. But from a point, it looked like just random. Maybe I gave > you wrong change request, or some test environment has unexpectedly changed. > > How about summarizing what tests you did so far, what changes in the kernel and > the test setup has made for each iteration, and how the results have changed? > > If it has been too long since the older tests, just doing the tests again or > dive deep into debugging of your current setup with the all mighty printk() on > core DAMON internall code can be an option. > > Have you also monitored DAMOS stats while the tests are ongoing? Maybe that > could also be a good debugging option for understanding what's going on as > expected vs not. The problem I've been having is inconsistent results. This may be due to thefact that I'm testing primarily with database, which contains a lot of variable data, like indexes that may be hit sometimes, and other times not, different data distribution, etc. I've been trying to get a test as consistent as possible, pinning the database to a single NUMA node and the tests script to another one, avoid network traffic, etc. I am almost done getting some consistent data. Maybe I can use perf to get DAMOS tracing. Would that make it? >> >>>>> >>>>>>>> >>>>>>>> The table below shows the memory consumption over time. Timestamp is in >>>>>>>> second and the memory usage in is MBytes. Gaps in the timestamp means >>>>>>>> that no changes in the hugepage consumption happened over that period >>>>>>>> of time in MB. The total used memory is calculated as >>>>>>>> mem_total - mem free. The huge page used is calculated as >>>>>>>> huge_page_anon + huge_page_shmem + huge_page_file. The table also >>>>>>>> shows the huge pages to total memory ratio. >>>>>>>> >>>>>>>> Hugepage autotune benchmark: >>>>>>>> +-----------+----------------+----------------+----------------------+ >>>>>>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>>>>>> +-----------+----------------+----------------+----------------------+ >>>>>>>> | 0 | 3044.988281 | 0 | 0% | >>>>>>>> | 22 | 3160.207031 | 2 | 0.06% | >>>>>>>> | 30 | 3250.90625 | 4 | 0.12% | >>>>>>>> | 69 | 3781.238281 | 6 | 0.16% | >>>>>>>> | 71 | 3822.226563 | 8 | 0.21% | >>>>>>>> | 72 | 3846.578125 | 10 | 0.26% | >>>>>>>> | 73 | 3852.402344 | 12 | 0.31% | >>>>>>>> | 74 | 3868 | 14 | 0.36% | >>>>>>>> | 75 | 3881.84375 | 104 | 2.68% | >>>>>>>> | 275 | 4194.175781 | 106 | 2.52% | >>>>>>>> +-----------+----------------+----------------+----------------------+ >>>>>>>> After second 275, no more pages are collapsed into hugepages >>>>>>>> >>>>>>>> >>>>>>>> THP (always) benchmark: >>>>>>>> +-----------+----------------+----------------+---------------------+ >>>>>>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>>>>>> +-----------+----------------+----------------+---------------------+ >>>>>>>> | 1 | 4489.320313 | 184 | 4.098615986 | >>>>>>>> | 15 | 4581.871094 | 214 | 4.670580984 | >>>>>>>> | 30 | 4757.742188 | 376 | 7.902908253 | >>>>>>>> | 45 | 4937.574219 | 558 | 11.30109595 | >>>>>>>> | 60 | 5147.867188 | 728 | 14.14177898 | >>>>>>>> | 75 | 5407.0625 | 918 | 16.97779524 | >>>>>>>> | 95 | 5668.796875 | 1040 | 18.34604455 | >>>>>>>> | 105 | 5723.839844 | 1056 | 18.44915352 | >>>>>>>> | 115 | 5736.84375 | 1072 | 18.68623317 | >>>>>>>> | 125 | 5732.042969 | 1088 | 18.98101612 | >>>>>>>> | 186 | 5753.601563 | 1184 | 20.57841488 | >>>>>>>> | 246 | 5746.398438 | 1280 | 22.27482159 | >>>>>>>> | 306 | 5752.128906 | 1376 | 23.92157795 | >>>>>>>> | 367 | 5772.5625 | 1472 | 25.49994045 | >>>>>>>> | 427 | 5832.019531 | 1568 | 26.88605536 | >>>>>>>> | 488 | 5813.246094 | 1664 | 28.62428277 | >>>>>>>> | 548 | 5807.621094 | 1760 | 30.30500736 | >>>>>>>> | 598 | 5841.253906 | 1822 | 31.19193292 | >>>>>>>> | 669 | 5982.160156 | 1854 | 30.99214918 | >>>>>>>> | 931 | 5946.605469 | 1868 | 31.41287933 | >>>>>>>> | 981 | 6020.207031 | 1896 | 31.49393352 | >>>>>>>> | 991 | 5988.445313 | 1910 | 31.89475566 | >>>>>>>> | 1011 | 5988.570313 | 1926 | 32.16126554 | >>>>>>>> | 1032 | 6016.039063 | 1936 | 32.18064211 | >>>>>>>> | 1575 | 6057.289063 | 1968 | 32.48978181 | >>>>>>>> | 1606 | 6026.167969 | 2000 | 33.18858702 | >>>>>>>> +-----------+----------------+----------------+---------------------+ >>>>>>>> I ignored some points to make the table shorter. Anyway, the amount >>>>>>>> of memory consumption, total and huge pages, is a lot higher than >>>>>>>> with DAMON hugepage autotuning. >>>>>>> >>>>>>> Could you further clarify why it is, and what this means >>>>>> Memory fragmentation. I will add information about memory fragmentation >>>>>> in the next cover letter. >> >>>>> >>>>> Yes, please. Let's make the complete story of the benchmark. >>> >>> I'd like to again call out I'd like to show "complete story". I don't think >>> additional data points that look interesting but not providing a complete story >>> is really adding much values to this work. >>> >>> If you want my feedback on benchmark results first, sending benchmark results >>> (with your analysis an discussions) without the code change could be an option. >> That makes sense. Maybe I will just reply for now on to get your thoughts. > > I suggested to take step back and look back what we tested so far to get a > better idea on theory. But, yes, adding even more data shouldn't harm us. > Please feel free to share your findings. > > Thank you for replying to all my comments. To recap, let's keep discussing > about the test. > > > Thanks, > SJ > > [...] Thanks to you. I will keep testing and keep you posted in the coming days. -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-08 14:50 ` Gutierrez Asier @ 2026-07-09 0:52 ` SJ Park 0 siblings, 0 replies; 37+ messages in thread From: SJ Park @ 2026-07-09 0:52 UTC (permalink / raw) To: Gutierrez Asier Cc: SJ Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Wed, 8 Jul 2026 17:50:57 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > Hi SJ, > > On 7/8/2026 4:22 AM, SJ Park wrote: > > On Tue, 7 Jul 2026 17:25:36 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: [...] > >> I have no idea, to be honest. I will try to test with different databasesizes with temporal and consistent policies. The behaviour was weird to me, > >> but I don't know if this was a TEMPORAL policy issue or I didn't set the > >> DAMON parameters correctly. > > > > Thank you for transparently sharing your thought. And this is little bit > > concerning me. It feels like we don't really have a good theory about what > > change will make what results for what reason. It rather feels like we just > > doing random experiments and showing the random results. > > > > I understand having data first and developing the theory driven by data is also > > a good approach. But I feel like this is a time to step back and think about > > what we're doing. > > > > IIRC, your initial experiment results on the very early version of this series > > looked promising. But from a point, it looked like just random. Maybe I gave > > you wrong change request, or some test environment has unexpectedly changed. > > > > How about summarizing what tests you did so far, what changes in the kernel and > > the test setup has made for each iteration, and how the results have changed? > > > > If it has been too long since the older tests, just doing the tests again or > > dive deep into debugging of your current setup with the all mighty printk() on > > core DAMON internall code can be an option. > > > > Have you also monitored DAMOS stats while the tests are ongoing? Maybe that > > could also be a good debugging option for understanding what's going on as > > expected vs not. > The problem I've been having is inconsistent results. This may be due to thefact that I'm testing primarily with database, which contains a lot of > variable data, like indexes that may be hit sometimes, and other times not, > different data distribution, etc. Makes sense. Testing is another challenging area of arts. If you find it is too difficult to have a stable test setup, I wouldn't mind using more artificial test setup for test results on this series' cover letter. I'd request it to be only makes sense and shows a sane and complete story. It would be really great if you can apply this on more realistic environments and share the wins. But that's not necessarily a blocker of this series in my opinion. > > I've been trying to get a test as consistent as possible, pinning the > database to a single NUMA node and the tests script to another one, avoid > network traffic, etc. > > I am almost done getting some consistent data. Cool. > > Maybe I can use perf to get DAMOS tracing. Would that make it? Yes, that should work. 'damo' also provides a wrapper of 'perf' for tracing purpose. If you want to try it, I'd suggest something like below: damo report trace --event damon:damos_esz damon:damos_stat_after_apply_interval [...] > Thanks to you. I will keep testing and keep you posted in the coming days. You're welcome. No rush. Take your time and fun :) Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-06-20 17:11 ` Gutierrez Asier 2026-06-20 20:02 ` SeongJae Park @ 2026-07-06 15:03 ` Gutierrez Asier 2026-07-06 15:16 ` SJ Park 1 sibling, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-07-06 15:03 UTC (permalink / raw) To: SeongJae Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel Hi SJ, On 6/20/2026 8:11 PM, Gutierrez Asier wrote: > Hi SJ, > > So sorry, I missed your email. I just found it. Sorry for the late answer. > > On 6/17/2026 4:44 AM, SeongJae Park wrote: >> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: >> >>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >>> >>> Overview >>> ======== >>> >>> This patch set introduces a new autotuning which allows to collapse >>> hot regions into hugepages. >>> >>> Motivation >>> ========== >>> >>> Since TLB is a bottleneck for many systems[1], 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. >>> >>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. >>> However, there is no way to tune the settings. It will collapse all the >>> hot regions that meet the access pattern. If the server is a bare metal >>> database or big data server, this will also lead to eventual fragmentation. >>> >>> Additionally, currently THP is set globally. Ideally, there should be a >>> way to control which tasks can use huge pages. >> >> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control >> cases, as we discussed [1] on RFC v3? >> >>> >>> Solution >>> ======== >>> >>> DAMON has now a way to autotune some of the variables and adjust quotas >>> automatically, so that DAMON is fired only under the right circumstances. >>> It would be nice to have something similar, but for huge pages. >>> >>> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, >>> which checks the huge page consumption to total memory consumption. This >>> new quota mechanism reuses current autotuning architecture. >>> >>> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate >>> the use of huge pages collapse autotuning. The goal is to collapse hot >>> regions of a given process into huge pages. The sample module launches >>> a kdamond thread for a certain task provided by the user through >>> taget_pid module argument. Hugepage goal autotuning will automatically >>> adjust the aggressiveness of hot region collapses. >>> >>> This sample module also has a user autotuning knob which allows the >>> user to adjust the aggressiveness of page collapsing. >>> >>> Benchmarks >>> ========== >>> >>> Huge page collapse autotuning was tested in a physicial machine with >>> MariaDB 10.5.29 and sysbench as the benchmark framework. >>> >>> The hugepage module was set up in the following way: >>> >>> # echo 1000 > min_age >>> # echo 1000 > quota_percentage_hugepage >> >> I guess this is the quota goal? What is the unit? I guess it is aparently not >> percentage? The name doesn't sound like very consistent or intuitive. How >> about hugepage_mem_bp or target_hugepage_mem_bp? > Right, we agreed to change the name. I will correct it. >>> # echo $(pidof mariadbd) > taget_pid >>> # echo on > enabled >>> >>> The goal was to achieve 5% of the total memory used as hugepage. >> >> I guess this is what the above example is setting using >> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this >> correct...? > I actually set it to 500. I will update the cover letter. >>> Since the database was not very big, we may not be able to achieve >>> high amount of huge pages per total memory consumption ratio. >> >> I believe this patch series will work as you explained. But, it seems bit >> weird to show a test result that doesn't demonstrate what this patch is aimed >> to achive. Could you increase the size of the database? IIRC, you were able >> to show the percentage is over-achived case in an early version. > Actually, this is what I got using the TEMPORAL quota goals. With the regular > quota goals, it actually over-achieves the goal. > > Is this an actual bug in the TEMPORAL quota goal? >>> >>> The table below shows the memory consumption over time. Timestamp is in >>> second and the memory usage in is MBytes. Gaps in the timestamp means >>> that no changes in the hugepage consumption happened over that period >>> of time in MB. The total used memory is calculated as >>> mem_total - mem free. The huge page used is calculated as >>> huge_page_anon + huge_page_shmem + huge_page_file. The table also >>> shows the huge pages to total memory ratio. >>> >>> Hugepage autotune benchmark: >>> +-----------+----------------+----------------+----------------------+ >>> | timestamp | total mem used | huge page used | percentage hugepage | >>> +-----------+----------------+----------------+----------------------+ >>> | 0 | 3044.988281 | 0 | 0% | >>> | 22 | 3160.207031 | 2 | 0.06% | >>> | 30 | 3250.90625 | 4 | 0.12% | >>> | 69 | 3781.238281 | 6 | 0.16% | >>> | 71 | 3822.226563 | 8 | 0.21% | >>> | 72 | 3846.578125 | 10 | 0.26% | >>> | 73 | 3852.402344 | 12 | 0.31% | >>> | 74 | 3868 | 14 | 0.36% | >>> | 75 | 3881.84375 | 104 | 2.68% | >>> | 275 | 4194.175781 | 106 | 2.52% | >>> +-----------+----------------+----------------+----------------------+ >>> After second 275, no more pages are collapsed into hugepages >>> >>> >>> THP (always) benchmark: >>> +-----------+----------------+----------------+---------------------+ >>> | timestamp | total mem used | huge page used | percentage hugepage | >>> +-----------+----------------+----------------+---------------------+ >>> | 1 | 4489.320313 | 184 | 4.098615986 | >>> | 15 | 4581.871094 | 214 | 4.670580984 | >>> | 30 | 4757.742188 | 376 | 7.902908253 | >>> | 45 | 4937.574219 | 558 | 11.30109595 | >>> | 60 | 5147.867188 | 728 | 14.14177898 | >>> | 75 | 5407.0625 | 918 | 16.97779524 | >>> | 95 | 5668.796875 | 1040 | 18.34604455 | >>> | 105 | 5723.839844 | 1056 | 18.44915352 | >>> | 115 | 5736.84375 | 1072 | 18.68623317 | >>> | 125 | 5732.042969 | 1088 | 18.98101612 | >>> | 186 | 5753.601563 | 1184 | 20.57841488 | >>> | 246 | 5746.398438 | 1280 | 22.27482159 | >>> | 306 | 5752.128906 | 1376 | 23.92157795 | >>> | 367 | 5772.5625 | 1472 | 25.49994045 | >>> | 427 | 5832.019531 | 1568 | 26.88605536 | >>> | 488 | 5813.246094 | 1664 | 28.62428277 | >>> | 548 | 5807.621094 | 1760 | 30.30500736 | >>> | 598 | 5841.253906 | 1822 | 31.19193292 | >>> | 669 | 5982.160156 | 1854 | 30.99214918 | >>> | 931 | 5946.605469 | 1868 | 31.41287933 | >>> | 981 | 6020.207031 | 1896 | 31.49393352 | >>> | 991 | 5988.445313 | 1910 | 31.89475566 | >>> | 1011 | 5988.570313 | 1926 | 32.16126554 | >>> | 1032 | 6016.039063 | 1936 | 32.18064211 | >>> | 1575 | 6057.289063 | 1968 | 32.48978181 | >>> | 1606 | 6026.167969 | 2000 | 33.18858702 | >>> +-----------+----------------+----------------+---------------------+ >>> I ignored some points to make the table shorter. Anyway, the amount >>> of memory consumption, total and huge pages, is a lot higher than >>> with DAMON hugepage autotuning. >> >> Could you further clarify why it is, and what this means > Memory fragmentation. I will add information about memory fragmentation > in the next cover letter. >> >>> >>> Performance: >>> Baseline (no THP, module off) -> 18,162.45 transactions per second >>> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) >>> THP always -> 18,388.3 (+1.24%) >>> THP madvise -> 18,179.25 (+0.09%) >>> >>> Improvement is due to lower TLB misses >> >> So this result says THP always is much better than the Hugepage autotune in >> terms of the performance. Maybe you want to claim Hugepage autotune is better >> in terms of the memory efficiency? Could you please clarify further? > It's better than THP "never", but worse than THP "always". THP "always" is worse > in terms of memory consumption, "always" is worse. >>> >>> Patches Sequence >>> ================ >>> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning >>> Patch 2 -> Module that demonstrates how to use >>> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL >>> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes >>> >>> Changes from previous versions >>> ============================== >>> RFC 4[3] -> v1 >>> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and >>> functions to damon_sample_hpage_... >>> - Make the module depend on TRANSPARENT_HUGEPAGE, since >>> the module will need some THP functions anyway >>> - Removed documentation, since this is just a sample module >>> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from >>> damos_sysfs_add_quota_score >>> - Added a short description of the module in Kconfig >> >> Thank you for continuing this work! >> >> [...] >> >>> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 >>> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com >>> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com >>> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com >>> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com >>> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org >>> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org >>> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com >>> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ >> >> [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com >> >> >> Thanks, >> SJ >> >> [...] >> > > SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix > it with your feedback. > I didn't get a reply to this email. I will update the cover letter and submit a new patch set soon. -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-06 15:03 ` Gutierrez Asier @ 2026-07-06 15:16 ` SJ Park 2026-07-13 11:30 ` Gutierrez Asier 0 siblings, 1 reply; 37+ messages in thread From: SJ Park @ 2026-07-06 15:16 UTC (permalink / raw) To: Gutierrez Asier Cc: SJ Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Mon, 6 Jul 2026 18:03:03 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > Hi SJ, > > On 6/20/2026 8:11 PM, Gutierrez Asier wrote: > > Hi SJ, > > > > So sorry, I missed your email. I just found it. Sorry for the late answer. > > > > On 6/17/2026 4:44 AM, SeongJae Park wrote: > >> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: > >> > >>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > >>> > >>> Overview > >>> ======== > >>> > >>> This patch set introduces a new autotuning which allows to collapse > >>> hot regions into hugepages. > >>> > >>> Motivation > >>> ========== > >>> > >>> Since TLB is a bottleneck for many systems[1], 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. > >>> > >>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. > >>> However, there is no way to tune the settings. It will collapse all the > >>> hot regions that meet the access pattern. If the server is a bare metal > >>> database or big data server, this will also lead to eventual fragmentation. > >>> > >>> Additionally, currently THP is set globally. Ideally, there should be a > >>> way to control which tasks can use huge pages. > >> > >> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control > >> cases, as we discussed [1] on RFC v3? > >> > >>> > >>> Solution > >>> ======== > >>> > >>> DAMON has now a way to autotune some of the variables and adjust quotas > >>> automatically, so that DAMON is fired only under the right circumstances. > >>> It would be nice to have something similar, but for huge pages. > >>> > >>> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, > >>> which checks the huge page consumption to total memory consumption. This > >>> new quota mechanism reuses current autotuning architecture. > >>> > >>> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate > >>> the use of huge pages collapse autotuning. The goal is to collapse hot > >>> regions of a given process into huge pages. The sample module launches > >>> a kdamond thread for a certain task provided by the user through > >>> taget_pid module argument. Hugepage goal autotuning will automatically > >>> adjust the aggressiveness of hot region collapses. > >>> > >>> This sample module also has a user autotuning knob which allows the > >>> user to adjust the aggressiveness of page collapsing. > >>> > >>> Benchmarks > >>> ========== > >>> > >>> Huge page collapse autotuning was tested in a physicial machine with > >>> MariaDB 10.5.29 and sysbench as the benchmark framework. > >>> > >>> The hugepage module was set up in the following way: > >>> > >>> # echo 1000 > min_age > >>> # echo 1000 > quota_percentage_hugepage > >> > >> I guess this is the quota goal? What is the unit? I guess it is aparently not > >> percentage? The name doesn't sound like very consistent or intuitive. How > >> about hugepage_mem_bp or target_hugepage_mem_bp? > > Right, we agreed to change the name. I will correct it. > >>> # echo $(pidof mariadbd) > taget_pid > >>> # echo on > enabled > >>> > >>> The goal was to achieve 5% of the total memory used as hugepage. > >> > >> I guess this is what the above example is setting using > >> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this > >> correct...? > > I actually set it to 500. I will update the cover letter. > >>> Since the database was not very big, we may not be able to achieve > >>> high amount of huge pages per total memory consumption ratio. > >> > >> I believe this patch series will work as you explained. But, it seems bit > >> weird to show a test result that doesn't demonstrate what this patch is aimed > >> to achive. Could you increase the size of the database? IIRC, you were able > >> to show the percentage is over-achived case in an early version. > > Actually, this is what I got using the TEMPORAL quota goals. With the regular > > quota goals, it actually over-achieves the goal. > > > > Is this an actual bug in the TEMPORAL quota goal? > >>> > >>> The table below shows the memory consumption over time. Timestamp is in > >>> second and the memory usage in is MBytes. Gaps in the timestamp means > >>> that no changes in the hugepage consumption happened over that period > >>> of time in MB. The total used memory is calculated as > >>> mem_total - mem free. The huge page used is calculated as > >>> huge_page_anon + huge_page_shmem + huge_page_file. The table also > >>> shows the huge pages to total memory ratio. > >>> > >>> Hugepage autotune benchmark: > >>> +-----------+----------------+----------------+----------------------+ > >>> | timestamp | total mem used | huge page used | percentage hugepage | > >>> +-----------+----------------+----------------+----------------------+ > >>> | 0 | 3044.988281 | 0 | 0% | > >>> | 22 | 3160.207031 | 2 | 0.06% | > >>> | 30 | 3250.90625 | 4 | 0.12% | > >>> | 69 | 3781.238281 | 6 | 0.16% | > >>> | 71 | 3822.226563 | 8 | 0.21% | > >>> | 72 | 3846.578125 | 10 | 0.26% | > >>> | 73 | 3852.402344 | 12 | 0.31% | > >>> | 74 | 3868 | 14 | 0.36% | > >>> | 75 | 3881.84375 | 104 | 2.68% | > >>> | 275 | 4194.175781 | 106 | 2.52% | > >>> +-----------+----------------+----------------+----------------------+ > >>> After second 275, no more pages are collapsed into hugepages > >>> > >>> > >>> THP (always) benchmark: > >>> +-----------+----------------+----------------+---------------------+ > >>> | timestamp | total mem used | huge page used | percentage hugepage | > >>> +-----------+----------------+----------------+---------------------+ > >>> | 1 | 4489.320313 | 184 | 4.098615986 | > >>> | 15 | 4581.871094 | 214 | 4.670580984 | > >>> | 30 | 4757.742188 | 376 | 7.902908253 | > >>> | 45 | 4937.574219 | 558 | 11.30109595 | > >>> | 60 | 5147.867188 | 728 | 14.14177898 | > >>> | 75 | 5407.0625 | 918 | 16.97779524 | > >>> | 95 | 5668.796875 | 1040 | 18.34604455 | > >>> | 105 | 5723.839844 | 1056 | 18.44915352 | > >>> | 115 | 5736.84375 | 1072 | 18.68623317 | > >>> | 125 | 5732.042969 | 1088 | 18.98101612 | > >>> | 186 | 5753.601563 | 1184 | 20.57841488 | > >>> | 246 | 5746.398438 | 1280 | 22.27482159 | > >>> | 306 | 5752.128906 | 1376 | 23.92157795 | > >>> | 367 | 5772.5625 | 1472 | 25.49994045 | > >>> | 427 | 5832.019531 | 1568 | 26.88605536 | > >>> | 488 | 5813.246094 | 1664 | 28.62428277 | > >>> | 548 | 5807.621094 | 1760 | 30.30500736 | > >>> | 598 | 5841.253906 | 1822 | 31.19193292 | > >>> | 669 | 5982.160156 | 1854 | 30.99214918 | > >>> | 931 | 5946.605469 | 1868 | 31.41287933 | > >>> | 981 | 6020.207031 | 1896 | 31.49393352 | > >>> | 991 | 5988.445313 | 1910 | 31.89475566 | > >>> | 1011 | 5988.570313 | 1926 | 32.16126554 | > >>> | 1032 | 6016.039063 | 1936 | 32.18064211 | > >>> | 1575 | 6057.289063 | 1968 | 32.48978181 | > >>> | 1606 | 6026.167969 | 2000 | 33.18858702 | > >>> +-----------+----------------+----------------+---------------------+ > >>> I ignored some points to make the table shorter. Anyway, the amount > >>> of memory consumption, total and huge pages, is a lot higher than > >>> with DAMON hugepage autotuning. > >> > >> Could you further clarify why it is, and what this means > > Memory fragmentation. I will add information about memory fragmentation > > in the next cover letter. >> > >>> > >>> Performance: > >>> Baseline (no THP, module off) -> 18,162.45 transactions per second > >>> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) > >>> THP always -> 18,388.3 (+1.24%) > >>> THP madvise -> 18,179.25 (+0.09%) > >>> > >>> Improvement is due to lower TLB misses > >> > >> So this result says THP always is much better than the Hugepage autotune in > >> terms of the performance. Maybe you want to claim Hugepage autotune is better > >> in terms of the memory efficiency? Could you please clarify further? > > It's better than THP "never", but worse than THP "always". THP "always" is worse > > in terms of memory consumption, "always" is worse. > >>> > >>> Patches Sequence > >>> ================ > >>> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning > >>> Patch 2 -> Module that demonstrates how to use > >>> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL > >>> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes > >>> > >>> Changes from previous versions > >>> ============================== > >>> RFC 4[3] -> v1 > >>> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and > >>> functions to damon_sample_hpage_... > >>> - Make the module depend on TRANSPARENT_HUGEPAGE, since > >>> the module will need some THP functions anyway > >>> - Removed documentation, since this is just a sample module > >>> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from > >>> damos_sysfs_add_quota_score > >>> - Added a short description of the module in Kconfig > >> > >> Thank you for continuing this work! > >> > >> [...] > >> > >>> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 > >>> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com > >>> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com > >>> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com > >>> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com > >>> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org > >>> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org > >>> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com > >>> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ > >> > >> [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com > >> > >> > >> Thanks, > >> SJ > >> > >> [...] > >> > > > > SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix > > it with your feedback. > > > > I didn't get a reply to this email. I sent the reply [1] weeks ago. > > I will update the cover letter and submit a new patch set soon. No, please. Let's fully complete the discussion before a new version. [1] https://lore.kernel.org/20260620200254.82414-1-sj@kernel.org Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-06 15:16 ` SJ Park @ 2026-07-13 11:30 ` Gutierrez Asier 2026-07-13 14:45 ` SJ Park 0 siblings, 1 reply; 37+ messages in thread From: Gutierrez Asier @ 2026-07-13 11:30 UTC (permalink / raw) To: SJ Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel Hi SJ, On 7/6/2026 6:16 PM, SJ Park wrote: > On Mon, 6 Jul 2026 18:03:03 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > >> Hi SJ, >> >> On 6/20/2026 8:11 PM, Gutierrez Asier wrote: >>> Hi SJ, >>> >>> So sorry, I missed your email. I just found it. Sorry for the late answer. >>> >>> On 6/17/2026 4:44 AM, SeongJae Park wrote: >>>> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: >>>> >>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >>>>> >>>>> Overview >>>>> ======== >>>>> >>>>> This patch set introduces a new autotuning which allows to collapse >>>>> hot regions into hugepages. >>>>> >>>>> Motivation >>>>> ========== >>>>> >>>>> Since TLB is a bottleneck for many systems[1], 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. >>>>> >>>>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. >>>>> However, there is no way to tune the settings. It will collapse all the >>>>> hot regions that meet the access pattern. If the server is a bare metal >>>>> database or big data server, this will also lead to eventual fragmentation. >>>>> >>>>> Additionally, currently THP is set globally. Ideally, there should be a >>>>> way to control which tasks can use huge pages. >>>> >>>> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control >>>> cases, as we discussed [1] on RFC v3? >>>> >>>>> >>>>> Solution >>>>> ======== >>>>> >>>>> DAMON has now a way to autotune some of the variables and adjust quotas >>>>> automatically, so that DAMON is fired only under the right circumstances. >>>>> It would be nice to have something similar, but for huge pages. >>>>> >>>>> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, >>>>> which checks the huge page consumption to total memory consumption. This >>>>> new quota mechanism reuses current autotuning architecture. >>>>> >>>>> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate >>>>> the use of huge pages collapse autotuning. The goal is to collapse hot >>>>> regions of a given process into huge pages. The sample module launches >>>>> a kdamond thread for a certain task provided by the user through >>>>> taget_pid module argument. Hugepage goal autotuning will automatically >>>>> adjust the aggressiveness of hot region collapses. >>>>> >>>>> This sample module also has a user autotuning knob which allows the >>>>> user to adjust the aggressiveness of page collapsing. >>>>> >>>>> Benchmarks >>>>> ========== >>>>> >>>>> Huge page collapse autotuning was tested in a physicial machine with >>>>> MariaDB 10.5.29 and sysbench as the benchmark framework. >>>>> >>>>> The hugepage module was set up in the following way: >>>>> >>>>> # echo 1000 > min_age >>>>> # echo 1000 > quota_percentage_hugepage >>>> >>>> I guess this is the quota goal? What is the unit? I guess it is aparently not >>>> percentage? The name doesn't sound like very consistent or intuitive. How >>>> about hugepage_mem_bp or target_hugepage_mem_bp? >>> Right, we agreed to change the name. I will correct it. >>>>> # echo $(pidof mariadbd) > taget_pid >>>>> # echo on > enabled >>>>> >>>>> The goal was to achieve 5% of the total memory used as hugepage. >>>> >>>> I guess this is what the above example is setting using >>>> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this >>>> correct...? >>> I actually set it to 500. I will update the cover letter. >>>>> Since the database was not very big, we may not be able to achieve >>>>> high amount of huge pages per total memory consumption ratio. >>>> >>>> I believe this patch series will work as you explained. But, it seems bit >>>> weird to show a test result that doesn't demonstrate what this patch is aimed >>>> to achive. Could you increase the size of the database? IIRC, you were able >>>> to show the percentage is over-achived case in an early version. >>> Actually, this is what I got using the TEMPORAL quota goals. With the regular >>> quota goals, it actually over-achieves the goal. >>> >>> Is this an actual bug in the TEMPORAL quota goal? >>>>> >>>>> The table below shows the memory consumption over time. Timestamp is in >>>>> second and the memory usage in is MBytes. Gaps in the timestamp means >>>>> that no changes in the hugepage consumption happened over that period >>>>> of time in MB. The total used memory is calculated as >>>>> mem_total - mem free. The huge page used is calculated as >>>>> huge_page_anon + huge_page_shmem + huge_page_file. The table also >>>>> shows the huge pages to total memory ratio. >>>>> >>>>> Hugepage autotune benchmark: >>>>> +-----------+----------------+----------------+----------------------+ >>>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>>> +-----------+----------------+----------------+----------------------+ >>>>> | 0 | 3044.988281 | 0 | 0% | >>>>> | 22 | 3160.207031 | 2 | 0.06% | >>>>> | 30 | 3250.90625 | 4 | 0.12% | >>>>> | 69 | 3781.238281 | 6 | 0.16% | >>>>> | 71 | 3822.226563 | 8 | 0.21% | >>>>> | 72 | 3846.578125 | 10 | 0.26% | >>>>> | 73 | 3852.402344 | 12 | 0.31% | >>>>> | 74 | 3868 | 14 | 0.36% | >>>>> | 75 | 3881.84375 | 104 | 2.68% | >>>>> | 275 | 4194.175781 | 106 | 2.52% | >>>>> +-----------+----------------+----------------+----------------------+ >>>>> After second 275, no more pages are collapsed into hugepages >>>>> >>>>> >>>>> THP (always) benchmark: >>>>> +-----------+----------------+----------------+---------------------+ >>>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>>> +-----------+----------------+----------------+---------------------+ >>>>> | 1 | 4489.320313 | 184 | 4.098615986 | >>>>> | 15 | 4581.871094 | 214 | 4.670580984 | >>>>> | 30 | 4757.742188 | 376 | 7.902908253 | >>>>> | 45 | 4937.574219 | 558 | 11.30109595 | >>>>> | 60 | 5147.867188 | 728 | 14.14177898 | >>>>> | 75 | 5407.0625 | 918 | 16.97779524 | >>>>> | 95 | 5668.796875 | 1040 | 18.34604455 | >>>>> | 105 | 5723.839844 | 1056 | 18.44915352 | >>>>> | 115 | 5736.84375 | 1072 | 18.68623317 | >>>>> | 125 | 5732.042969 | 1088 | 18.98101612 | >>>>> | 186 | 5753.601563 | 1184 | 20.57841488 | >>>>> | 246 | 5746.398438 | 1280 | 22.27482159 | >>>>> | 306 | 5752.128906 | 1376 | 23.92157795 | >>>>> | 367 | 5772.5625 | 1472 | 25.49994045 | >>>>> | 427 | 5832.019531 | 1568 | 26.88605536 | >>>>> | 488 | 5813.246094 | 1664 | 28.62428277 | >>>>> | 548 | 5807.621094 | 1760 | 30.30500736 | >>>>> | 598 | 5841.253906 | 1822 | 31.19193292 | >>>>> | 669 | 5982.160156 | 1854 | 30.99214918 | >>>>> | 931 | 5946.605469 | 1868 | 31.41287933 | >>>>> | 981 | 6020.207031 | 1896 | 31.49393352 | >>>>> | 991 | 5988.445313 | 1910 | 31.89475566 | >>>>> | 1011 | 5988.570313 | 1926 | 32.16126554 | >>>>> | 1032 | 6016.039063 | 1936 | 32.18064211 | >>>>> | 1575 | 6057.289063 | 1968 | 32.48978181 | >>>>> | 1606 | 6026.167969 | 2000 | 33.18858702 | >>>>> +-----------+----------------+----------------+---------------------+ >>>>> I ignored some points to make the table shorter. Anyway, the amount >>>>> of memory consumption, total and huge pages, is a lot higher than >>>>> with DAMON hugepage autotuning. >>>> >>>> Could you further clarify why it is, and what this means >>> Memory fragmentation. I will add information about memory fragmentation >>> in the next cover letter. >> >>>>> >>>>> Performance: >>>>> Baseline (no THP, module off) -> 18,162.45 transactions per second >>>>> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) >>>>> THP always -> 18,388.3 (+1.24%) >>>>> THP madvise -> 18,179.25 (+0.09%) >>>>> >>>>> Improvement is due to lower TLB misses >>>> >>>> So this result says THP always is much better than the Hugepage autotune in >>>> terms of the performance. Maybe you want to claim Hugepage autotune is better >>>> in terms of the memory efficiency? Could you please clarify further? >>> It's better than THP "never", but worse than THP "always". THP "always" is worse >>> in terms of memory consumption, "always" is worse. >>>>> >>>>> Patches Sequence >>>>> ================ >>>>> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning >>>>> Patch 2 -> Module that demonstrates how to use >>>>> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL >>>>> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes >>>>> >>>>> Changes from previous versions >>>>> ============================== >>>>> RFC 4[3] -> v1 >>>>> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and >>>>> functions to damon_sample_hpage_... >>>>> - Make the module depend on TRANSPARENT_HUGEPAGE, since >>>>> the module will need some THP functions anyway >>>>> - Removed documentation, since this is just a sample module >>>>> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from >>>>> damos_sysfs_add_quota_score >>>>> - Added a short description of the module in Kconfig >>>> >>>> Thank you for continuing this work! >>>> >>>> [...] >>>> >>>>> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 >>>>> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com >>>>> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com >>>>> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com >>>>> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com >>>>> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org >>>>> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org >>>>> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com >>>>> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ >>>> >>>> [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com >>>> >>>> >>>> Thanks, >>>> SJ >>>> >>>> [...] >>>> >>> >>> SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix >>> it with your feedback. >>> >> >> I didn't get a reply to this email. > > I sent the reply [1] weeks ago. > >> >> I will update the cover letter and submit a new patch set soon. > > No, please. Let's fully complete the discussion before a new version. > > [1] https://lore.kernel.org/20260620200254.82414-1-sj@kernel.org > > > Thanks, > SJ > > [...] Hi SJ, So, I finally got some stable results which make sense now. Setup: physical server with arm64 processor with 4 NUMA nodes, 1 TB RAM and running mariaDB 10.5.29. I use sysbench for the benchmark, with 20 tables and 3 million rows per table. The database was pinned to one of the nodes, and the benchmark framework to a different node. No network traffic involved in the benchmark. I forked damo and added hugepage_mem_bp support[1]. I launch DAMON using this command line: sudo ./damo start $(pidof mariadbd) \ --monitoring_nr_regions_range 10 1000 \ --monitoring_intervals 5000 100000 60000000 \ --damos_quota_time 0 --damos_quota_space 128000000 \ --damos_quota_interval 1000 \ --damos_quota_weights 0 1 1 \ --damos_quota_goal hugepage_mem_bp <target> \ --damos_quota_goal_tuner temporal \ --damos_apply_interval 50000 \ --damos_access_rate 0 max --damos_age 50 max \ --damos_action collapse --debug_damon <target> was 1000 to taget 10% hugepage to total memory ratio, or 2500 to target 25%. Tuner was also tested with consistent and temporal. Results ======= After the last timestamp, there was no change in huge page use, and the total huge page to memory consumption ratio barely moved. Timestamp is measured in seconds, and the memory consumption (total and huge page) is in MB. hugepage_mem_bp: 1000 goal tuner: temporal +-----------+----------------+----------------+----------------------+ | timestamp | total mem used | huge page used | percentage hugepage | +-----------+----------------+----------------+----------------------+ | 0 | 16945.04297 | 0 | 0 | | 7 | 17008.69531 | 74 | 0.435071583 | | 8 | 17036.40234 | 194 | 1.138738074 | | 9 | 17017.01563 | 314 | 1.845211916 | | 10 | 17029.67969 | 434 | 2.548491856 | | 61 | 17111.30859 | 584 | 3.412947623 | | 75 | 17068.51953 | 612 | 3.58554823 | | 90 | 17098.84766 | 638 | 3.731245595 | | 105 | 17076.32031 | 664 | 3.888425538 | | 120 | 17071.05859 | 694 | 4.065360072 | | 135 | 17088.94531 | 722 | 4.22495354 | | 150 | 17101.42578 | 746 | 4.362209383 | | 165 | 17097.33984 | 776 | 4.53871776 | | 180 | 17133.88281 | 804 | 4.692456513 | | 195 | 17099.12891 | 832 | 4.865744943 | | 201 | 17103.5 | 852 | 4.981436548 | | 202 | 17077.84375 | 862 | 5.047475622 | | 203 | 17088.16406 | 916 | 5.360435426 | | 204 | 17126.34766 | 1046 | 6.107548562 | | 205 | 17093.84375 | 1176 | 6.879669764 | | 206 | 17142.77734 | 1298 | 7.571701913 | | 207 | 17129.86719 | 1428 | 8.336316822 | | 208 | 17099.76953 | 1556 | 9.099537846 | | 209 | 17149.17969 | 1686 | 9.831374041 | | 210 | 17097.30859 | 1754 | 10.25892462 | +-----------+----------------+----------------+----------------------+ hugepage_mem_bp: 1000 goal tuner: consistent +-----------+----------------+----------------+----------------------+ | timestamp | total mem used | huge page used | percentage hugepage | +-----------+----------------+----------------+----------------------+ | 0 | 16955.24609 | 0 | 0 | | 34 | 17039.71875 | 106 | 0.622075995 | | 35 | 17022.21875 | 224 | 1.315927161 | | 36 | 17070.08594 | 344 | 2.015221255 | | 37 | 17005.86719 | 464 | 2.728470091 | | 38 | 17028.92188 | 542 | 3.182820404 | | 78 | 17009.47656 | 554 | 3.257007927 | | 79 | 17051.82031 | 572 | 3.354480575 | | 90 | 17048.92188 | 596 | 3.495822225 | | 105 | 17086.22656 | 624 | 3.652064414 | | 120 | 17102.49609 | 654 | 3.824003212 | | 135 | 17081.31641 | 680 | 3.980957813 | | 150 | 17092.90625 | 706 | 4.130368409 | | 165 | 17093.69531 | 736 | 4.305681051 | | 180 | 17053.08984 | 764 | 4.480126517 | | 195 | 17095.73047 | 788 | 4.609337995 | | 210 | 17086.20703 | 818 | 4.787487349 | | 225 | 17095.04297 | 846 | 4.948803004 | | 226 | 17057.95703 | 848 | 4.971286998 | | 227 | 17101.46484 | 858 | 5.017114077 | | 228 | 17053.90625 | 896 | 5.253928261 | | 229 | 17061.48047 | 1016 | 5.954934578 | | 230 | 17097.48828 | 1136 | 6.644250789 | | 231 | 17080.42188 | 1256 | 7.353448347 | | 232 | 17118.92969 | 1376 | 8.037885692 | | 233 | 17100.50391 | 1496 | 8.748280216 | | 234 | 17110.80859 | 1616 | 9.444322816 | | 235 | 17138.17188 | 1736 | 10.12943512 | | 236 | 17060.17578 | 1856 | 10.87913761 | | 237 | 17118.92578 | 1976 | 11.54278034 | | 238 | 17119.28516 | 2096 | 12.24350188 | | 239 | 17098.89063 | 2216 | 12.95990511 | | 240 | 17135.44531 | 2334 | 13.62088908 | | 241 | 17097.58594 | 2454 | 14.35290344 | | 242 | 17134.69531 | 2574 | 15.02215215 | | 243 | 17127.96094 | 2694 | 15.72866735 | | 244 | 17097.53516 | 2812 | 16.44681514 | | 245 | 17132.55078 | 2932 | 17.11362212 | | 246 | 17117.95313 | 3052 | 17.82923448 | | 247 | 17154.30469 | 3172 | 18.49098554 | | 248 | 17145.55078 | 3292 | 19.20031641 | | 249 | 17138.36719 | 3410 | 19.89687794 | | 250 | 17163.12109 | 3532 | 20.57900763 | +-----------+----------------+----------------+----------------------+ hugepage_mem_bp: 2500 goal tuner: temporal +-----------+----------------+----------------+----------------------+ | timestamp | total mem used | huge page used | percentage hugepage | +-----------+----------------+----------------+----------------------+ | 0 | 17010.31641 | 0 | 0 | | 9 | 17063.6875 | 50 | 0.2930199 | | 10 | 17051.75781 | 170 | 0.996964664 | | 11 | 17059.625 | 290 | 1.699920133 | | 12 | 17053.72656 | 410 | 2.404166611 | | 13 | 17082.44141 | 528 | 3.090893084 | | 14 | 17097.22266 | 530 | 3.099918687 | | 60 | 17133.85547 | 572 | 3.338419663 | | 75 | 17149.26563 | 598 | 3.487029784 | | 90 | 17192.07813 | 626 | 3.641211932 | | 105 | 17196.34766 | 654 | 3.80313316 | | 120 | 17221.44531 | 682 | 3.960178647 | | 135 | 17225.36719 | 708 | 4.110217172 | | 150 | 17220.15625 | 736 | 4.274061102 | | 165 | 17223.66406 | 764 | 4.435757672 | | 181 | 17199.76172 | 790 | 4.593086886 | | 195 | 17139.11328 | 818 | 4.772708988 | | 205 | 17185.85547 | 862 | 5.015752644 | | 206 | 17228.63281 | 978 | 5.67659669 | | 207 | 17194.80469 | 1094 | 6.362386895 | | 208 | 17222.77734 | 1206 | 7.002354939 | | 209 | 17177.09766 | 1320 | 7.68465096 | | 210 | 17182.23828 | 1428 | 8.310907907 | | 211 | 17196.77734 | 1542 | 8.966796332 | | 212 | 17205.57031 | 1664 | 9.671286507 | | 213 | 17227.39844 | 1784 | 10.35559726 | | 214 | 17245.17969 | 1904 | 11.04076637 | | 215 | 17240.45703 | 2024 | 11.73982799 | | 216 | 17218.85156 | 2144 | 12.45146921 | | 217 | 17183.63281 | 2264 | 13.17532809 | | 218 | 17217.08984 | 2384 | 13.84670709 | | 219 | 17176.72266 | 2504 | 14.57786826 | | 220 | 17234.79688 | 2624 | 15.22501262 | | 221 | 17221.20703 | 2744 | 15.93384247 | | 222 | 17258.91016 | 2864 | 16.59432707 | | 223 | 17248.64063 | 2984 | 17.29991403 | | 224 | 17227.35156 | 3104 | 18.0178595 | | 225 | 17194.83594 | 3224 | 18.74981542 | | 226 | 17216.30078 | 3344 | 19.42345247 | | 227 | 17205.71875 | 3464 | 20.13284101 | | 228 | 17222.83594 | 3584 | 20.80958103 | | 229 | 17232.32031 | 3704 | 21.49449368 | | 230 | 17269.49219 | 3824 | 22.14309465 | | 231 | 17247.55469 | 3944 | 22.86700968 | | 232 | 17248.90234 | 4064 | 23.56091952 | | 233 | 17229.21875 | 4184 | 24.28432804 | | 234 | 17221.28125 | 4304 | 24.99233325 | | 235 | 17229.37109 | 4424 | 25.67708349 | +-----------+----------------+----------------+----------------------+ hugepage_mem_bp: 1000 goal tuner: consist +-----------+----------------+----------------+----------------------+ | timestamp | total mem used | huge page used | percentage hugepage | +-----------+----------------+----------------+----------------------+ | 0 | 17125.85156 | 0 | 0 | | 38 | 17081.23438 | 76 | 0.444932716 | | 39 | 17133.11719 | 196 | 1.143983304 | | 40 | 17119.83984 | 316 | 1.84581166 | | 41 | 17116.48438 | 436 | 2.547252055 | | 60 | 17109.72656 | 554 | 3.237924335 | | 75 | 17158.79297 | 600 | 3.496749457 | | 90 | 17164.11328 | 628 | 3.65879664 | | 105 | 17205 | 654 | 3.801220575 | | 120 | 17176.01953 | 682 | 3.970652215 | | 136 | 17172.19922 | 710 | 4.134589816 | | 150 | 17154.96484 | 738 | 4.3019616 | | 165 | 17190.66797 | 764 | 4.444271749 | | 180 | 17177.66016 | 792 | 4.610639591 | | 195 | 17202.01563 | 822 | 4.778509786 | | 210 | 17160.23047 | 848 | 4.941658572 | | 216 | 17147.09766 | 898 | 5.237037882 | | 217 | 17180.72656 | 1018 | 5.925244176 | | 218 | 17179.74609 | 1138 | 6.624079272 | | 219 | 17151.43359 | 1258 | 7.334663853 | | 220 | 17180.86719 | 1378 | 8.020549749 | | 221 | 17201.65625 | 1498 | 8.708463756 | | 222 | 17184.45703 | 1618 | 9.415485151 | | 223 | 17174.21094 | 1718 | 10.00337079 | | 224 | 17174.90234 | 1800 | 10.48040894 | | 225 | 17204.64063 | 1874 | 10.89241002 | | 226 | 17187.82031 | 1980 | 11.51978531 | | 227 | 17145.08594 | 2100 | 12.24840755 | | 228 | 17144.25781 | 2220 | 12.948942 | | 229 | 17171.44141 | 2338 | 13.61563042 | | 230 | 17175.02344 | 2458 | 14.31147974 | | 231 | 17150.30469 | 2578 | 15.03180292 | | 232 | 17148.73438 | 2698 | 15.73293948 | | 233 | 17143.48438 | 2818 | 16.4377319 | | 234 | 17167.57422 | 2938 | 17.11365836 | | 235 | 17157.11328 | 3058 | 17.82351116 | | 236 | 17151.45703 | 3178 | 18.52903805 | | 237 | 17155.85938 | 3298 | 19.22375282 | | 238 | 17188.00781 | 3418 | 19.88595791 | | 239 | 17151.66406 | 3536 | 20.61607543 | | 240 | 17137.38281 | 3656 | 21.33347921 | | 241 | 17165.32422 | 3776 | 21.99783675 | | 242 | 17158.48438 | 3896 | 22.70596817 | | 243 | 17122.70313 | 4016 | 23.45424067 | | 244 | 17151.28516 | 4136 | 24.114811 | | 245 | 17188.16797 | 4256 | 24.76121951 | | 246 | 17150.58984 | 4376 | 25.51515744 | | 247 | 17178.125 | 4496 | 26.17282154 | | 248 | 17130.97266 | 4616 | 26.94534684 | | 249 | 17149.64063 | 4736 | 27.61573903 | | 250 | 17175.5 | 4856 | 28.27283049 | | 251 | 17141.30859 | 4978 | 29.04095666 | | 252 | 17168.22266 | 5098 | 29.69439587 | | 253 | 17158.42578 | 5218 | 30.41071522 | | 254 | 17175.84375 | 5338 | 31.07853144 | | 255 | 17173.60156 | 5458 | 31.78133591 | | 256 | 17188.17188 | 5578 | 32.45254958 | | 257 | 17217.83203 | 5698 | 33.09359732 | | 258 | 17182.50781 | 5818 | 33.86001661 | | 259 | 17194.44922 | 5936 | 34.52276909 | | 260 | 17199.66406 | 6056 | 35.20999002 | | 261 | 17188.90234 | 6176 | 35.93015933 | | 262 | 17204.27344 | 6296 | 36.59555879 | | 263 | 17202.03516 | 6416 | 37.29791238 | | 264 | 17207.71484 | 6536 | 37.98296322 | | 265 | 17224.46094 | 6656 | 38.64271877 | | 266 | 17198.29297 | 6776 | 39.39925906 | | 267 | 17200.13281 | 6896 | 40.09271367 | | 268 | 17204.625 | 7014 | 40.76810741 | | 269 | 17210.91406 | 7134 | 41.45044228 | | 270 | 17203.98438 | 7254 | 42.16465118 | | 271 | 17206.08203 | 7374 | 42.85693853 | | 272 | 17210.62891 | 7494 | 43.54285971 | | 273 | 17202.55859 | 7614 | 44.26085782 | | 274 | 17223.07813 | 7734 | 44.90486511 | | 275 | 17207.21875 | 7762 | 45.10897498 | +-----------+----------------+----------------+----------------------+ From this, we can conclude that the huge page autotuner works fine, achieving the target. When using consistent autotuner, it actually over-achieves the target, which is expected, since quota esz_bp is not set to 0 to cap the DAMOS policy. [1] https://github.com/asierHuawei/damo/commit/79ae1a4ab1c012a7161db85a000d14f08fa36736 Let me know what you think. Thanks in advance, -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-13 11:30 ` Gutierrez Asier @ 2026-07-13 14:45 ` SJ Park 2026-07-13 15:04 ` Gutierrez Asier 0 siblings, 1 reply; 37+ messages in thread From: SJ Park @ 2026-07-13 14:45 UTC (permalink / raw) To: Gutierrez Asier Cc: SJ Park, artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On Mon, 13 Jul 2026 14:30:40 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > Hi SJ, > > On 7/6/2026 6:16 PM, SJ Park wrote: > > On Mon, 6 Jul 2026 18:03:03 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > > > >> Hi SJ, > >> > >> On 6/20/2026 8:11 PM, Gutierrez Asier wrote: > >>> Hi SJ, > >>> > >>> So sorry, I missed your email. I just found it. Sorry for the late answer. > >>> > >>> On 6/17/2026 4:44 AM, SeongJae Park wrote: > >>>> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: > >>>> > >>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> > >>>>> > >>>>> Overview > >>>>> ======== > >>>>> > >>>>> This patch set introduces a new autotuning which allows to collapse > >>>>> hot regions into hugepages. > >>>>> > >>>>> Motivation > >>>>> ========== > >>>>> > >>>>> Since TLB is a bottleneck for many systems[1], 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. > >>>>> > >>>>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. > >>>>> However, there is no way to tune the settings. It will collapse all the > >>>>> hot regions that meet the access pattern. If the server is a bare metal > >>>>> database or big data server, this will also lead to eventual fragmentation. > >>>>> > >>>>> Additionally, currently THP is set globally. Ideally, there should be a > >>>>> way to control which tasks can use huge pages. > >>>> > >>>> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control > >>>> cases, as we discussed [1] on RFC v3? > >>>> > >>>>> > >>>>> Solution > >>>>> ======== > >>>>> > >>>>> DAMON has now a way to autotune some of the variables and adjust quotas > >>>>> automatically, so that DAMON is fired only under the right circumstances. > >>>>> It would be nice to have something similar, but for huge pages. > >>>>> > >>>>> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, > >>>>> which checks the huge page consumption to total memory consumption. This > >>>>> new quota mechanism reuses current autotuning architecture. > >>>>> > >>>>> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate > >>>>> the use of huge pages collapse autotuning. The goal is to collapse hot > >>>>> regions of a given process into huge pages. The sample module launches > >>>>> a kdamond thread for a certain task provided by the user through > >>>>> taget_pid module argument. Hugepage goal autotuning will automatically > >>>>> adjust the aggressiveness of hot region collapses. > >>>>> > >>>>> This sample module also has a user autotuning knob which allows the > >>>>> user to adjust the aggressiveness of page collapsing. > >>>>> > >>>>> Benchmarks > >>>>> ========== > >>>>> > >>>>> Huge page collapse autotuning was tested in a physicial machine with > >>>>> MariaDB 10.5.29 and sysbench as the benchmark framework. > >>>>> > >>>>> The hugepage module was set up in the following way: > >>>>> > >>>>> # echo 1000 > min_age > >>>>> # echo 1000 > quota_percentage_hugepage > >>>> > >>>> I guess this is the quota goal? What is the unit? I guess it is aparently not > >>>> percentage? The name doesn't sound like very consistent or intuitive. How > >>>> about hugepage_mem_bp or target_hugepage_mem_bp? > >>> Right, we agreed to change the name. I will correct it. > >>>>> # echo $(pidof mariadbd) > taget_pid > >>>>> # echo on > enabled > >>>>> > >>>>> The goal was to achieve 5% of the total memory used as hugepage. > >>>> > >>>> I guess this is what the above example is setting using > >>>> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this > >>>> correct...? > >>> I actually set it to 500. I will update the cover letter. > >>>>> Since the database was not very big, we may not be able to achieve > >>>>> high amount of huge pages per total memory consumption ratio. > >>>> > >>>> I believe this patch series will work as you explained. But, it seems bit > >>>> weird to show a test result that doesn't demonstrate what this patch is aimed > >>>> to achive. Could you increase the size of the database? IIRC, you were able > >>>> to show the percentage is over-achived case in an early version. > >>> Actually, this is what I got using the TEMPORAL quota goals. With the regular > >>> quota goals, it actually over-achieves the goal. > >>> > >>> Is this an actual bug in the TEMPORAL quota goal? > >>>>> > >>>>> The table below shows the memory consumption over time. Timestamp is in > >>>>> second and the memory usage in is MBytes. Gaps in the timestamp means > >>>>> that no changes in the hugepage consumption happened over that period > >>>>> of time in MB. The total used memory is calculated as > >>>>> mem_total - mem free. The huge page used is calculated as > >>>>> huge_page_anon + huge_page_shmem + huge_page_file. The table also > >>>>> shows the huge pages to total memory ratio. > >>>>> > >>>>> Hugepage autotune benchmark: > >>>>> +-----------+----------------+----------------+----------------------+ > >>>>> | timestamp | total mem used | huge page used | percentage hugepage | > >>>>> +-----------+----------------+----------------+----------------------+ > >>>>> | 0 | 3044.988281 | 0 | 0% | > >>>>> | 22 | 3160.207031 | 2 | 0.06% | > >>>>> | 30 | 3250.90625 | 4 | 0.12% | > >>>>> | 69 | 3781.238281 | 6 | 0.16% | > >>>>> | 71 | 3822.226563 | 8 | 0.21% | > >>>>> | 72 | 3846.578125 | 10 | 0.26% | > >>>>> | 73 | 3852.402344 | 12 | 0.31% | > >>>>> | 74 | 3868 | 14 | 0.36% | > >>>>> | 75 | 3881.84375 | 104 | 2.68% | > >>>>> | 275 | 4194.175781 | 106 | 2.52% | > >>>>> +-----------+----------------+----------------+----------------------+ > >>>>> After second 275, no more pages are collapsed into hugepages > >>>>> > >>>>> > >>>>> THP (always) benchmark: > >>>>> +-----------+----------------+----------------+---------------------+ > >>>>> | timestamp | total mem used | huge page used | percentage hugepage | > >>>>> +-----------+----------------+----------------+---------------------+ > >>>>> | 1 | 4489.320313 | 184 | 4.098615986 | > >>>>> | 15 | 4581.871094 | 214 | 4.670580984 | > >>>>> | 30 | 4757.742188 | 376 | 7.902908253 | > >>>>> | 45 | 4937.574219 | 558 | 11.30109595 | > >>>>> | 60 | 5147.867188 | 728 | 14.14177898 | > >>>>> | 75 | 5407.0625 | 918 | 16.97779524 | > >>>>> | 95 | 5668.796875 | 1040 | 18.34604455 | > >>>>> | 105 | 5723.839844 | 1056 | 18.44915352 | > >>>>> | 115 | 5736.84375 | 1072 | 18.68623317 | > >>>>> | 125 | 5732.042969 | 1088 | 18.98101612 | > >>>>> | 186 | 5753.601563 | 1184 | 20.57841488 | > >>>>> | 246 | 5746.398438 | 1280 | 22.27482159 | > >>>>> | 306 | 5752.128906 | 1376 | 23.92157795 | > >>>>> | 367 | 5772.5625 | 1472 | 25.49994045 | > >>>>> | 427 | 5832.019531 | 1568 | 26.88605536 | > >>>>> | 488 | 5813.246094 | 1664 | 28.62428277 | > >>>>> | 548 | 5807.621094 | 1760 | 30.30500736 | > >>>>> | 598 | 5841.253906 | 1822 | 31.19193292 | > >>>>> | 669 | 5982.160156 | 1854 | 30.99214918 | > >>>>> | 931 | 5946.605469 | 1868 | 31.41287933 | > >>>>> | 981 | 6020.207031 | 1896 | 31.49393352 | > >>>>> | 991 | 5988.445313 | 1910 | 31.89475566 | > >>>>> | 1011 | 5988.570313 | 1926 | 32.16126554 | > >>>>> | 1032 | 6016.039063 | 1936 | 32.18064211 | > >>>>> | 1575 | 6057.289063 | 1968 | 32.48978181 | > >>>>> | 1606 | 6026.167969 | 2000 | 33.18858702 | > >>>>> +-----------+----------------+----------------+---------------------+ > >>>>> I ignored some points to make the table shorter. Anyway, the amount > >>>>> of memory consumption, total and huge pages, is a lot higher than > >>>>> with DAMON hugepage autotuning. > >>>> > >>>> Could you further clarify why it is, and what this means > >>> Memory fragmentation. I will add information about memory fragmentation > >>> in the next cover letter. >> > >>>>> > >>>>> Performance: > >>>>> Baseline (no THP, module off) -> 18,162.45 transactions per second > >>>>> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) > >>>>> THP always -> 18,388.3 (+1.24%) > >>>>> THP madvise -> 18,179.25 (+0.09%) > >>>>> > >>>>> Improvement is due to lower TLB misses > >>>> > >>>> So this result says THP always is much better than the Hugepage autotune in > >>>> terms of the performance. Maybe you want to claim Hugepage autotune is better > >>>> in terms of the memory efficiency? Could you please clarify further? > >>> It's better than THP "never", but worse than THP "always". THP "always" is worse > >>> in terms of memory consumption, "always" is worse. > >>>>> > >>>>> Patches Sequence > >>>>> ================ > >>>>> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning > >>>>> Patch 2 -> Module that demonstrates how to use > >>>>> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL > >>>>> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes > >>>>> > >>>>> Changes from previous versions > >>>>> ============================== > >>>>> RFC 4[3] -> v1 > >>>>> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and > >>>>> functions to damon_sample_hpage_... > >>>>> - Make the module depend on TRANSPARENT_HUGEPAGE, since > >>>>> the module will need some THP functions anyway > >>>>> - Removed documentation, since this is just a sample module > >>>>> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from > >>>>> damos_sysfs_add_quota_score > >>>>> - Added a short description of the module in Kconfig > >>>> > >>>> Thank you for continuing this work! > >>>> > >>>> [...] > >>>> > >>>>> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 > >>>>> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com > >>>>> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com > >>>>> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com > >>>>> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com > >>>>> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org > >>>>> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org > >>>>> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com > >>>>> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ > >>>> > >>>> [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com > >>>> > >>>> > >>>> Thanks, > >>>> SJ > >>>> > >>>> [...] > >>>> > >>> > >>> SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix > >>> it with your feedback. > >>> > >> > >> I didn't get a reply to this email. > > > > I sent the reply [1] weeks ago. > > > >> > >> I will update the cover letter and submit a new patch set soon. > > > > No, please. Let's fully complete the discussion before a new version. > > > > [1] https://lore.kernel.org/20260620200254.82414-1-sj@kernel.org > > > > > > Thanks, > > SJ > > > > [...] > > Hi SJ, > > So, I finally got some stable results which make sense now. > > Setup: physical server with arm64 processor with 4 NUMA nodes, > 1 TB RAM and running mariaDB 10.5.29. I use sysbench for the > benchmark, with 20 tables and 3 million rows per table. The database > was pinned to one of the nodes, and the benchmark framework to a > different node. No network traffic involved in the benchmark. > > I forked damo and added hugepage_mem_bp support[1]. > > I launch DAMON using this command line: This is very helpful at understanding the test setup. Thank you for sharing! > > sudo ./damo start $(pidof mariadbd) \ > --monitoring_nr_regions_range 10 1000 \ > --monitoring_intervals 5000 100000 60000000 \ > --damos_quota_time 0 --damos_quota_space 128000000 \ > --damos_quota_interval 1000 \ > --damos_quota_weights 0 1 1 \ > --damos_quota_goal hugepage_mem_bp <target> \ > --damos_quota_goal_tuner temporal \ > --damos_apply_interval 50000 \ So, 50 ms DAMOS apply interval? Seems quite short to me. No big deal, though. > --damos_access_rate 0 max --damos_age 50 max \ > --damos_action collapse --debug_damon FYI, damo supports human friendly formats. E.g., --monitoring_intervals 5ms 100ms 60s \ --damos_quota_space 128MB --damos_quota_interval 1s \ --damos_apply_interval 50ms > > <target> was 1000 to taget 10% hugepage to total memory ratio, or > 2500 to target 25%. Tuner was also tested with consistent and > temporal. > > Results > ======= > After the last timestamp, there was no change in huge page use, and > the total huge page to memory consumption ratio barely moved. > > Timestamp is measured in seconds, and the memory consumption (total > and huge page) is in MB. > > hugepage_mem_bp: 1000 > goal tuner: temporal > > +-----------+----------------+----------------+----------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+----------------------+ > | 0 | 16945.04297 | 0 | 0 | > | 7 | 17008.69531 | 74 | 0.435071583 | > | 8 | 17036.40234 | 194 | 1.138738074 | > | 9 | 17017.01563 | 314 | 1.845211916 | > | 10 | 17029.67969 | 434 | 2.548491856 | > | 61 | 17111.30859 | 584 | 3.412947623 | > | 75 | 17068.51953 | 612 | 3.58554823 | > | 90 | 17098.84766 | 638 | 3.731245595 | > | 105 | 17076.32031 | 664 | 3.888425538 | > | 120 | 17071.05859 | 694 | 4.065360072 | > | 135 | 17088.94531 | 722 | 4.22495354 | > | 150 | 17101.42578 | 746 | 4.362209383 | > | 165 | 17097.33984 | 776 | 4.53871776 | > | 180 | 17133.88281 | 804 | 4.692456513 | > | 195 | 17099.12891 | 832 | 4.865744943 | > | 201 | 17103.5 | 852 | 4.981436548 | > | 202 | 17077.84375 | 862 | 5.047475622 | > | 203 | 17088.16406 | 916 | 5.360435426 | > | 204 | 17126.34766 | 1046 | 6.107548562 | > | 205 | 17093.84375 | 1176 | 6.879669764 | > | 206 | 17142.77734 | 1298 | 7.571701913 | > | 207 | 17129.86719 | 1428 | 8.336316822 | > | 208 | 17099.76953 | 1556 | 9.099537846 | > | 209 | 17149.17969 | 1686 | 9.831374041 | > | 210 | 17097.30859 | 1754 | 10.25892462 | > +-----------+----------------+----------------+----------------------+ I saw you added description of all results at the end. But adding it for each result would be nicer for readers. E.g., you could say, "As expected, ~10 % huge page ratio is achieved." Or, you could make tables shorter by cutting more lines, keeping the height ~10 rows per table? > > hugepage_mem_bp: 1000 > goal tuner: consistent > > +-----------+----------------+----------------+----------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+----------------------+ > | 0 | 16955.24609 | 0 | 0 | > | 34 | 17039.71875 | 106 | 0.622075995 | > | 35 | 17022.21875 | 224 | 1.315927161 | > | 36 | 17070.08594 | 344 | 2.015221255 | > | 37 | 17005.86719 | 464 | 2.728470091 | > | 38 | 17028.92188 | 542 | 3.182820404 | > | 78 | 17009.47656 | 554 | 3.257007927 | > | 79 | 17051.82031 | 572 | 3.354480575 | > | 90 | 17048.92188 | 596 | 3.495822225 | > | 105 | 17086.22656 | 624 | 3.652064414 | > | 120 | 17102.49609 | 654 | 3.824003212 | > | 135 | 17081.31641 | 680 | 3.980957813 | > | 150 | 17092.90625 | 706 | 4.130368409 | > | 165 | 17093.69531 | 736 | 4.305681051 | > | 180 | 17053.08984 | 764 | 4.480126517 | > | 195 | 17095.73047 | 788 | 4.609337995 | > | 210 | 17086.20703 | 818 | 4.787487349 | > | 225 | 17095.04297 | 846 | 4.948803004 | > | 226 | 17057.95703 | 848 | 4.971286998 | > | 227 | 17101.46484 | 858 | 5.017114077 | > | 228 | 17053.90625 | 896 | 5.253928261 | > | 229 | 17061.48047 | 1016 | 5.954934578 | > | 230 | 17097.48828 | 1136 | 6.644250789 | > | 231 | 17080.42188 | 1256 | 7.353448347 | > | 232 | 17118.92969 | 1376 | 8.037885692 | > | 233 | 17100.50391 | 1496 | 8.748280216 | > | 234 | 17110.80859 | 1616 | 9.444322816 | > | 235 | 17138.17188 | 1736 | 10.12943512 | > | 236 | 17060.17578 | 1856 | 10.87913761 | > | 237 | 17118.92578 | 1976 | 11.54278034 | > | 238 | 17119.28516 | 2096 | 12.24350188 | > | 239 | 17098.89063 | 2216 | 12.95990511 | > | 240 | 17135.44531 | 2334 | 13.62088908 | > | 241 | 17097.58594 | 2454 | 14.35290344 | > | 242 | 17134.69531 | 2574 | 15.02215215 | > | 243 | 17127.96094 | 2694 | 15.72866735 | > | 244 | 17097.53516 | 2812 | 16.44681514 | > | 245 | 17132.55078 | 2932 | 17.11362212 | > | 246 | 17117.95313 | 3052 | 17.82923448 | > | 247 | 17154.30469 | 3172 | 18.49098554 | > | 248 | 17145.55078 | 3292 | 19.20031641 | > | 249 | 17138.36719 | 3410 | 19.89687794 | > | 250 | 17163.12109 | 3532 | 20.57900763 | > +-----------+----------------+----------------+----------------------+ Seems the table bit long to me. When you add this to the cover letter, I think you could further cut some rows. Maybe showing the rows for ~2% jumps? E.g., +-----------+----------------+----------------+----------------------+ | timestamp | total mem used | huge page used | percentage hugepage | +-----------+----------------+----------------+----------------------+ | 0 | 16955.24609 | 0 | 0 | | 36 | 17070.08594 | 344 | 2.015221255 | | 150 | 17092.90625 | 706 | 4.130368409 | | 230 | 17097.48828 | 1136 | 6.644250789 | | 232 | 17118.92969 | 1376 | 8.037885692 | | 235 | 17138.17188 | 1736 | 10.12943512 | | 238 | 17119.28516 | 2096 | 12.24350188 | | 241 | 17097.58594 | 2454 | 14.35290344 | | 244 | 17097.53516 | 2812 | 16.44681514 | | 247 | 17154.30469 | 3172 | 18.49098554 | | 250 | 17163.12109 | 3532 | 20.57900763 | +-----------+----------------+----------------+----------------------+ > > hugepage_mem_bp: 2500 > goal tuner: temporal > > +-----------+----------------+----------------+----------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+----------------------+ > | 0 | 17010.31641 | 0 | 0 | > | 9 | 17063.6875 | 50 | 0.2930199 | > | 10 | 17051.75781 | 170 | 0.996964664 | > | 11 | 17059.625 | 290 | 1.699920133 | > | 12 | 17053.72656 | 410 | 2.404166611 | > | 13 | 17082.44141 | 528 | 3.090893084 | > | 14 | 17097.22266 | 530 | 3.099918687 | > | 60 | 17133.85547 | 572 | 3.338419663 | > | 75 | 17149.26563 | 598 | 3.487029784 | > | 90 | 17192.07813 | 626 | 3.641211932 | > | 105 | 17196.34766 | 654 | 3.80313316 | > | 120 | 17221.44531 | 682 | 3.960178647 | > | 135 | 17225.36719 | 708 | 4.110217172 | > | 150 | 17220.15625 | 736 | 4.274061102 | > | 165 | 17223.66406 | 764 | 4.435757672 | > | 181 | 17199.76172 | 790 | 4.593086886 | > | 195 | 17139.11328 | 818 | 4.772708988 | > | 205 | 17185.85547 | 862 | 5.015752644 | > | 206 | 17228.63281 | 978 | 5.67659669 | > | 207 | 17194.80469 | 1094 | 6.362386895 | > | 208 | 17222.77734 | 1206 | 7.002354939 | > | 209 | 17177.09766 | 1320 | 7.68465096 | > | 210 | 17182.23828 | 1428 | 8.310907907 | > | 211 | 17196.77734 | 1542 | 8.966796332 | > | 212 | 17205.57031 | 1664 | 9.671286507 | > | 213 | 17227.39844 | 1784 | 10.35559726 | > | 214 | 17245.17969 | 1904 | 11.04076637 | > | 215 | 17240.45703 | 2024 | 11.73982799 | > | 216 | 17218.85156 | 2144 | 12.45146921 | > | 217 | 17183.63281 | 2264 | 13.17532809 | > | 218 | 17217.08984 | 2384 | 13.84670709 | > | 219 | 17176.72266 | 2504 | 14.57786826 | > | 220 | 17234.79688 | 2624 | 15.22501262 | > | 221 | 17221.20703 | 2744 | 15.93384247 | > | 222 | 17258.91016 | 2864 | 16.59432707 | > | 223 | 17248.64063 | 2984 | 17.29991403 | > | 224 | 17227.35156 | 3104 | 18.0178595 | > | 225 | 17194.83594 | 3224 | 18.74981542 | > | 226 | 17216.30078 | 3344 | 19.42345247 | > | 227 | 17205.71875 | 3464 | 20.13284101 | > | 228 | 17222.83594 | 3584 | 20.80958103 | > | 229 | 17232.32031 | 3704 | 21.49449368 | > | 230 | 17269.49219 | 3824 | 22.14309465 | > | 231 | 17247.55469 | 3944 | 22.86700968 | > | 232 | 17248.90234 | 4064 | 23.56091952 | > | 233 | 17229.21875 | 4184 | 24.28432804 | > | 234 | 17221.28125 | 4304 | 24.99233325 | > | 235 | 17229.37109 | 4424 | 25.67708349 | > +-----------+----------------+----------------+----------------------+ Again, table looks bit long to me. In the final version of the cover letter, maybe we can show only ~3% jumps? E.g., +-----------+----------------+----------------+----------------------+ | timestamp | total mem used | huge page used | percentage hugepage | +-----------+----------------+----------------+----------------------+ | 0 | 17010.31641 | 0 | 0 | | 13 | 17082.44141 | 528 | 3.090893084 | | 207 | 17194.80469 | 1094 | 6.362386895 | | 212 | 17205.57031 | 1664 | 9.671286507 | | 216 | 17218.85156 | 2144 | 12.45146921 | | 220 | 17234.79688 | 2624 | 15.22501262 | | 224 | 17227.35156 | 3104 | 18.0178595 | | 229 | 17232.32031 | 3704 | 21.49449368 | | 233 | 17229.21875 | 4184 | 24.28432804 | | 235 | 17229.37109 | 4424 | 25.67708349 | +-----------+----------------+----------------+----------------------+ > > hugepage_mem_bp: 1000 > goal tuner: consist > > +-----------+----------------+----------------+----------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+----------------------+ > | 0 | 17125.85156 | 0 | 0 | > | 38 | 17081.23438 | 76 | 0.444932716 | > | 39 | 17133.11719 | 196 | 1.143983304 | > | 40 | 17119.83984 | 316 | 1.84581166 | > | 41 | 17116.48438 | 436 | 2.547252055 | > | 60 | 17109.72656 | 554 | 3.237924335 | > | 75 | 17158.79297 | 600 | 3.496749457 | > | 90 | 17164.11328 | 628 | 3.65879664 | > | 105 | 17205 | 654 | 3.801220575 | > | 120 | 17176.01953 | 682 | 3.970652215 | > | 136 | 17172.19922 | 710 | 4.134589816 | > | 150 | 17154.96484 | 738 | 4.3019616 | > | 165 | 17190.66797 | 764 | 4.444271749 | > | 180 | 17177.66016 | 792 | 4.610639591 | > | 195 | 17202.01563 | 822 | 4.778509786 | > | 210 | 17160.23047 | 848 | 4.941658572 | > | 216 | 17147.09766 | 898 | 5.237037882 | > | 217 | 17180.72656 | 1018 | 5.925244176 | > | 218 | 17179.74609 | 1138 | 6.624079272 | > | 219 | 17151.43359 | 1258 | 7.334663853 | > | 220 | 17180.86719 | 1378 | 8.020549749 | > | 221 | 17201.65625 | 1498 | 8.708463756 | > | 222 | 17184.45703 | 1618 | 9.415485151 | > | 223 | 17174.21094 | 1718 | 10.00337079 | > | 224 | 17174.90234 | 1800 | 10.48040894 | > | 225 | 17204.64063 | 1874 | 10.89241002 | > | 226 | 17187.82031 | 1980 | 11.51978531 | > | 227 | 17145.08594 | 2100 | 12.24840755 | > | 228 | 17144.25781 | 2220 | 12.948942 | > | 229 | 17171.44141 | 2338 | 13.61563042 | > | 230 | 17175.02344 | 2458 | 14.31147974 | > | 231 | 17150.30469 | 2578 | 15.03180292 | > | 232 | 17148.73438 | 2698 | 15.73293948 | > | 233 | 17143.48438 | 2818 | 16.4377319 | > | 234 | 17167.57422 | 2938 | 17.11365836 | > | 235 | 17157.11328 | 3058 | 17.82351116 | > | 236 | 17151.45703 | 3178 | 18.52903805 | > | 237 | 17155.85938 | 3298 | 19.22375282 | > | 238 | 17188.00781 | 3418 | 19.88595791 | > | 239 | 17151.66406 | 3536 | 20.61607543 | > | 240 | 17137.38281 | 3656 | 21.33347921 | > | 241 | 17165.32422 | 3776 | 21.99783675 | > | 242 | 17158.48438 | 3896 | 22.70596817 | > | 243 | 17122.70313 | 4016 | 23.45424067 | > | 244 | 17151.28516 | 4136 | 24.114811 | > | 245 | 17188.16797 | 4256 | 24.76121951 | > | 246 | 17150.58984 | 4376 | 25.51515744 | > | 247 | 17178.125 | 4496 | 26.17282154 | > | 248 | 17130.97266 | 4616 | 26.94534684 | > | 249 | 17149.64063 | 4736 | 27.61573903 | > | 250 | 17175.5 | 4856 | 28.27283049 | > | 251 | 17141.30859 | 4978 | 29.04095666 | > | 252 | 17168.22266 | 5098 | 29.69439587 | > | 253 | 17158.42578 | 5218 | 30.41071522 | > | 254 | 17175.84375 | 5338 | 31.07853144 | > | 255 | 17173.60156 | 5458 | 31.78133591 | > | 256 | 17188.17188 | 5578 | 32.45254958 | > | 257 | 17217.83203 | 5698 | 33.09359732 | > | 258 | 17182.50781 | 5818 | 33.86001661 | > | 259 | 17194.44922 | 5936 | 34.52276909 | > | 260 | 17199.66406 | 6056 | 35.20999002 | > | 261 | 17188.90234 | 6176 | 35.93015933 | > | 262 | 17204.27344 | 6296 | 36.59555879 | > | 263 | 17202.03516 | 6416 | 37.29791238 | > | 264 | 17207.71484 | 6536 | 37.98296322 | > | 265 | 17224.46094 | 6656 | 38.64271877 | > | 266 | 17198.29297 | 6776 | 39.39925906 | > | 267 | 17200.13281 | 6896 | 40.09271367 | > | 268 | 17204.625 | 7014 | 40.76810741 | > | 269 | 17210.91406 | 7134 | 41.45044228 | > | 270 | 17203.98438 | 7254 | 42.16465118 | > | 271 | 17206.08203 | 7374 | 42.85693853 | > | 272 | 17210.62891 | 7494 | 43.54285971 | > | 273 | 17202.55859 | 7614 | 44.26085782 | > | 274 | 17223.07813 | 7734 | 44.90486511 | > | 275 | 17207.21875 | 7762 | 45.10897498 | > +-----------+----------------+----------------+----------------------+ Again, seems long for the final version of the cover letter? We could show for ~5% jumps? +-----------+----------------+----------------+----------------------+ | timestamp | total mem used | huge page used | percentage hugepage | +-----------+----------------+----------------+----------------------+ | 0 | 17125.85156 | 0 | 0 | | 216 | 17147.09766 | 898 | 5.237037882 | | 223 | 17174.21094 | 1718 | 10.00337079 | | 231 | 17150.30469 | 2578 | 15.03180292 | | 239 | 17151.66406 | 3536 | 20.61607543 | | 246 | 17150.58984 | 4376 | 25.51515744 | | 253 | 17158.42578 | 5218 | 30.41071522 | | 260 | 17199.66406 | 6056 | 35.20999002 | | 267 | 17200.13281 | 6896 | 40.09271367 | | 275 | 17207.21875 | 7762 | 45.10897498 | +-----------+----------------+----------------+----------------------+ > > From this, we can conclude that the huge page autotuner works fine, achieving > the target. When using consistent autotuner, it actually over-achieves the > target, which is expected, since quota esz_bp is not set to 0 to cap the > DAMOS policy. > > [1] https://github.com/asierHuawei/damo/commit/79ae1a4ab1c012a7161db85a000d14f08fa36736 > > Let me know what you think. Looks good! Let's proceed to the next version of the patch series with this great test results! Thanks, SJ [...] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning 2026-07-13 14:45 ` SJ Park @ 2026-07-13 15:04 ` Gutierrez Asier 0 siblings, 0 replies; 37+ messages in thread From: Gutierrez Asier @ 2026-07-13 15:04 UTC (permalink / raw) To: SJ Park Cc: artem.kuzin, stepanov.anatoly, wangkefeng.wang, yanquanmin1, zuoze1, damon, akpm, linux-mm, linux-kernel On 7/13/2026 5:45 PM, SJ Park wrote: > On Mon, 13 Jul 2026 14:30:40 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: > >> Hi SJ, >> >> On 7/6/2026 6:16 PM, SJ Park wrote: >>> On Mon, 6 Jul 2026 18:03:03 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote: >>> >>>> Hi SJ, >>>> >>>> On 6/20/2026 8:11 PM, Gutierrez Asier wrote: >>>>> Hi SJ, >>>>> >>>>> So sorry, I missed your email. I just found it. Sorry for the late answer. >>>>> >>>>> On 6/17/2026 4:44 AM, SeongJae Park wrote: >>>>>> On Tue, 16 Jun 2026 15:03:13 +0000 <gutierrez.asier@huawei-partners.com> wrote: >>>>>> >>>>>>> From: Asier Gutierrez <gutierrez.asier@huawei-partners.com> >>>>>>> >>>>>>> Overview >>>>>>> ======== >>>>>>> >>>>>>> This patch set introduces a new autotuning which allows to collapse >>>>>>> hot regions into hugepages. >>>>>>> >>>>>>> Motivation >>>>>>> ========== >>>>>>> >>>>>>> Since TLB is a bottleneck for many systems[1], 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. >>>>>>> >>>>>>> Currently DAMON has DAMOS_HUGEPAGE, DAMOS_NONHUGEPAGE and DAMOS_COLLAPSE. >>>>>>> However, there is no way to tune the settings. It will collapse all the >>>>>>> hot regions that meet the access pattern. If the server is a bare metal >>>>>>> database or big data server, this will also lead to eventual fragmentation. >>>>>>> >>>>>>> Additionally, currently THP is set globally. Ideally, there should be a >>>>>>> way to control which tasks can use huge pages. >>>>>> >>>>>> Could you please reword for prctl(PR_SET_THP_DISABLE) like per-process control >>>>>> cases, as we discussed [1] on RFC v3? >>>>>> >>>>>>> >>>>>>> Solution >>>>>>> ======== >>>>>>> >>>>>>> DAMON has now a way to autotune some of the variables and adjust quotas >>>>>>> automatically, so that DAMON is fired only under the right circumstances. >>>>>>> It would be nice to have something similar, but for huge pages. >>>>>>> >>>>>>> A new autotuning quota goal[2], damos_hugepage_mem_bp, is introduced, >>>>>>> which checks the huge page consumption to total memory consumption. This >>>>>>> new quota mechanism reuses current autotuning architecture. >>>>>>> >>>>>>> A new sample module (SAMPLE_DAMON_HPAGE) is introduced to demonstrate >>>>>>> the use of huge pages collapse autotuning. The goal is to collapse hot >>>>>>> regions of a given process into huge pages. The sample module launches >>>>>>> a kdamond thread for a certain task provided by the user through >>>>>>> taget_pid module argument. Hugepage goal autotuning will automatically >>>>>>> adjust the aggressiveness of hot region collapses. >>>>>>> >>>>>>> This sample module also has a user autotuning knob which allows the >>>>>>> user to adjust the aggressiveness of page collapsing. >>>>>>> >>>>>>> Benchmarks >>>>>>> ========== >>>>>>> >>>>>>> Huge page collapse autotuning was tested in a physicial machine with >>>>>>> MariaDB 10.5.29 and sysbench as the benchmark framework. >>>>>>> >>>>>>> The hugepage module was set up in the following way: >>>>>>> >>>>>>> # echo 1000 > min_age >>>>>>> # echo 1000 > quota_percentage_hugepage >>>>>> >>>>>> I guess this is the quota goal? What is the unit? I guess it is aparently not >>>>>> percentage? The name doesn't sound like very consistent or intuitive. How >>>>>> about hugepage_mem_bp or target_hugepage_mem_bp? >>>>> Right, we agreed to change the name. I will correct it. >>>>>>> # echo $(pidof mariadbd) > taget_pid >>>>>>> # echo on > enabled >>>>>>> >>>>>>> The goal was to achieve 5% of the total memory used as hugepage. >>>>>> >>>>>> I guess this is what the above example is setting using >>>>>> 'quotta_percentage_hugepage'? If so, it means the unit is 1/20000 ? Is this >>>>>> correct...? >>>>> I actually set it to 500. I will update the cover letter. >>>>>>> Since the database was not very big, we may not be able to achieve >>>>>>> high amount of huge pages per total memory consumption ratio. >>>>>> >>>>>> I believe this patch series will work as you explained. But, it seems bit >>>>>> weird to show a test result that doesn't demonstrate what this patch is aimed >>>>>> to achive. Could you increase the size of the database? IIRC, you were able >>>>>> to show the percentage is over-achived case in an early version. >>>>> Actually, this is what I got using the TEMPORAL quota goals. With the regular >>>>> quota goals, it actually over-achieves the goal. >>>>> >>>>> Is this an actual bug in the TEMPORAL quota goal? >>>>>>> >>>>>>> The table below shows the memory consumption over time. Timestamp is in >>>>>>> second and the memory usage in is MBytes. Gaps in the timestamp means >>>>>>> that no changes in the hugepage consumption happened over that period >>>>>>> of time in MB. The total used memory is calculated as >>>>>>> mem_total - mem free. The huge page used is calculated as >>>>>>> huge_page_anon + huge_page_shmem + huge_page_file. The table also >>>>>>> shows the huge pages to total memory ratio. >>>>>>> >>>>>>> Hugepage autotune benchmark: >>>>>>> +-----------+----------------+----------------+----------------------+ >>>>>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>>>>> +-----------+----------------+----------------+----------------------+ >>>>>>> | 0 | 3044.988281 | 0 | 0% | >>>>>>> | 22 | 3160.207031 | 2 | 0.06% | >>>>>>> | 30 | 3250.90625 | 4 | 0.12% | >>>>>>> | 69 | 3781.238281 | 6 | 0.16% | >>>>>>> | 71 | 3822.226563 | 8 | 0.21% | >>>>>>> | 72 | 3846.578125 | 10 | 0.26% | >>>>>>> | 73 | 3852.402344 | 12 | 0.31% | >>>>>>> | 74 | 3868 | 14 | 0.36% | >>>>>>> | 75 | 3881.84375 | 104 | 2.68% | >>>>>>> | 275 | 4194.175781 | 106 | 2.52% | >>>>>>> +-----------+----------------+----------------+----------------------+ >>>>>>> After second 275, no more pages are collapsed into hugepages >>>>>>> >>>>>>> >>>>>>> THP (always) benchmark: >>>>>>> +-----------+----------------+----------------+---------------------+ >>>>>>> | timestamp | total mem used | huge page used | percentage hugepage | >>>>>>> +-----------+----------------+----------------+---------------------+ >>>>>>> | 1 | 4489.320313 | 184 | 4.098615986 | >>>>>>> | 15 | 4581.871094 | 214 | 4.670580984 | >>>>>>> | 30 | 4757.742188 | 376 | 7.902908253 | >>>>>>> | 45 | 4937.574219 | 558 | 11.30109595 | >>>>>>> | 60 | 5147.867188 | 728 | 14.14177898 | >>>>>>> | 75 | 5407.0625 | 918 | 16.97779524 | >>>>>>> | 95 | 5668.796875 | 1040 | 18.34604455 | >>>>>>> | 105 | 5723.839844 | 1056 | 18.44915352 | >>>>>>> | 115 | 5736.84375 | 1072 | 18.68623317 | >>>>>>> | 125 | 5732.042969 | 1088 | 18.98101612 | >>>>>>> | 186 | 5753.601563 | 1184 | 20.57841488 | >>>>>>> | 246 | 5746.398438 | 1280 | 22.27482159 | >>>>>>> | 306 | 5752.128906 | 1376 | 23.92157795 | >>>>>>> | 367 | 5772.5625 | 1472 | 25.49994045 | >>>>>>> | 427 | 5832.019531 | 1568 | 26.88605536 | >>>>>>> | 488 | 5813.246094 | 1664 | 28.62428277 | >>>>>>> | 548 | 5807.621094 | 1760 | 30.30500736 | >>>>>>> | 598 | 5841.253906 | 1822 | 31.19193292 | >>>>>>> | 669 | 5982.160156 | 1854 | 30.99214918 | >>>>>>> | 931 | 5946.605469 | 1868 | 31.41287933 | >>>>>>> | 981 | 6020.207031 | 1896 | 31.49393352 | >>>>>>> | 991 | 5988.445313 | 1910 | 31.89475566 | >>>>>>> | 1011 | 5988.570313 | 1926 | 32.16126554 | >>>>>>> | 1032 | 6016.039063 | 1936 | 32.18064211 | >>>>>>> | 1575 | 6057.289063 | 1968 | 32.48978181 | >>>>>>> | 1606 | 6026.167969 | 2000 | 33.18858702 | >>>>>>> +-----------+----------------+----------------+---------------------+ >>>>>>> I ignored some points to make the table shorter. Anyway, the amount >>>>>>> of memory consumption, total and huge pages, is a lot higher than >>>>>>> with DAMON hugepage autotuning. >>>>>> >>>>>> Could you further clarify why it is, and what this means >>>>> Memory fragmentation. I will add information about memory fragmentation >>>>> in the next cover letter. >> >>>>>>> >>>>>>> Performance: >>>>>>> Baseline (no THP, module off) -> 18,162.45 transactions per second >>>>>>> Hugepage autotune -> 18,211.82 transactions per second (+0.27% improvement) >>>>>>> THP always -> 18,388.3 (+1.24%) >>>>>>> THP madvise -> 18,179.25 (+0.09%) >>>>>>> >>>>>>> Improvement is due to lower TLB misses >>>>>> >>>>>> So this result says THP always is much better than the Hugepage autotune in >>>>>> terms of the performance. Maybe you want to claim Hugepage autotune is better >>>>>> in terms of the memory efficiency? Could you please clarify further? >>>>> It's better than THP "never", but worse than THP "always". THP "always" is worse >>>>> in terms of memory consumption, "always" is worse. >>>>>>> >>>>>>> Patches Sequence >>>>>>> ================ >>>>>>> Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning >>>>>>> Patch 2 -> Module that demonstrates how to use >>>>>>> DAMOS_QUOTA_HUGEPAGE_MEM_BP and DAMOS_QUOTA_GOAL_TUNER_TEMPORAL >>>>>>> Patch 3 -> Support for DAMOS_QUOTA_HUGEPAGE_MEM_BP in sysfs-schemes >>>>>>> >>>>>>> Changes from previous versions >>>>>>> ============================== >>>>>>> RFC 4[3] -> v1 >>>>>>> - Renamed config to SAMPLE_DAMON_HPAGE, file to hpage.c and >>>>>>> functions to damon_sample_hpage_... >>>>>>> - Make the module depend on TRANSPARENT_HUGEPAGE, since >>>>>>> the module will need some THP functions anyway >>>>>>> - Removed documentation, since this is just a sample module >>>>>>> - Removed DAMOS_QUOTA_HUGEPAGE_MEM_BP from >>>>>>> damos_sysfs_add_quota_score >>>>>>> - Added a short description of the module in Kconfig >>>>>> >>>>>> Thank you for continuing this work! >>>>>> >>>>>> [...] >>>>>> >>>>>>> [1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227 >>>>>>> [2] https://lore.kernel.org/e67f05ad-dbb9-45e6-ba30-b167a99ac67d@huawei-partners.com >>>>>>> [3] https://lore.kernel.org/20260611150244.3454699-1-gutierrez.asier@huawei-partners.com >>>>>>> [4] https://lore.kernel.org/20260604150338.501128-1-gutierrez.asier@huawei-partners.com >>>>>>> [5] https://lore.kernel.org/20260522145518.158910-1-gutierrez.asier@huawei-partners.com >>>>>>> [6] https://lore.kernel.org/20260522171210.900B11F00A3D@smtp.kernel.org >>>>>>> [7] https://lore.kernel.org/20260522171633.AAF5B1F000E9@smtp.kernel.org >>>>>>> [8] https://lore.kernel.org/20260430134139.2446417-1-gutierrez.asier@huawei-partners.com >>>>>>> [9] https://lore.kernel.org/all/20260430154338.E22E6C2BCB3@smtp.kernel.org/ >>>>>> >>>>>> [1] https://lore.kernel.org/9f9e2159-5a6b-496f-9633-fa06c0217948@huawei-partners.com >>>>>> >>>>>> >>>>>> Thanks, >>>>>> SJ >>>>>> >>>>>> [...] >>>>>> >>>>> >>>>> SJ, once again, sorry for the late answer. Please, disregard my new patch set, I will fix >>>>> it with your feedback. >>>>> >>>> >>>> I didn't get a reply to this email. >>> >>> I sent the reply [1] weeks ago. >>> >>>> >>>> I will update the cover letter and submit a new patch set soon. >>> >>> No, please. Let's fully complete the discussion before a new version. >>> >>> [1] https://lore.kernel.org/20260620200254.82414-1-sj@kernel.org >>> >>> >>> Thanks, >>> SJ >>> >>> [...] >> >> Hi SJ, >> >> So, I finally got some stable results which make sense now. >> >> Setup: physical server with arm64 processor with 4 NUMA nodes, >> 1 TB RAM and running mariaDB 10.5.29. I use sysbench for the >> benchmark, with 20 tables and 3 million rows per table. The database >> was pinned to one of the nodes, and the benchmark framework to a >> different node. No network traffic involved in the benchmark. >> >> I forked damo and added hugepage_mem_bp support[1]. >> >> I launch DAMON using this command line: > > This is very helpful at understanding the test setup. Thank you for sharing! > >> >> sudo ./damo start $(pidof mariadbd) \ >> --monitoring_nr_regions_range 10 1000 \ >> --monitoring_intervals 5000 100000 60000000 \ >> --damos_quota_time 0 --damos_quota_space 128000000 \ >> --damos_quota_interval 1000 \ >> --damos_quota_weights 0 1 1 \ >> --damos_quota_goal hugepage_mem_bp <target> \ >> --damos_quota_goal_tuner temporal \ >> --damos_apply_interval 50000 \ > > So, 50 ms DAMOS apply interval? Seems quite short to me. No big deal, though. > >> --damos_access_rate 0 max --damos_age 50 max \ >> --damos_action collapse --debug_damon > > FYI, damo supports human friendly formats. E.g., > > --monitoring_intervals 5ms 100ms 60s \ > --damos_quota_space 128MB --damos_quota_interval 1s \ > --damos_apply_interval 50ms > >> >> <target> was 1000 to taget 10% hugepage to total memory ratio, or >> 2500 to target 25%. Tuner was also tested with consistent and >> temporal. >> >> Results >> ======= >> After the last timestamp, there was no change in huge page use, and >> the total huge page to memory consumption ratio barely moved. >> >> Timestamp is measured in seconds, and the memory consumption (total >> and huge page) is in MB. >> >> hugepage_mem_bp: 1000 >> goal tuner: temporal >> >> +-----------+----------------+----------------+----------------------+ >> | timestamp | total mem used | huge page used | percentage hugepage | >> +-----------+----------------+----------------+----------------------+ >> | 0 | 16945.04297 | 0 | 0 | >> | 7 | 17008.69531 | 74 | 0.435071583 | >> | 8 | 17036.40234 | 194 | 1.138738074 | >> | 9 | 17017.01563 | 314 | 1.845211916 | >> | 10 | 17029.67969 | 434 | 2.548491856 | >> | 61 | 17111.30859 | 584 | 3.412947623 | >> | 75 | 17068.51953 | 612 | 3.58554823 | >> | 90 | 17098.84766 | 638 | 3.731245595 | >> | 105 | 17076.32031 | 664 | 3.888425538 | >> | 120 | 17071.05859 | 694 | 4.065360072 | >> | 135 | 17088.94531 | 722 | 4.22495354 | >> | 150 | 17101.42578 | 746 | 4.362209383 | >> | 165 | 17097.33984 | 776 | 4.53871776 | >> | 180 | 17133.88281 | 804 | 4.692456513 | >> | 195 | 17099.12891 | 832 | 4.865744943 | >> | 201 | 17103.5 | 852 | 4.981436548 | >> | 202 | 17077.84375 | 862 | 5.047475622 | >> | 203 | 17088.16406 | 916 | 5.360435426 | >> | 204 | 17126.34766 | 1046 | 6.107548562 | >> | 205 | 17093.84375 | 1176 | 6.879669764 | >> | 206 | 17142.77734 | 1298 | 7.571701913 | >> | 207 | 17129.86719 | 1428 | 8.336316822 | >> | 208 | 17099.76953 | 1556 | 9.099537846 | >> | 209 | 17149.17969 | 1686 | 9.831374041 | >> | 210 | 17097.30859 | 1754 | 10.25892462 | >> +-----------+----------------+----------------+----------------------+ > > I saw you added description of all results at the end. But adding it for each > result would be nicer for readers. E.g., you could say, > > "As expected, ~10 % huge page ratio is achieved." > > Or, you could make tables shorter by cutting more lines, keeping the height ~10 > rows per table? > >> >> hugepage_mem_bp: 1000 >> goal tuner: consistent >> >> +-----------+----------------+----------------+----------------------+ >> | timestamp | total mem used | huge page used | percentage hugepage | >> +-----------+----------------+----------------+----------------------+ >> | 0 | 16955.24609 | 0 | 0 | >> | 34 | 17039.71875 | 106 | 0.622075995 | >> | 35 | 17022.21875 | 224 | 1.315927161 | >> | 36 | 17070.08594 | 344 | 2.015221255 | >> | 37 | 17005.86719 | 464 | 2.728470091 | >> | 38 | 17028.92188 | 542 | 3.182820404 | >> | 78 | 17009.47656 | 554 | 3.257007927 | >> | 79 | 17051.82031 | 572 | 3.354480575 | >> | 90 | 17048.92188 | 596 | 3.495822225 | >> | 105 | 17086.22656 | 624 | 3.652064414 | >> | 120 | 17102.49609 | 654 | 3.824003212 | >> | 135 | 17081.31641 | 680 | 3.980957813 | >> | 150 | 17092.90625 | 706 | 4.130368409 | >> | 165 | 17093.69531 | 736 | 4.305681051 | >> | 180 | 17053.08984 | 764 | 4.480126517 | >> | 195 | 17095.73047 | 788 | 4.609337995 | >> | 210 | 17086.20703 | 818 | 4.787487349 | >> | 225 | 17095.04297 | 846 | 4.948803004 | >> | 226 | 17057.95703 | 848 | 4.971286998 | >> | 227 | 17101.46484 | 858 | 5.017114077 | >> | 228 | 17053.90625 | 896 | 5.253928261 | >> | 229 | 17061.48047 | 1016 | 5.954934578 | >> | 230 | 17097.48828 | 1136 | 6.644250789 | >> | 231 | 17080.42188 | 1256 | 7.353448347 | >> | 232 | 17118.92969 | 1376 | 8.037885692 | >> | 233 | 17100.50391 | 1496 | 8.748280216 | >> | 234 | 17110.80859 | 1616 | 9.444322816 | >> | 235 | 17138.17188 | 1736 | 10.12943512 | >> | 236 | 17060.17578 | 1856 | 10.87913761 | >> | 237 | 17118.92578 | 1976 | 11.54278034 | >> | 238 | 17119.28516 | 2096 | 12.24350188 | >> | 239 | 17098.89063 | 2216 | 12.95990511 | >> | 240 | 17135.44531 | 2334 | 13.62088908 | >> | 241 | 17097.58594 | 2454 | 14.35290344 | >> | 242 | 17134.69531 | 2574 | 15.02215215 | >> | 243 | 17127.96094 | 2694 | 15.72866735 | >> | 244 | 17097.53516 | 2812 | 16.44681514 | >> | 245 | 17132.55078 | 2932 | 17.11362212 | >> | 246 | 17117.95313 | 3052 | 17.82923448 | >> | 247 | 17154.30469 | 3172 | 18.49098554 | >> | 248 | 17145.55078 | 3292 | 19.20031641 | >> | 249 | 17138.36719 | 3410 | 19.89687794 | >> | 250 | 17163.12109 | 3532 | 20.57900763 | >> +-----------+----------------+----------------+----------------------+ > > Seems the table bit long to me. When you add this to the cover letter, I think > you could further cut some rows. Maybe showing the rows for ~2% jumps? E.g., > > +-----------+----------------+----------------+----------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+----------------------+ > | 0 | 16955.24609 | 0 | 0 | > | 36 | 17070.08594 | 344 | 2.015221255 | > | 150 | 17092.90625 | 706 | 4.130368409 | > | 230 | 17097.48828 | 1136 | 6.644250789 | > | 232 | 17118.92969 | 1376 | 8.037885692 | > | 235 | 17138.17188 | 1736 | 10.12943512 | > | 238 | 17119.28516 | 2096 | 12.24350188 | > | 241 | 17097.58594 | 2454 | 14.35290344 | > | 244 | 17097.53516 | 2812 | 16.44681514 | > | 247 | 17154.30469 | 3172 | 18.49098554 | > | 250 | 17163.12109 | 3532 | 20.57900763 | > +-----------+----------------+----------------+----------------------+ > >> >> hugepage_mem_bp: 2500 >> goal tuner: temporal >> >> +-----------+----------------+----------------+----------------------+ >> | timestamp | total mem used | huge page used | percentage hugepage | >> +-----------+----------------+----------------+----------------------+ >> | 0 | 17010.31641 | 0 | 0 | >> | 9 | 17063.6875 | 50 | 0.2930199 | >> | 10 | 17051.75781 | 170 | 0.996964664 | >> | 11 | 17059.625 | 290 | 1.699920133 | >> | 12 | 17053.72656 | 410 | 2.404166611 | >> | 13 | 17082.44141 | 528 | 3.090893084 | >> | 14 | 17097.22266 | 530 | 3.099918687 | >> | 60 | 17133.85547 | 572 | 3.338419663 | >> | 75 | 17149.26563 | 598 | 3.487029784 | >> | 90 | 17192.07813 | 626 | 3.641211932 | >> | 105 | 17196.34766 | 654 | 3.80313316 | >> | 120 | 17221.44531 | 682 | 3.960178647 | >> | 135 | 17225.36719 | 708 | 4.110217172 | >> | 150 | 17220.15625 | 736 | 4.274061102 | >> | 165 | 17223.66406 | 764 | 4.435757672 | >> | 181 | 17199.76172 | 790 | 4.593086886 | >> | 195 | 17139.11328 | 818 | 4.772708988 | >> | 205 | 17185.85547 | 862 | 5.015752644 | >> | 206 | 17228.63281 | 978 | 5.67659669 | >> | 207 | 17194.80469 | 1094 | 6.362386895 | >> | 208 | 17222.77734 | 1206 | 7.002354939 | >> | 209 | 17177.09766 | 1320 | 7.68465096 | >> | 210 | 17182.23828 | 1428 | 8.310907907 | >> | 211 | 17196.77734 | 1542 | 8.966796332 | >> | 212 | 17205.57031 | 1664 | 9.671286507 | >> | 213 | 17227.39844 | 1784 | 10.35559726 | >> | 214 | 17245.17969 | 1904 | 11.04076637 | >> | 215 | 17240.45703 | 2024 | 11.73982799 | >> | 216 | 17218.85156 | 2144 | 12.45146921 | >> | 217 | 17183.63281 | 2264 | 13.17532809 | >> | 218 | 17217.08984 | 2384 | 13.84670709 | >> | 219 | 17176.72266 | 2504 | 14.57786826 | >> | 220 | 17234.79688 | 2624 | 15.22501262 | >> | 221 | 17221.20703 | 2744 | 15.93384247 | >> | 222 | 17258.91016 | 2864 | 16.59432707 | >> | 223 | 17248.64063 | 2984 | 17.29991403 | >> | 224 | 17227.35156 | 3104 | 18.0178595 | >> | 225 | 17194.83594 | 3224 | 18.74981542 | >> | 226 | 17216.30078 | 3344 | 19.42345247 | >> | 227 | 17205.71875 | 3464 | 20.13284101 | >> | 228 | 17222.83594 | 3584 | 20.80958103 | >> | 229 | 17232.32031 | 3704 | 21.49449368 | >> | 230 | 17269.49219 | 3824 | 22.14309465 | >> | 231 | 17247.55469 | 3944 | 22.86700968 | >> | 232 | 17248.90234 | 4064 | 23.56091952 | >> | 233 | 17229.21875 | 4184 | 24.28432804 | >> | 234 | 17221.28125 | 4304 | 24.99233325 | >> | 235 | 17229.37109 | 4424 | 25.67708349 | >> +-----------+----------------+----------------+----------------------+ > > Again, table looks bit long to me. In the final version of the cover letter, > maybe we can show only ~3% jumps? E.g., > > +-----------+----------------+----------------+----------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+----------------------+ > | 0 | 17010.31641 | 0 | 0 | > | 13 | 17082.44141 | 528 | 3.090893084 | > | 207 | 17194.80469 | 1094 | 6.362386895 | > | 212 | 17205.57031 | 1664 | 9.671286507 | > | 216 | 17218.85156 | 2144 | 12.45146921 | > | 220 | 17234.79688 | 2624 | 15.22501262 | > | 224 | 17227.35156 | 3104 | 18.0178595 | > | 229 | 17232.32031 | 3704 | 21.49449368 | > | 233 | 17229.21875 | 4184 | 24.28432804 | > | 235 | 17229.37109 | 4424 | 25.67708349 | > +-----------+----------------+----------------+----------------------+ > >> >> hugepage_mem_bp: 1000 >> goal tuner: consist >> >> +-----------+----------------+----------------+----------------------+ >> | timestamp | total mem used | huge page used | percentage hugepage | >> +-----------+----------------+----------------+----------------------+ >> | 0 | 17125.85156 | 0 | 0 | >> | 38 | 17081.23438 | 76 | 0.444932716 | >> | 39 | 17133.11719 | 196 | 1.143983304 | >> | 40 | 17119.83984 | 316 | 1.84581166 | >> | 41 | 17116.48438 | 436 | 2.547252055 | >> | 60 | 17109.72656 | 554 | 3.237924335 | >> | 75 | 17158.79297 | 600 | 3.496749457 | >> | 90 | 17164.11328 | 628 | 3.65879664 | >> | 105 | 17205 | 654 | 3.801220575 | >> | 120 | 17176.01953 | 682 | 3.970652215 | >> | 136 | 17172.19922 | 710 | 4.134589816 | >> | 150 | 17154.96484 | 738 | 4.3019616 | >> | 165 | 17190.66797 | 764 | 4.444271749 | >> | 180 | 17177.66016 | 792 | 4.610639591 | >> | 195 | 17202.01563 | 822 | 4.778509786 | >> | 210 | 17160.23047 | 848 | 4.941658572 | >> | 216 | 17147.09766 | 898 | 5.237037882 | >> | 217 | 17180.72656 | 1018 | 5.925244176 | >> | 218 | 17179.74609 | 1138 | 6.624079272 | >> | 219 | 17151.43359 | 1258 | 7.334663853 | >> | 220 | 17180.86719 | 1378 | 8.020549749 | >> | 221 | 17201.65625 | 1498 | 8.708463756 | >> | 222 | 17184.45703 | 1618 | 9.415485151 | >> | 223 | 17174.21094 | 1718 | 10.00337079 | >> | 224 | 17174.90234 | 1800 | 10.48040894 | >> | 225 | 17204.64063 | 1874 | 10.89241002 | >> | 226 | 17187.82031 | 1980 | 11.51978531 | >> | 227 | 17145.08594 | 2100 | 12.24840755 | >> | 228 | 17144.25781 | 2220 | 12.948942 | >> | 229 | 17171.44141 | 2338 | 13.61563042 | >> | 230 | 17175.02344 | 2458 | 14.31147974 | >> | 231 | 17150.30469 | 2578 | 15.03180292 | >> | 232 | 17148.73438 | 2698 | 15.73293948 | >> | 233 | 17143.48438 | 2818 | 16.4377319 | >> | 234 | 17167.57422 | 2938 | 17.11365836 | >> | 235 | 17157.11328 | 3058 | 17.82351116 | >> | 236 | 17151.45703 | 3178 | 18.52903805 | >> | 237 | 17155.85938 | 3298 | 19.22375282 | >> | 238 | 17188.00781 | 3418 | 19.88595791 | >> | 239 | 17151.66406 | 3536 | 20.61607543 | >> | 240 | 17137.38281 | 3656 | 21.33347921 | >> | 241 | 17165.32422 | 3776 | 21.99783675 | >> | 242 | 17158.48438 | 3896 | 22.70596817 | >> | 243 | 17122.70313 | 4016 | 23.45424067 | >> | 244 | 17151.28516 | 4136 | 24.114811 | >> | 245 | 17188.16797 | 4256 | 24.76121951 | >> | 246 | 17150.58984 | 4376 | 25.51515744 | >> | 247 | 17178.125 | 4496 | 26.17282154 | >> | 248 | 17130.97266 | 4616 | 26.94534684 | >> | 249 | 17149.64063 | 4736 | 27.61573903 | >> | 250 | 17175.5 | 4856 | 28.27283049 | >> | 251 | 17141.30859 | 4978 | 29.04095666 | >> | 252 | 17168.22266 | 5098 | 29.69439587 | >> | 253 | 17158.42578 | 5218 | 30.41071522 | >> | 254 | 17175.84375 | 5338 | 31.07853144 | >> | 255 | 17173.60156 | 5458 | 31.78133591 | >> | 256 | 17188.17188 | 5578 | 32.45254958 | >> | 257 | 17217.83203 | 5698 | 33.09359732 | >> | 258 | 17182.50781 | 5818 | 33.86001661 | >> | 259 | 17194.44922 | 5936 | 34.52276909 | >> | 260 | 17199.66406 | 6056 | 35.20999002 | >> | 261 | 17188.90234 | 6176 | 35.93015933 | >> | 262 | 17204.27344 | 6296 | 36.59555879 | >> | 263 | 17202.03516 | 6416 | 37.29791238 | >> | 264 | 17207.71484 | 6536 | 37.98296322 | >> | 265 | 17224.46094 | 6656 | 38.64271877 | >> | 266 | 17198.29297 | 6776 | 39.39925906 | >> | 267 | 17200.13281 | 6896 | 40.09271367 | >> | 268 | 17204.625 | 7014 | 40.76810741 | >> | 269 | 17210.91406 | 7134 | 41.45044228 | >> | 270 | 17203.98438 | 7254 | 42.16465118 | >> | 271 | 17206.08203 | 7374 | 42.85693853 | >> | 272 | 17210.62891 | 7494 | 43.54285971 | >> | 273 | 17202.55859 | 7614 | 44.26085782 | >> | 274 | 17223.07813 | 7734 | 44.90486511 | >> | 275 | 17207.21875 | 7762 | 45.10897498 | >> +-----------+----------------+----------------+----------------------+ > > Again, seems long for the final version of the cover letter? We could show for > ~5% jumps? > > +-----------+----------------+----------------+----------------------+ > | timestamp | total mem used | huge page used | percentage hugepage | > +-----------+----------------+----------------+----------------------+ > | 0 | 17125.85156 | 0 | 0 | > | 216 | 17147.09766 | 898 | 5.237037882 | > | 223 | 17174.21094 | 1718 | 10.00337079 | > | 231 | 17150.30469 | 2578 | 15.03180292 | > | 239 | 17151.66406 | 3536 | 20.61607543 | > | 246 | 17150.58984 | 4376 | 25.51515744 | > | 253 | 17158.42578 | 5218 | 30.41071522 | > | 260 | 17199.66406 | 6056 | 35.20999002 | > | 267 | 17200.13281 | 6896 | 40.09271367 | > | 275 | 17207.21875 | 7762 | 45.10897498 | > +-----------+----------------+----------------+----------------------+ > >> >> From this, we can conclude that the huge page autotuner works fine, achieving >> the target. When using consistent autotuner, it actually over-achieves the >> target, which is expected, since quota esz_bp is not set to 0 to cap the >> DAMOS policy. >> >> [1] https://github.com/asierHuawei/damo/commit/79ae1a4ab1c012a7161db85a000d14f08fa36736 >> >> Let me know what you think. > > Looks good! Let's proceed to the next version of the patch series with this > great test results! Yes, I will make the tables shorter. I just wanted to show how the memory consumption changes over time, but I guess I can refer to this email in the new cover letter. > > Thanks, > SJ > > [...] -- Asier Gutierrez Huawei ^ permalink raw reply [flat|nested] 37+ messages in thread
end of thread, other threads:[~2026-07-13 15:04 UTC | newest] Thread overview: 37+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-16 15:03 [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning gutierrez.asier 2026-06-16 15:03 ` [PATCH v1 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE " gutierrez.asier 2026-06-16 15:20 ` sashiko-bot 2026-06-16 19:33 ` Gutierrez Asier 2026-06-17 3:31 ` SeongJae Park 2026-06-16 15:03 ` [PATCH v1 2/3] mm/damon: introduce DAMON_HUGEPAGE for hot region hugepage collapsing gutierrez.asier 2026-06-16 15:21 ` sashiko-bot 2026-06-16 19:27 ` Gutierrez Asier 2026-06-17 4:09 ` SeongJae Park 2026-06-17 4:04 ` SeongJae Park 2026-06-18 0:16 ` SeongJae Park 2026-06-18 0:19 ` SeongJae Park 2026-06-18 11:51 ` Gutierrez Asier 2026-06-18 14:57 ` SeongJae Park 2026-06-18 14:59 ` Gutierrez Asier 2026-06-18 15:08 ` SeongJae Park 2026-06-17 16:12 ` Julian Braha 2026-06-18 0:18 ` SeongJae Park 2026-06-16 15:03 ` [PATCH v1 3/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric gutierrez.asier 2026-06-16 15:21 ` sashiko-bot 2026-06-16 19:35 ` Gutierrez Asier 2026-06-17 4:15 ` SeongJae Park 2026-06-17 4:16 ` SeongJae Park 2026-06-17 1:44 ` [PATCH v1 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning SeongJae Park 2026-06-20 17:11 ` Gutierrez Asier 2026-06-20 20:02 ` SeongJae Park 2026-07-07 13:31 ` Gutierrez Asier 2026-07-07 14:10 ` SJ Park 2026-07-07 14:25 ` Gutierrez Asier 2026-07-08 1:22 ` SJ Park 2026-07-08 14:50 ` Gutierrez Asier 2026-07-09 0:52 ` SJ Park 2026-07-06 15:03 ` Gutierrez Asier 2026-07-06 15:16 ` SJ Park 2026-07-13 11:30 ` Gutierrez Asier 2026-07-13 14:45 ` SJ Park 2026-07-13 15:04 ` Gutierrez Asier
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.