mm/damon: Introduce a huge page collapsing mechanism using auto tuning
Subsystems (4)
SJ Park
maintainerv4 cover mm/damon: Introduce a huge page collapsing mechanism using auto tuning
From: Asier Gutierrez <[email protected]>
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.
Selective huge page collapse per process is possible using prctl and a launcher. However, this does not solve the issue with hot region detection. Additionally, it the sysadmin should create a launcher that uses PRCTL to enable THP for a particular process.
We can use the DAMON support for DAMOS_HUGEPAGE and DAMOS_COLLAPSE, to target a certain process. DAMOS_COLLAPSE can also target the hot regions in that process.
Still, there is an issue with the amount of huge page consumption. Since huge pages can lead to memory fragmentation and waste, there should be a way to limit the amount of huge page consumption. There is hugetlbfs, but it requires changes to the application code or the use of libhugetlbfs.
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.
Solution
========
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.
In order to test this new mechanism, a sample module[3] was created, but not included in this patch series. To demonstrate the tool, damo user space tool was modified[4], which sets up huge pages collapse autotuning.
Benchmarks
==========
Setup: physical server with arm64 processor with 4 NUMA nodes, 1 TB RAM and running mariaDB 10.5.29. Sysbench was used 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.
Damo user space tool was forked and hugepage_mem_bp support added[4].
DAMON was lauched 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.
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 | | 120 | 17071.05859 | 694 | 4.065360072 | | 180 | 17133.88281 | 804 | 4.692456513 | | 203 | 17088.16406 | 916 | 5.360435426 | | 204 | 17126.34766 | 1046 | 6.107548562 | | 205 | 17093.84375 | 1176 | 6.879669764 | | 206 | 17142.77734 | 1298 | 7.571701913 | | 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 | | 78 | 17009.47656 | 554 | 3.257007927 | | 90 | 17048.92188 | 596 | 3.495822225 | | 150 | 17092.90625 | 706 | 4.130368409 | | 180 | 17053.08984 | 764 | 4.480126517 | | 233 | 17100.50391 | 1496 | 8.748280216 | | 239 | 17098.89063 | 2216 | 12.95990511 | | 240 | 17135.44531 | 2334 | 13.62088908 | | 245 | 17132.55078 | 2932 | 17.11362212 | | 246 | 17117.95313 | 3052 | 17.82923448 | | 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 | | 60 | 17133.85547 | 572 | 3.338419663 | | 90 | 17192.07813 | 626 | 3.641211932 | | 120 | 17221.44531 | 682 | 3.960178647 | | 181 | 17199.76172 | 790 | 4.593086886 | | 208 | 17222.77734 | 1206 | 7.002354939 | | 214 | 17245.17969 | 1904 | 11.04076637 | | 215 | 17240.45703 | 2024 | 11.73982799 | | 220 | 17234.79688 | 2624 | 15.22501262 | | 228 | 17222.83594 | 3584 | 20.80958103 | | 231 | 17247.55469 | 3944 | 22.86700968 | | 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 | | 60 | 17109.72656 | 554 | 3.237924335 | | 90 | 17164.11328 | 628 | 3.65879664 | | 180 | 17177.66016 | 792 | 4.610639591 | | 220 | 17180.86719 | 1378 | 8.020549749 | | 226 | 17187.82031 | 1980 | 11.51978531 | | 233 | 17143.48438 | 2818 | 16.4377319 | | 240 | 17137.38281 | 3656 | 21.33347921 | | 250 | 17175.5 | 4856 | 28.27283049 | | 260 | 17199.66406 | 6056 | 35.20999002 | | 270 | 17203.98438 | 7254 | 42.16465118 | | 275 | 17207.21875 | 7762 | 45.10897498 | +-----------+----------------+----------------+----------------------+
More detailed tables are provided here[5]
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.
Patches Sequence
================
Patch 1 -> Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP and autotuning Patch 2 -> sysfs support for the new quota goal
Patch 3 -> Document hugepage_mem_bp parameter
[1] https://dl.acm.org/doi/pdf/10.1145/3307650.3322227
[2] https://lore.kernel.org/[email protected]
[3] https://lore.kernel.org/[email protected]
[4] https://github.com/asierHuawei/damo/commit/79ae1a4ab1c012a7161db85a000d14f08fa36736
[5] https://lore.kernel.org/all/[email protected]/
Changes from previous versions
==============================
v3 -> v4
- v3: https://lore.kernel.org/[email protected]
- Add R-b: from SJ.
- Handle a per-cpu count race where free pages larger than total
pages.
- Return 10,000 as hugepage memory ratio for the racy corner case,
instead of MAX_INT.
- Wordsmith commit message.
- Rebase to latest mm-new.
v2[6] -> v3
- Reworked the cover letter to make more clean the intents, design
choices and results.
- Added a guard in damos_hugepage_mem_bp in order to avoid potential
division by 0.[7]
- Fixed a typo in the documentation.
v1[8] -> v2
- Rebased onto updated mm-new
- Removed the sample module altogether, since it will increase maintenance costs[9]
- Document hugepage_mem_bp in design.rst
RFC 4[10] -> 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[11] -> 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[12] -> 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 [13]
- Fixed typos and added quota_sz to the documentation discovered by
sashiko [14]
RFC 1[15] -> 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.[16]
[6] https://lore.kernel.org/all/[email protected]
[7] https://lore.kernel.org/all/[email protected]/
[8] https://lore.kernel.org/[email protected]
[9] https://lore.kernel.org/[email protected]
[10] https://lore.kernel.org/[email protected]
[11] https://lore.kernel.org/[email protected]
[12] https://lore.kernel.org/[email protected]
[13] https://lore.kernel.org/[email protected]
[14] https://lore.kernel.org/[email protected]
[15] https://lore.kernel.org/[email protected]
[16] https://lore.kernel.org/all/[email protected]/
Note to Andrew:
Footnote references 6-16 are only used for changelog. Hence those can be removed with changelog.
Asier Gutierrez (3):
mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning mm/damon/sysfs: support hugepage_mem_bp quota goal metric Docs/mm/damon/design: Document hugepage_mem_bp target metric
Documentation/mm/damon/design.rst | 2 ++ include/linux/damon.h | 2 ++ mm/damon/core.c | 19 +++++++++++++++++++ mm/damon/sysfs-schemes.c | 4 ++++ 4 files changed, 27 insertions(+)
base-commit: 0ae786fcfff4cfea3290e16a65fe12f5c99a6d2f
Signature · 1 line
2.47.3
SJ Park
maintainerPATCH v4 1/3 mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
From: Asier Gutierrez <[email protected]>
Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP auto tuning. Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio.
Vmstat may lag, which in some cases may lead to NR_FREE_PAGES being greater than or equal to the amount of RAM in the system. A guard is added to avoid the extremely unlikely case [1]. In the case, return 100% (10000 bp).
[1] https://lore.kernel.org/all/[email protected]/
--- include/linux/damon.h | 2 ++ mm/damon/core.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+)
include/linux/damon.h +2 -0
@@ -153,6 +153,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.
@@ -167,6 +168,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, };
mm/damon/core.c +19 -0
@@ -3038,6 +3038,22 @@ 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_pages, free_pages; + + total_pages =totalram_pages (); + free_pages =global_zone_page_state (NR_FREE_PAGES ); + +if (total_pages <= free_pages) +return 10000 ; + + thp =global_node_page_state (NR_ANON_THPS ) + +global_node_page_state (NR_SHMEM_THPS ) + +global_node_page_state (NR_FILE_THPS ); +return mult_frac (thp,10000 , total_pages - free_pages); +} +static void damos_set_quota_goal_current_value (struct damon_ctx *c,struct damos *s,struct damos_quota_goal *goal) {
@@ -3074,6 +3090,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 ; }
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Unbounded metric calculation due to vmstat drift can destabilize quota tuning. - [High] Silent…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Unbounded metric calculation due to vmstat drift can destabilize quota tuning.
- [High] Silent 32-bit integer overflow in mult_frac() during memory ratio calculation. --
commit 59f2c739bce03363ce501965d6708d807908af18
Author: Asier Gutierrez <[email protected]> Date: Mon Aug 31 14:47:28 2026 +0000
mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
This commit introduces a new DAMOS quota goal metric, DAMOS_QUOTA_HUGEPAGE_MEM_BP, to auto-tune quotas based on the ratio of huge page consumption to total memory consumption. It includes a fallback mechanism for situations where vmstat counters drift and report more free pages than total RAM.
[ ... ]
Quoted 4 lines
mm/damon/core.c +0
-0
[ ... ]
Quoted 8 lines
mm/damon/core.c +4
-0@@ -3007,6 +3007,22 @@ 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_pages, free_pages; +
mm/damon/core.c static unsigned int damos_get_in_active_mem_bp(bool active_ratio) · line 3023
Quoted 10 lines
mm/damon/core.c +10
-0+ total_pages =totalram_pages (); + free_pages =global_zone_page_state (NR_FREE_PAGES ); + +if (total_pages <= free_pages) +return 10000 ; + + thp =global_node_page_state (NR_ANON_THPS ) + +global_node_page_state (NR_SHMEM_THPS ) + +global_node_page_state (NR_FILE_THPS ); +return mult_frac (thp,10000 , total_pages - free_pages);
[Severity: High]
Could the independent vmstat counters drift enough to produce an out-of-bounds ratio here?
Because NR_ANON_THPS, NR_SHMEM_THPS, NR_FILE_THPS, and NR_FREE_PAGES are updated asynchronously across CPUs, they can drift in opposite directions. On systems with high core counts, if the system's actual used memory is low but the thp stat artificially drifts higher than the calculated used memory (or used memory drifts toward zero), the calculated ratio could vastly exceed 10,000 (100%).
Would this cause the DAMOS auto-tuning PID controller to calculate an exponentially inflated goal score, ultimately crushing the tuning quota to zero and paralyzing DAMON's actions?
[Severity: High]
Can this calculation silently overflow on 32-bit architectures?
The mult_frac macro evaluates an intermediate multiplication that retains the 32-bit type of x. Both thp and total_pages are declared as unsigned long.
On 32-bit architectures like ARM32 with LPAE (which supports Transparent Hugepages and up to 1TB RAM), unsigned long is 32 bits. If THP consumption exceeds 429,496 base pages (around 1.71 GB), the intermediate calculation (thp * 10000) will wrap around U32_MAX.
For example, 2GB of THP on a 3GB system might falsely report a 9.4% ratio instead of 66.6%. Will this cause DAMON to mis-tune memory limits due to a highly truncated quota goal metric?
Quoted 2 lines
mm/damon/core.c +2
-0+} +
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
SJ Park
maintainerRe: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Quoted 58 lines · On Mon, 31 Aug 2026 18:16:31 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Unbounded metric calculation due to vmstat drift can destabilize quota tuning.
- [High] Silent 32-bit integer overflow inmult_frac()during memory ratio calculation. --commit
59f2c739bce03363ce501965d6708d807908af18Author: Asier Gutierrez <[email protected]> Date: Mon Aug 31 14:47:28 2026 +0000mm/damon: Introduce
DAMOS_QUOTA_HUGEPAGEauto tuningThis commit introduces a new DAMOS quota goal metric,
DAMOS_QUOTA_HUGEPAGE_MEM_BP, to auto-tune quotas based on the ratio of huge page consumption to total memory consumption. It includes a fallback mechanism for situations where vmstat counters drift and report more free pages than total RAM.[ ... ]
Quoted 4 lines
mm/damon/core.c +0
-0[ ... ]
Quoted 8 lines
mm/damon/core.c +4
-0@@ -3007,6 +3007,22 @@ 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_pages, free_pages; +mm/damon/core.c static unsigned int damos_get_in_active_mem_bp(bool active_ratio) · line 3023
Quoted 10 lines
mm/damon/core.c +10
-0+ total_pages =totalram_pages (); + free_pages =global_zone_page_state (NR_FREE_PAGES ); + +if (total_pages <= free_pages) +return 10000 ; + + thp =global_node_page_state (NR_ANON_THPS ) + +global_node_page_state (NR_SHMEM_THPS ) + +global_node_page_state (NR_FILE_THPS ); +return mult_frac (thp,10000 , total_pages - free_pages);[Severity: High]
Could the independent vmstat counters drift enough to produce an out-of-bounds ratio here?Because
NR_ANON_THPS,NR_SHMEM_THPS,NR_FILE_THPS, andNR_FREE_PAGESare updated asynchronously across CPUs, they can drift in opposite directions. On systems with high core counts, if the system's actual used memory is low but the thp stat artificially drifts higher than the calculated used memory (or used memory drifts toward zero), the calculated ratio could vastly exceed 10,000 (100%).
Quoted 3 lines
Would this cause the DAMOS auto-tuning PID controller to calculate an exponentially inflated goal score, ultimately crushing the tuning quota to zero and paralyzing DAMON's actions?
The tuning logic ensures the resulting quota is 1 byte in minimum 2x of current quota in maximum. So, it will be no real problem.
Quoted 8 lines
[Severity: High]
Can this calculation silently overflow on 32-bit architectures?The
mult_fracmacro evaluates an intermediate multiplication that retains the 32-bit type of x. Both thp andtotal_pagesare declared as unsigned long.
Quoted 8 lines
On 32-bit architectures like ARM32 with LPAE (which supports Transparent Hugepages and up to 1TB RAM), unsigned long is 32 bits. If THP consumption exceeds 429,496 base pages (around 1.71 GB), the intermediate calculation (thp * 10000) will wrap around
U32_MAX.For example, 2GB of THP on a 3GB system might falsely report a 9.4% ratio instead of 66.6%. Will this cause DAMON to mis-tune memory limits due to a highly truncated quota goal metric?
Known low priority issue.
Quoted 6 lines
Quoted 3 lines
mm/damon/core.c +2
-0+} +Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Thanks,
SJ
Re: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
In reply to SJ ParkHi SJ and Asier,
Thanks for working on this and for providing the server results. I have two questions about what hugepage_mem_bp is intended to represent.
Quoted 3 lines
Introduce
DAMOS_QUOTA_HUGEPAGE_MEM_BPauto tuning. Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio.
First, NR_ANON_THPS tracks anonymous PMD mappings, while NR_SHMEM_THPS and NR_FILE_THPS track PMD-mappable page-cache folios. Therefore, splitting only an anonymous PMD mapping can change hugepage_mem_bp without physically splitting the folio. Is the intended metric PMD-mapped memory or physical large-folio memory? Clarifying this and adding a mapping-only test may help.
Second, the metric is global while a DAMOS scheme can target one process. THPs from other processes or NUMA nodes can satisfy the target or dilute the monitored process's changes. Is this intentional? If so, documenting the scope and testing a background THP workload may be useful.
The temporal results approach the 10% and 25% targets, while the consistent results overshoot the 10% target to about 20% and 45%. I would describe this as control-response data. TPS, latency, TLB, fragmentation and collapse CPU data could further show the workload benefit and cost.
If I have misunderstood any of this, please feel free to ignore these comments and correct me.
The enum, quota-goal wiring and sysfs exposure otherwise look consistent with the existing DAMOS autotuning framework. I consider the points above follow-up questions about semantics and evaluation, rather than blockers for this series.
For the series:
Please feel free to Cc me on related follow-up patches. I am happy to help review the code. Besides my own DAMON work, I have recently been reviewing and learning from other DAMON and MM work, and I would be glad to continue.
Thanks,
Lian
Sent using hkml (https://github.com/sjp38/hackermail)
SJ Park
maintainerRe: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Hi Lian,
Quoted 9 lines · On Tue, 1 Sep 2026 14:58:35 +0800 Lian Wang <[email protected]> wrote:
Hi SJ and Asier,
Thanks for working on this and for providing the server results. I have two questions about what
hugepage_mem_bpis intended to represent.Quoted 3 lines
Introduce
DAMOS_QUOTA_HUGEPAGE_MEM_BPauto tuning. Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio.
Quoted 5 lines
First,
NR_ANON_THPStracks anonymous PMD mappings, whileNR_SHMEM_THPSandNR_FILE_THPStrack PMD-mappable page-cache folios. Therefore, splitting only an anonymous PMD mapping can changehugepage_mem_bpwithout physically splitting the folio. Is the intended metric PMD-mapped memory or physical large-folio memory? Clarifying this and adding a mapping-only test may help.
Good point. I was just missing this. So, hugepage_mem_bp is not accounting anon mTHPs, right? Since hugepage_mem_bp is for general hugepages, I think this is better to be improved. Seems using MTHP_STAT_NR_ANON that is exposed as 'nr_anon' can be used? Because this is an improvement rather than a fix of a bug, I think doing this as either a followup or new version of this series are ok. Asier, what do you think?
Quoted 2 lines
Second, the metric is global while a DAMOS scheme can target one process.
Actually it can target multiple processes if those are in single DAMON context.
Quoted 2 lines
THPs from other processes or NUMA nodes can satisfy the target or dilute the monitored process's changes. Is this intentional?
I think it is intentional. The user should have the control on collapsing hugepages, or believe the uncontrolled collapse mechanisms.
Quoted 2 lines
If so, documenting the
scope and testing a background THP workload may be useful.
More documentation and testing are always welcome :)
Quoted 5 lines
The temporal results approach the 10% and 25% targets, while the consistent results overshoot the 10% target to about 20% and 45%. I would describe this as control-response data. TPS, latency, TLB, fragmentation and collapse CPU data could further show the workload benefit and cost.
Yes, those would be helpful. That's not mandatory for this simple change in my opinion, though. I would let Asier decide whether and when to make and share such data.
Quoted 3 lines
If I have misunderstood any of this, please feel free to ignore these comments and correct me.
Your comments are very helpful, thank you for your review and comments, Lian.
Quoted 5 lines
The enum, quota-goal wiring and sysfs exposure otherwise look consistent with the existing DAMOS autotuning framework. I consider the points above follow-up questions about semantics and evaluation, rather than blockers for this series.
I agree.
Quoted 4 lines
For the series:
Reviewed-by Lian Wang <[email protected]>
Thank you!
Quoted 4 lines
Please feel free to Cc me on related follow-up patches. I am happy to help review the code. Besides my own DAMON work, I have recently been reviewing and learning from other DAMON and MM work, and I would be glad to continue.
I'm curious if you and general reviewers need or prefer to directly be Cc-ed. I was naively thinking people can search and review DAMON patches by subscribing to the mailing list or using the archives via lore.kernel.org like tools.
Thanks,
SJ
[...]
Re: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Hi SJ,
Quoted 1 line
Seems using
MTHP_STAT_NR_ANONthat is exposed as 'nr_anon' can be used?
Thank you for the suggestion. I will study MTHP_STAT_NR_ANON and nr_anon further, and document what I find. We can continue discussing it by email, and I will be happy to review any follow-up or updated patches.
Quoted 4 lines
I'm curious if you and general reviewers need or prefer to directly be Cc-ed. I was naively thinking people can search and review DAMON patches by subscribing to the mailing list or using the archives via lore.kernel.org like tools.
I subscribe to many mailing lists, including linux-mm and DAMON, and I also follow patches through lore. Direct Cc is not required, but I appreciate it for DAMON-related patches. Because I care deeply about DAMON, directly Cc-ed messages are filtered into my important mailbox, so I can archive and review them quickly.
I am very happy to contribute to DAMON, and I look forward to continuing our discussions and reviews by email.
Thanks,
Lian
SJ Park
maintainerRe: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Quoted 13 lines · On Wed, 2 Sep 2026 09:56:01 +0800 Lian Wang <[email protected]> wrote:
Hi SJ,
Quoted 1 line
Seems using
MTHP_STAT_NR_ANONthat is exposed as 'nr_anon' can be used?Thank you for the suggestion. I will study
MTHP_STAT_NR_ANONandnr_anonfurther, and document what I find. We can continue discussing it by email, and I will be happy to review any follow-up or updated patches.Quoted 4 lines
I'm curious if you and general reviewers need or prefer to directly be Cc-ed. I was naively thinking people can search and review DAMON patches by subscribing to the mailing list or using the archives via lore.kernel.org like tools.
Quoted 5 lines
I subscribe to many mailing lists, including linux-mm and DAMON, and I also follow patches through lore. Direct Cc is not required, but I appreciate it for DAMON-related patches. Because I care deeply about DAMON, directly Cc-ed messages are filtered into my important mailbox, so I can archive and review them quickly.
Thank you so much for your interest in DAMON, Lian. But, the problem is that my memory is so bad. :'(
I am maintaing mm patches review status dashboard for people who want to find patches that waiting for their review. It also provides the review status for each sub-mm components [2] including DAMON [3]. Maybe finding patches that waiting for your review from the dashboard is also a way for you?
If having the mail directly in your important mailbox is what you need, I believe adding mails filtering rule for DAMON patches wouldn't be that difficult. If you use hkml, it could also help you monitoring [4] those.
Yet another systematic and long term solution that I could suggest is keep reviewing and posting DAMON patches one by one, build more tracked records and trusts, eventually adding your name as DAMON reviewer or maintainer on the MAINTAINERS file. All patches sent with get_maintainers.pl will automatically Cc you. It would take time and require patience, though, of course.
Quoted 3 lines
I am very happy to contribute to DAMON, and I look forward to continuing our discussions and reviews by email.
I really appreciate your interest and contributions to DAMON. I hope it to be continued long term!
[1] https://github.com/sjp38/mm_git_dashboard
[2] https://github.com/sjp38/mm_git_dashboard/tree/master/summary/subsystem
[3] https://github.com/sjp38/mm_git_dashboard/tree/master/summary/subsystem/DAMON
[4] https://github.com/sjp38/hackermail/blob/master/USAGE.md#monitoring-mails
Thanks,
SJ
[...]
Re: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Quoted 37 lines · SJ Park
Quoted 13 lines · On Wed, 2 Sep 2026 09:56:01 +0800 Lian Wang <[email protected]…
Hi SJ,
Quoted 1 line
Seems using
MTHP_STAT_NR_ANONthat is exposed as 'nr_anon' can be used?Thank you for the suggestion. I will study
MTHP_STAT_NR_ANONandnr_anonfurther, and document what I find. We can continue discussing it by email, and I will be happy to review any follow-up or updated patches.Quoted 4 lines
I'm curious if you and general reviewers need or prefer to directly be Cc-ed. I was naively thinking people can search and review DAMON patches by subscribing to the mailing list or using the archives via lore.kernel.org like tools.
Quoted 5 lines
I subscribe to many mailing lists, including linux-mm and DAMON, and I also follow patches through lore. Direct Cc is not required, but I appreciate it for DAMON-related patches. Because I care deeply about DAMON, directly Cc-ed messages are filtered into my important mailbox, so I can archive and review them quickly.
Thank you so much for your interest in DAMON, Lian. But, the problem is that my memory is so bad. :'(
I am maintaing mm patches review status dashboard for people who want to find patches that waiting for their review. It also provides the review status for each sub-mm components [2] including DAMON [3]. Maybe finding patches that waiting for your review from the dashboard is also a way for you?
If having the mail directly in your important mailbox is what you need, I believe adding mails filtering rule for DAMON patches wouldn't be that difficult. If you use hkml, it could also help you monitoring [4] those.
Quoted 5 lines
Yet another systematic and long term solution that I could suggest is keep reviewing and posting DAMON patches one by one, build more tracked records and trusts, eventually adding your name as DAMON reviewer or maintainer on the
MAINTAINERSfile. All patches sent with get_maintainers.pl will automatically Cc you. It would take time and require patience, though, of course.
Thank you for your detailed feedback.
Quoted 5 lines
Quoted 4 lines
I am very happy to contribute to DAMON, and I look forward to continuing our discussions and reviews by email.
Quoted 8 lines
I really appreciate your interest and contributions to DAMON. I hope it to be continued long term!
[1] https://github.com/sjp38/mm_git_dashboard
[2] https://github.com/sjp38/mm_git_dashboard/tree/master/summary/subsystem
[3] https://github.com/sjp38/mm_git_dashboard/tree/master/summary/subsystem/DAMON
[4] https://github.com/sjp38/hackermail/blob/master/USAGE.md#monitoring-mails
Okay, I will. I will contribute to the community, continuously learn and provide feedback to ultimately make Damon better.
Quoted 5 lines
Thanks,
SJ
Thanks
Lian
Quoted 1 line
[...]
Re: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
In reply to SJ ParkHi SJ and Lian,
Quoted 19 lines · SJ Park
Hi Lian,
Quoted 9 lines · On Tue, 1 Sep 2026 14:58:35 +0800 Lian Wang <[email protected]> wrote:
Hi SJ and Asier,
Thanks for working on this and for providing the server results. I have two questions about what
hugepage_mem_bpis intended to represent.Quoted 3 lines
Introduce
DAMOS_QUOTA_HUGEPAGE_MEM_BPauto tuning. Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio.Quoted 5 lines
First,
NR_ANON_THPStracks anonymous PMD mappings, whileNR_SHMEM_THPSandNR_FILE_THPStrack PMD-mappable page-cache folios. Therefore, splitting only an anonymous PMD mapping can changehugepage_mem_bpwithout physically splitting the folio. Is the intended metric PMD-mapped memory or physical large-folio memory? Clarifying this and adding a mapping-only test may help.
Quoted 6 lines
Good point. I was just missing this. So,
hugepage_mem_bpis not accounting anon mTHPs, right? Sincehugepage_mem_bpis for general hugepages, I think this is better to be improved. Seems usingMTHP_STAT_NR_ANONthat is exposed as 'nr_anon' can be used? Because this is an improvement rather than a fix of a bug, I think doing this as either a followup or new version of this series are ok. Asier, what do you think?
Agree, I will submit a new patch to fix this behaviour and account for mTHP.
Lian, thanks a lot for the review and pointing this issue.>>
Quoted 16 lines
Quoted 1 line
Second, the metric is global while a DAMOS scheme can target one process.
Actually it can target multiple processes if those are in single DAMON context.
Quoted 2 lines
THPs from other processes or NUMA nodes can satisfy the target or dilute the monitored process's changes. Is this intentional?
I think it is intentional. The user should have the control on collapsing hugepages, or believe the uncontrolled collapse mechanisms.
Quoted 2 lines
If so, documenting the
scope and testing a background THP workload may be useful.More documentation and testing are always welcome :)
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
The temporal results approach the 10% and 25% targets, while the consistent results overshoot the 10% target to about 20% and 45%. I would describe this as control-response data. TPS, latency, TLB, fragmentation and collapse CPU data could further show the workload benefit and cost.
Yes, those would be helpful. That's not mandatory for this simple change in my opinion, though. I would let Asier decide whether and when to make and share such data.
The idea of this patch was to introduce auto tuning. I think I submitted thebenchmark results when I sent the DAMOS_COLLAPSE feature.
Anyway, it shouldn't take long for me to get more data. I think it may be useful for people to know the actual results in real application.
SJ, what's the best place to publish all those data? I believe you have more experience sharing this data and which platform is the most useful one.>>
Quoted 35 lines
Quoted 2 lines
If I have misunderstood any of this, please feel free to ignore these comments and correct me.
Your comments are very helpful, thank you for your review and comments, Lian.
Quoted 5 lines
The enum, quota-goal wiring and sysfs exposure otherwise look consistent with the existing DAMOS autotuning framework. I consider the points above follow-up questions about semantics and evaluation, rather than blockers for this series.
I agree.
Quoted 4 lines
For the series:
Reviewed-by Lian Wang <[email protected]>Thank you!
Quoted 4 lines
Please feel free to Cc me on related follow-up patches. I am happy to help review the code. Besides my own DAMON work, I have recently been reviewing and learning from other DAMON and MM work, and I would be glad to continue.
I'm curious if you and general reviewers need or prefer to directly be Cc-ed. I was naively thinking people can search and review DAMON patches by subscribing to the mailing list or using the archives via lore.kernel.org like tools.
Thanks,
SJ[...]
Signature · 2 lines
Asier Gutierrez Huawei
SJ Park
maintainerRe: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Quoted 7 lines · On Wed, 2 Sep 2026 18:03:39 +0300 Gutierrez Asier…
Hi SJ and Lian,
Quoted 4 lines · SJ Park
Hi Lian,
On Tue, 1 Sep 2026 14:58:35 +0800 Lian Wang <[email protected]> wrote:
[...]
Quoted 24 lines
Quoted 16 lines
Quoted 1 line
Second, the metric is global while a DAMOS scheme can target one process.
Actually it can target multiple processes if those are in single DAMON context.
Quoted 2 lines
THPs from other processes or NUMA nodes can satisfy the target or dilute the monitored process's changes. Is this intentional?
I think it is intentional. The user should have the control on collapsing hugepages, or believe the uncontrolled collapse mechanisms.
Quoted 2 lines
If so, documenting the
scope and testing a background THP workload may be useful.More documentation and testing are always welcome :)
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
The temporal results approach the 10% and 25% targets, while the consistent results overshoot the 10% target to about 20% and 45%. I would describe this as control-response data. TPS, latency, TLB, fragmentation and collapse CPU data could further show the workload benefit and cost.
Yes, those would be helpful. That's not mandatory for this simple change in my opinion, though. I would let Asier decide whether and when to make and share such data.
Quoted 7 lines
The idea of this patch was to introduce auto tuning. I think I submitted thebenchmark results when I sent the
DAMOS_COLLAPSEfeature.Anyway, it shouldn't take long for me to get more data. I think it may be useful for people to know the actual results in real application.
SJ, what's the best place to publish all those data? I believe you have more experience sharing this data and which platform is the most useful one.>>
I'm never an expert in visibility :) But if I should recommend, I get three places off the top of my head.
First, you could simply share the data with plain mail on DAMON and wider kernel mailing lists like linux-mm@ and linux-kernel@.
Second, if the data is matured, sharing those in conferences like LPC, OSSummit, FOSDEM or DAMON (nano) Conference would be nice.
Third, if you prefer text, LWN or personal blogs like medias could also be good places. I also maintain DAMON porject blog [1]. Kunwu and Lian actually contributed an article to the blog before. If you want to submit an article there, let me know.
[1] https://damonitor.github.io/posts/
[2] https://damonitor.github.io/posts/tlb_flush_policy/
Thanks,
SJ
[...]
SJ Park
maintainerPATCH v4 2/3 mm/damon/sysfs: support hugepage_mem_bp quota goal metric
In reply to SJ ParkFrom: Asier Gutierrez <[email protected]>
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.
--- mm/damon/sysfs-schemes.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/damon/sysfs-schemes.c +4 -0
@@ -1269,6 +1269,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,
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v4 2/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The new `hugepage_mem_bp` metric is missing from the sysfs selftests. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The new hugepage_mem_bp metric is missing from the sysfs selftests. --
commit a2c5ad81dadcc820e74efd9d73c1f576bbe76457
Author: Asier Gutierrez <[email protected]>
mm/damon/sysfs: support hugepage_mem_bp quota goal metric
This commit introduces the new DAMOS_QUOTA_HUGEPAGE_MEM_BP autotune policy metric. It also exposes this metric to userspace through the sysfs-schemes interface by adding "hugepage_mem_bp" to the list of recognized metrics.
Quoted 4 lines
mm/damon/sysfs-schemes.c +0
-0
[ ... ]
mm/damon/sysfs-schemes.c struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = { · line 1275
Quoted 8 lines
mm/damon/sysfs-schemes.c +4
-0@@ -1269,6 +1269,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: Medium]
Should the new hugepage_mem_bp metric be added to the DAMON sysfs kselftest?
Looking at tools/testing/selftests/damon/sysfs.sh in test_goal(), it explicitly validates all supported metric strings by writing them to the sysfs node:
ensure_write_succ "$fpath" "node_eligible_mem_bp" "valid input" ensure_write_fail "$fpath" "foo" "invalid input"
Without adding hugepage_mem_bp to this selftest script, the new sysfs metric is left without automated test coverage.
Quoted 3 lines
mm/damon/sysfs-schemes.c +0
-0}; static ssize_t target_metric_show(struct kobject *kobj,
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
SJ Park
maintainerRe: [PATCH v4 2/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric
Quoted 32 lines · On Mon, 31 Aug 2026 18:22:08 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The newhugepage_mem_bpmetric is missing from the sysfs selftests. --commit
a2c5ad81dadcc820e74efd9d73c1f576bbe76457
Author: Asier Gutierrez <[email protected]>
mm/damon/sysfs: supporthugepage_mem_bpquota goal metricThis commit introduces the new
DAMOS_QUOTA_HUGEPAGE_MEM_BPautotune policy metric. It also exposes this metric to userspace through the sysfs-schemes interface by adding "hugepage_mem_bp" to the list of recognized metrics.Quoted 4 lines
mm/damon/sysfs-schemes.c +0
-0[ ... ]
mm/damon/sysfs-schemes.c struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = { · line 1275
Quoted 8 lines
mm/damon/sysfs-schemes.c +4
-0@@ -1269,6 +1269,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: Medium]
Should the newhugepage_mem_bpmetric be added to the DAMON sysfs kselftest?
Quoted 8 lines
Looking at
tools/testing/selftests/damon/sysfs.shintest_goal(), it explicitly validates all supported metric strings by writing them to the sysfs node:
ensure_write_succ"$fpath" "node_eligible_mem_bp" "valid input"ensure_write_fail"$fpath" "foo" "invalid input"Without adding
hugepage_mem_bpto this selftest script, the new sysfs metric is left without automated test coverage.
I'm working on this, and this shouldn't be a blocker of this series.
Quoted 7 lines
Quoted 4 lines
mm/damon/sysfs-schemes.c +0
-0}; static ssize_t target_metric_show(struct kobject *kobj,Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Thanks,
SJ
SJ Park
maintainerPATCH v4 3/3 Docs/mm/damon/design: Document hugepage_mem_bp target metric
In reply to SJ ParkFrom: Asier Gutierrez <[email protected]>
Document hugepage_mem_bp metric exposed by sysfs.
--- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+)
Documentation/mm/damon/design.rst +2 -0
@@ -713,6 +713,8 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to bp (1/10,000). - ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio of a node in bp (1/10,000). +- ``hugepage_mem_bp``: Total huge page to total used memory ratio in bp + (1/10,000). ``nid`` is optionally required for ``node_mem_used_bp``, ``node_mem_free_bp``, ``node_memcg_used_bp``, ``node_memcg_free_bp`` and ``node_eligible_mem_bp`` to
Signature · 1 line
2.47.3
Randy Dunlap
reviewerRe: [PATCH v4 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric
Hi,
Quoted 16 lines · SJ Park
From: Asier Gutierrez <[email protected]>
Document
hugepage_mem_bpmetric exposed by sysfs.Signed-off-by Asier Gutierrez <[email protected]>Reviewed-by SJ Park <[email protected]>Signed-off-by SJ Park <[email protected]>--- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+)Documentation/mm/damon/design.rst +0
-0
Documentation/mm/damon/design.rst mechanism tries to make ``current_value`` of ``target_metric`` be same to · line 720
Quoted 8 lines
Documentation/mm/damon/design.rst +2
-0@@ -713,6 +713,8 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to bp (1/10,000). - ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio of a node in bp (1/10,000). +- ``hugepage_mem_bp``: Total huge page to total used memory ratio in bp + (1/10,000). ``nid`` is optionally required for ``node_mem_used_bp``, ``node_mem_free_bp``, ``node_memcg_used_bp``, ``node_memcg_free_bp`` and ``node_eligible_mem_bp`` to
I've looked thru the entire design.rst file and cannot find anything telling me (or anyone) what "bp" means. Explain??
thanks.
Signature · 1 line
~Randy
Randy Dunlap
reviewerRe: [PATCH v4 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric
Quoted 25 lines · Randy Dunlap
Hi,
Quoted 22 lines · SJ Park
From: Asier Gutierrez <[email protected]>
Document
hugepage_mem_bpmetric exposed by sysfs.Signed-off-by Asier Gutierrez <[email protected]>Reviewed-by SJ Park <[email protected]>Signed-off-by SJ Park <[email protected]>--- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+)Documentation/mm/damon/design.rst +2
-0@@ -713,6 +713,8 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to bp (1/10,000). - ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio of a node in bp (1/10,000). +- ``hugepage_mem_bp``: Total huge page to total used memory ratio in bp + (1/10,000).
Quoted 5 lines
Documentation/mm/damon/design.rst mechanism tries to make ``current_value`` of ``target_metric`` be same to · line 720
Quoted 2 lines
Documentation/mm/damon/design.rst +0
-0``nid`` is optionally required for ``node_mem_used_bp``, ``node_mem_free_bp``, ``node_memcg_used_bp``, ``node_memcg_free_bp`` and ``node_eligible_mem_bp`` toI've looked thru the entire
design.rstfile and cannot find anything telling me (or anyone) what "bp" means. Explain??
OK, I found it on the internet. I still think that it would be a good idea to say "basis point" one time (the first time that it is used).
Signature · 1 line
~Randy
SJ Park
maintainerRe: [PATCH v4 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric
Quoted 28 lines · On Mon, 31 Aug 2026 13:00:26 -0700 Randy Dunlap <[email protected]> wrote:
Quoted 25 lines · Randy Dunlap
Hi,
Quoted 22 lines · SJ Park
From: Asier Gutierrez <[email protected]>
Document
hugepage_mem_bpmetric exposed by sysfs.Signed-off-by Asier Gutierrez <[email protected]>Reviewed-by SJ Park <[email protected]>Signed-off-by SJ Park <[email protected]>--- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+)Documentation/mm/damon/design.rst +2
-0@@ -713,6 +713,8 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to bp (1/10,000). - ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio of a node in bp (1/10,000). +- ``hugepage_mem_bp``: Total huge page to total used memory ratio in bp + (1/10,000).
Quoted 8 lines
Quoted 5 lines
Documentation/mm/damon/design.rst mechanism tries to make ``current_value`` of ``target_metric`` be same to · line 720
Quoted 2 lines
Documentation/mm/damon/design.rst +0
-0``nid`` is optionally required for ``node_mem_used_bp``, ``node_mem_free_bp``, ``node_memcg_used_bp``, ``node_memcg_free_bp`` and ``node_eligible_mem_bp`` toI've looked thru the entire
design.rstfile and cannot find anything telling me (or anyone) what "bp" means. Explain??OK, I found it on the internet. I still think that it would be a good idea to say "basis point" one time (the first time that it is used).
You are right, and I agree. I will add that clarification before the next merge window.
Quoted 4 lines
Signature · 2 lines
-- ~Randy
Thanks,
SJ
Re: [PATCH v4 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric
Quoted 1 line · SJ Park
On Mon, 31 Aug 2026 13:00:26 -0700 Randy Dunlap <[email protected]> wrote:
Hi,
Quoted 43 lines
Quoted 29 lines · Randy Dunlap
Quoted 25 lines
Hi,
Quoted 22 lines · SJ Park
From: Asier Gutierrez <[email protected]>
Document
hugepage_mem_bpmetric exposed by sysfs.Signed-off-by Asier Gutierrez <[email protected]>Reviewed-by SJ Park <[email protected]>Signed-off-by SJ Park <[email protected]>--- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+)Documentation/mm/damon/design.rst +2
-0@@ -713,6 +713,8 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to bp (1/10,000). - ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio of a node in bp (1/10,000). +- ``hugepage_mem_bp``: Total huge page to total used memory ratio in bp + (1/10,000).Quoted 8 lines
Quoted 5 lines
Documentation/mm/damon/design.rst mechanism tries to make ``current_value`` of ``target_metric`` be same to · line 720
Quoted 2 lines
Documentation/mm/damon/design.rst +0
-0``nid`` is optionally required for ``node_mem_used_bp``, ``node_mem_free_bp``, ``node_memcg_used_bp``, ``node_memcg_free_bp`` and ``node_eligible_mem_bp`` toI've looked thru the entire
design.rstfile and cannot find anything telling me (or anyone) what "bp" means. Explain??OK, I found it on the internet. I still think that it would be a good idea to say "basis point" one time (the first time that it is used).
You are right, and I agree. I will add that clarification before the next merge window.
Quoted 2 lines
Quoted 6 lines
Quoted 2 lines
Signature · 1 line
~RandyThanks,
SJ
SJ, should I submit a new patch to fix design.rst?
Signature · 2 lines
Asier Gutierrez Huawei
SJ Park
maintainerRe: [PATCH v4 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric
Quoted 46 lines · On Tue, 1 Sep 2026 08:20:50 +0300 Gutierrez Asier…
Quoted 1 line · SJ Park
On Mon, 31 Aug 2026 13:00:26 -0700 Randy Dunlap <[email protected]> wrote:
Hi,
Quoted 43 lines
Quoted 29 lines · Randy Dunlap
Quoted 25 lines
Hi,
Quoted 22 lines · SJ Park
From: Asier Gutierrez <[email protected]>
Document
hugepage_mem_bpmetric exposed by sysfs.Signed-off-by Asier Gutierrez <[email protected]>Reviewed-by SJ Park <[email protected]>Signed-off-by SJ Park <[email protected]>--- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+)Documentation/mm/damon/design.rst +2
-0@@ -713,6 +713,8 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to bp (1/10,000). - ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory ratio of a node in bp (1/10,000). +- ``hugepage_mem_bp``: Total huge page to total used memory ratio in bp + (1/10,000).Quoted 8 lines
Quoted 5 lines
Documentation/mm/damon/design.rst mechanism tries to make ``current_value`` of ``target_metric`` be same to · line 720
Quoted 2 lines
Documentation/mm/damon/design.rst +0
-0``nid`` is optionally required for ``node_mem_used_bp``, ``node_mem_free_bp``, ``node_memcg_used_bp``, ``node_memcg_free_bp`` and ``node_eligible_mem_bp`` toI've looked thru the entire
design.rstfile and cannot find anything telling me (or anyone) what "bp" means. Explain??OK, I found it on the internet. I still think that it would be a good idea to say "basis point" one time (the first time that it is used).
You are right, and I agree. I will add that clarification before the next merge window.
Quoted 2 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Signature · 1 line
~RandyThanks,
SJSJ, should I submit a new patch to fix
design.rst?
The lack of the clarification of 'bp' was introduced before this patch. So I don't think you should do that on your own.
Of course you could do if you want to. But that should be a separate patch in my opinion. Let me know if you will. Otherwise I will do.
Thanks,
SJ
[...]
[email protected]
AI reviewRe: [PATCH v4 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric
In reply to SJ ParkThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Integer overflow in `mult_frac` on 32-bit systems for memory exceeding ~1.75 GB of huge pages…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Integer overflow in mult_frac on 32-bit systems for memory exceeding ~1.75 GB of huge pages, resulting in incorrect DAMOS quota auto-tuning.
- [Medium] The newly introduced DAMOS quota goal metric 'hugepage_mem_bp' is not tested in the DAMON sysfs selftests.
--
commit 59f2c739bce03363ce501965d6708d807908af18
Author: Asier Gutierrez <[email protected]>
mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP auto tuning. Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio.
Quoted 4 lines
mm/damon/core.c +0
-0
[ ... ]
Quoted 8 lines
mm/damon/core.c +4
-0@@ -3007,6 +3007,22 @@ 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_pages, free_pages; +
mm/damon/core.c static unsigned int damos_get_in_active_mem_bp(bool active_ratio) · line 3023
Quoted 10 lines
mm/damon/core.c +10
-0+ total_pages =totalram_pages (); + free_pages =global_zone_page_state (NR_FREE_PAGES ); + +if (total_pages <= free_pages) +return 10000 ; + + thp =global_node_page_state (NR_ANON_THPS ) + +global_node_page_state (NR_SHMEM_THPS ) + +global_node_page_state (NR_FILE_THPS ); +return mult_frac (thp,10000 , total_pages - free_pages);
[Severity: High]
Does this calculation overflow on 32-bit systems?
Since thp is an unsigned long, on a 32-bit architecture it is a 32-bit integer. If the system has more than ~1.75 GB of huge pages (about 429,496 pages), the internal multiplication thp * 10000 will exceed 4,294,967,295 and wrap around.
This leads to an incorrect value being returned from mult_frac() and results in incorrect DAMOS auto-tuning.
commit a2c5ad81dadcc820e74efd9d73c1f576bbe76457
Author: Asier Gutierrez <[email protected]>
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.
Quoted 4 lines
mm/damon/sysfs-schemes.c +0
-0
[ ... ]
mm/damon/sysfs-schemes.c struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = { · line 1276
Quoted 9 lines
mm/damon/sysfs-schemes.c +4
-0@@ -1269,6 +1269,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: Medium]
Should there be an accompanying update to the selftests for this new sysfs metric?
Currently, the hugepage_mem_bp metric is missing from the tests. For example, in tools/testing/selftests/damon/sysfs.sh:test_goal(), the new metric is not verified:
tools/testing/selftests/damon/sysfs.sh:test_goal() {
...
ensure_write_succ "$fpath" "node_eligible_mem_bp" "valid input" ensure_write_fail "$fpath" "foo" "invalid input"
...
}
Running the sysfs.sh selftest will silently skip testing the new metric because it wasn't added to the hardcoded list of valid inputs.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
SJ Park
maintainerRe: [PATCH v4 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric
Quoted 43 lines · On Mon, 31 Aug 2026 18:35:58 +0000 [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Integer overflow inmult_fracon 32-bit systems for memory exceeding ~1.75 GB of huge pages, resulting in incorrect DAMOS quota auto-tuning.
- [Medium] The newly introduced DAMOS quota goal metric 'hugepage_mem_bp' is not tested in the DAMON sysfs selftests.
--commit
59f2c739bce03363ce501965d6708d807908af18
Author: Asier Gutierrez <[email protected]>mm/damon: Introduce
DAMOS_QUOTA_HUGEPAGEauto tuningIntroduce
DAMOS_QUOTA_HUGEPAGE_MEM_BPauto tuning. Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio.Quoted 4 lines
mm/damon/core.c +0
-0[ ... ]
Quoted 8 lines
mm/damon/core.c +4
-0@@ -3007,6 +3007,22 @@ 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_pages, free_pages; +mm/damon/core.c static unsigned int damos_get_in_active_mem_bp(bool active_ratio) · line 3023
Quoted 10 lines
mm/damon/core.c +10
-0+ total_pages =totalram_pages (); + free_pages =global_zone_page_state (NR_FREE_PAGES ); + +if (total_pages <= free_pages) +return 10000 ; + + thp =global_node_page_state (NR_ANON_THPS ) + +global_node_page_state (NR_SHMEM_THPS ) + +global_node_page_state (NR_FILE_THPS ); +return mult_frac (thp,10000 , total_pages - free_pages);[Severity: High]
Does this calculation overflow on 32-bit systems?
Quoted 7 lines
Since thp is an unsigned long, on a 32-bit architecture it is a 32-bit integer. If the system has more than ~1.75 GB of huge pages (about 429,496 pages), the internal multiplication thp * 10000 will exceed 4,294,967,295 and wrap around.
This leads to an incorrect value being returned from
mult_frac()and results in incorrect DAMOS auto-tuning.
Known low priority issue.
Quoted 39 lines
commit
a2c5ad81dadcc820e74efd9d73c1f576bbe76457
Author: Asier Gutierrez <[email protected]>
mm/damon/sysfs: supporthugepage_mem_bpquota goal metricDAMOS has a new autotune policy metric:
DAMOS_QUOTA_HUGEPAGE_MEM_BP. This patch exposesDAMOS_QUOTA_HUGEPAGE_MEM_BPthrough sysfs.Quoted 4 lines
mm/damon/sysfs-schemes.c +0
-0[ ... ]
mm/damon/sysfs-schemes.c struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = { · line 1276
Quoted 9 lines
mm/damon/sysfs-schemes.c +4
-0@@ -1269,6 +1269,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: Medium]
Should there be an accompanying update to the selftests for this new sysfs metric?Currently, the
hugepage_mem_bpmetric is missing from the tests. For example, in tools/testing/selftests/damon/sysfs.sh:test_goal(), the new metric is not verified:tools/testing/selftests/damon/sysfs.sh:test_goal() {
...
ensure_write_succ"$fpath" "node_eligible_mem_bp" "valid input"ensure_write_fail"$fpath" "foo" "invalid input"
...
}
Quoted 2 lines
Running the
sysfs.shselftest will silently skip testing the new metric because it wasn't added to the hardcoded list of valid inputs.
I'm working for it, separately. No blocker.
Quoted 3 lines
Signature · 2 lines
-- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Thanks,
SJ
SJ Park
maintainerQuoted 6 lines · On Mon, 31 Aug 2026 07:47:27 -0700 SJ Park <[email protected]> wrote:
From: Asier Gutierrez <[email protected]>
Overview
========
This patch set introduces a new autotuning which allows to collapse hot regions into hugepages.
Sashiko found no blocker for this series. Sashiko sent findings to damon@ mailing list [1], and I replied to all the comments. Please read those for details.
[1] https://lore.kernel.org/damon/
Thanks,
SJ
[...]