From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Asier Gutierrez <gutierrez.asier@huawei-partners.com>,
SJ Park <sj@kernel.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning
Date: Mon, 31 Aug 2026 07:47:28 -0700 [thread overview]
Message-ID: <20260831144732.80910-2-sj@kernel.org> (raw)
In-Reply-To: <20260831144732.80910-1-sj@kernel.org>
From: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
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/20260715151615.99767-1-sj@kernel.org/
Signed-off-by: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
include/linux/damon.h | 2 ++
mm/damon/core.c | 19 +++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 5607f98ec6306..310509455db13 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -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,
};
diff --git a/mm/damon/core.c b/mm/damon/core.c
index a5ea3e61e7f41..3fa1b096c8330 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -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;
}
--
2.47.3
next prev parent reply other threads:[~2026-08-31 14:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 14:47 [PATCH v4 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning SJ Park
2026-08-31 14:47 ` SJ Park [this message]
2026-09-01 6:58 ` [PATCH v4 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE " Lian Wang
2026-09-01 14:23 ` SJ Park
2026-09-02 1:56 ` Lian Wang
2026-09-02 4:23 ` SJ Park
2026-09-02 5:12 ` wang lian
2026-09-02 15:03 ` Gutierrez Asier
2026-09-02 15:15 ` SJ Park
2026-08-31 14:47 ` [PATCH v4 2/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric SJ Park
2026-08-31 14:47 ` [PATCH v4 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric SJ Park
2026-08-31 15:45 ` Randy Dunlap
2026-08-31 20:00 ` Randy Dunlap
2026-09-01 0:47 ` SJ Park
2026-09-01 5:20 ` Gutierrez Asier
2026-09-01 5:31 ` SJ Park
2026-09-01 0:49 ` [PATCH v4 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning SJ Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260831144732.80910-2-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=gutierrez.asier@huawei-partners.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox