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: use cgroup ID instead of private memcg ID

DAMON was using the internal private memcg ID which is meant for tracking
kernel objects that outlive their cgroup. Switch to using the public
cgroup ID instead.

Link: https://lkml.kernel.org/r/20251225232116.294540-6-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: SeongJae Park <sj@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Shakeel Butt and committed by
Andrew Morton
5866891a ea73e364

+9 -12
+2 -2
include/linux/damon.h
··· 203 203 u64 last_psi_total; 204 204 struct { 205 205 int nid; 206 - unsigned short memcg_id; 206 + u64 memcg_id; 207 207 }; 208 208 }; 209 209 struct list_head list; ··· 419 419 bool matching; 420 420 bool allow; 421 421 union { 422 - unsigned short memcg_id; 422 + u64 memcg_id; 423 423 struct damon_addr_range addr_range; 424 424 int target_idx; 425 425 struct damon_size_range sz_range;
+2 -5
mm/damon/core.c
··· 2094 2094 unsigned long used_pages, numerator; 2095 2095 struct sysinfo i; 2096 2096 2097 - rcu_read_lock(); 2098 - memcg = mem_cgroup_from_id(goal->memcg_id); 2099 - if (!memcg || !mem_cgroup_tryget(memcg)) { 2100 - rcu_read_unlock(); 2097 + memcg = mem_cgroup_get_from_ino(goal->memcg_id); 2098 + if (!memcg) { 2101 2099 if (goal->metric == DAMOS_QUOTA_NODE_MEMCG_USED_BP) 2102 2100 return 0; 2103 2101 else /* DAMOS_QUOTA_NODE_MEMCG_FREE_BP */ 2104 2102 return 10000; 2105 2103 } 2106 - rcu_read_unlock(); 2107 2104 2108 2105 mem_cgroup_flush_stats(memcg); 2109 2106 lruvec = mem_cgroup_lruvec(memcg, NODE_DATA(goal->nid));
+1 -1
mm/damon/ops-common.c
··· 274 274 if (!memcg) 275 275 matched = false; 276 276 else 277 - matched = filter->memcg_id == mem_cgroup_id(memcg); 277 + matched = filter->memcg_id == mem_cgroup_ino(memcg); 278 278 rcu_read_unlock(); 279 279 break; 280 280 case DAMOS_FILTER_TYPE_YOUNG:
+4 -4
mm/damon/sysfs-schemes.c
··· 2494 2494 return false; 2495 2495 } 2496 2496 2497 - static int damon_sysfs_memcg_path_to_id(char *memcg_path, unsigned short *id) 2497 + static int damon_sysfs_memcg_path_to_id(char *memcg_path, u64 *id) 2498 2498 { 2499 2499 struct mem_cgroup *memcg; 2500 2500 char *path; ··· 2509 2509 2510 2510 for (memcg = mem_cgroup_iter(NULL, NULL, NULL); memcg; 2511 2511 memcg = mem_cgroup_iter(NULL, memcg, NULL)) { 2512 - /* skip removed memcg */ 2513 - if (!mem_cgroup_id(memcg)) 2512 + /* skip offlined memcg */ 2513 + if (!mem_cgroup_online(memcg)) 2514 2514 continue; 2515 2515 if (damon_sysfs_memcg_path_eq(memcg, path, memcg_path)) { 2516 - *id = mem_cgroup_id(memcg); 2516 + *id = mem_cgroup_ino(memcg); 2517 2517 found = true; 2518 2518 break; 2519 2519 }