Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/core: add DAMOS quota gaol metric for per-memcg per-numa free memory

Add a variant of DAMOS_QUOTA_NODE_MEMCG_USED_BP, for the free memory
portion. The value of the metric is implemented as the entire memory of
the given NUMA node subtracted by the given cgroup's usage. So from a
perspective, "unused" could be a better term than "free". But arguably it
is not very clear what is better, so use the term "free".

Link: https://lkml.kernel.org/r/20251017212706.183502-7-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
98fdce76 a1d1df78

+12 -4
+4 -2
include/linux/damon.h
··· 148 148 * @DAMOS_QUOTA_NODE_MEM_USED_BP: MemUsed ratio of a node. 149 149 * @DAMOS_QUOTA_NODE_MEM_FREE_BP: MemFree ratio of a node. 150 150 * @DAMOS_QUOTA_NODE_MEMCG_USED_BP: MemUsed ratio of a node for a cgroup. 151 + * @DAMOS_QUOTA_NODE_MEMCG_FREE_BP: MemFree ratio of a node for a cgroup. 151 152 * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. 152 153 * 153 154 * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupported. ··· 159 158 DAMOS_QUOTA_NODE_MEM_USED_BP, 160 159 DAMOS_QUOTA_NODE_MEM_FREE_BP, 161 160 DAMOS_QUOTA_NODE_MEMCG_USED_BP, 161 + DAMOS_QUOTA_NODE_MEMCG_FREE_BP, 162 162 NR_DAMOS_QUOTA_GOAL_METRICS, 163 163 }; 164 164 ··· 185 183 * If @metric is DAMOS_QUOTA_NODE_MEM_{USED,FREE}_BP, @nid represents the node 186 184 * id of the target node to account the used/free memory. 187 185 * 188 - * If @metric is DAMOS_QUOTA_NODE_MEMCG_USED_BP, @nid and @memcg_id represents 189 - * the node id and the cgroup to account the used memory for. 186 + * If @metric is DAMOS_QUOTA_NODE_MEMCG_{USED,FREE}_BP, @nid and @memcg_id 187 + * represents the node id and the cgroup to account the used memory for. 190 188 */ 191 189 struct damos_quota_goal { 192 190 enum damos_quota_goal_metric metric;
+8 -2
mm/damon/core.c
··· 790 790 dst->nid = src->nid; 791 791 break; 792 792 case DAMOS_QUOTA_NODE_MEMCG_USED_BP: 793 + case DAMOS_QUOTA_NODE_MEMCG_FREE_BP: 793 794 dst->nid = src->nid; 794 795 dst->memcg_id = src->memcg_id; 795 796 break; ··· 2047 2046 { 2048 2047 struct mem_cgroup *memcg; 2049 2048 struct lruvec *lruvec; 2050 - unsigned long used_pages; 2049 + unsigned long used_pages, numerator; 2051 2050 struct sysinfo i; 2052 2051 2053 2052 rcu_read_lock(); ··· 2067 2066 used_pages += lruvec_page_state(lruvec, NR_INACTIVE_FILE); 2068 2067 2069 2068 si_meminfo_node(&i, goal->nid); 2070 - return used_pages * 10000 / i.totalram; 2069 + if (goal->metric == DAMOS_QUOTA_NODE_MEMCG_USED_BP) 2070 + numerator = used_pages; 2071 + else /* DAMOS_QUOTA_NODE_MEMCG_FREE_BP */ 2072 + numerator = i.totalram - used_pages; 2073 + return numerator * 10000 / i.totalram; 2071 2074 } 2072 2075 #else 2073 2076 static __kernel_ulong_t damos_get_node_mem_bp( ··· 2106 2101 goal->current_value = damos_get_node_mem_bp(goal); 2107 2102 break; 2108 2103 case DAMOS_QUOTA_NODE_MEMCG_USED_BP: 2104 + case DAMOS_QUOTA_NODE_MEMCG_FREE_BP: 2109 2105 goal->current_value = damos_get_node_memcg_used_bp(goal); 2110 2106 break; 2111 2107 default: