From: Asier Gutierrez Introduce DAMOS_QUOTA_HUGEPAGE auto tuning Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total anonymous memory consumption ratio. Signed-off-by: Asier Gutierrez --- include/linux/damon.h | 1 + mm/damon/core.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index f2cdb7c3f5e6..97201e9fa407 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -172,6 +172,7 @@ enum damos_quota_goal_metric { DAMOS_QUOTA_NODE_MEMCG_FREE_BP, DAMOS_QUOTA_ACTIVE_MEM_BP, DAMOS_QUOTA_INACTIVE_MEM_BP, + DAMOS_QUOTA_HUGEPAGE, NR_DAMOS_QUOTA_GOAL_METRICS, }; diff --git a/mm/damon/core.c b/mm/damon/core.c index 3dbbbfdeff71..06547e590ff2 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2319,6 +2319,18 @@ static unsigned int damos_get_in_active_mem_bp(bool active_ratio) return mult_frac(inactive, 10000, total); } +/* + * Returns anon hugepage memory to total anon memory use ratio. + */ +static unsigned int damos_get_used_hugepage_mem_bp(void) +{ + unsigned long used_hugepages, total_used; + + used_hugepages = global_node_page_state(NR_ANON_THPS); + total_used = global_node_page_state(NR_ANON_MAPPED); + return mult_frac(used_hugepages, 10000, total_used); +} + static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal) { u64 now_psi_total; @@ -2345,6 +2357,9 @@ static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal) goal->current_value = damos_get_in_active_mem_bp( goal->metric == DAMOS_QUOTA_ACTIVE_MEM_BP); break; + case DAMOS_QUOTA_HUGEPAGE: + goal->current_value = damos_get_used_hugepage_mem_bp(); + break; default: break; } -- 2.43.0