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.

memcg: use cgroup_id() instead of cgroup_ino() for memcg ID

Switch mem_cgroup_ino() from using cgroup_ino() to cgroup_id(). The
cgroup_ino() returns the kernfs inode number while cgroup_id() returns the
kernfs node ID. For 64-bit systems, they are the same. Also
cgroup_get_from_id() expects 64-bit node ID which is called by
mem_cgroup_get_from_ino().

Change the type from unsigned long to u64 to match cgroup_id()'s return
type, and update the format specifiers accordingly.

Note that the names mem_cgroup_ino() and mem_cgroup_get_from_ino() are now
misnomers since they deal with cgroup IDs rather than inode numbers. A
follow-up patch will rename them.

Link: https://lkml.kernel.org/r/20251225232116.294540-5-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
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: SeongJae Park <sj@kernel.org>
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
ea73e364 510e1290

+10 -9
+5 -5
include/linux/memcontrol.h
··· 836 836 } 837 837 struct mem_cgroup *mem_cgroup_from_id(unsigned short id); 838 838 839 - static inline unsigned long mem_cgroup_ino(struct mem_cgroup *memcg) 839 + static inline u64 mem_cgroup_ino(struct mem_cgroup *memcg) 840 840 { 841 - return memcg ? cgroup_ino(memcg->css.cgroup) : 0; 841 + return memcg ? cgroup_id(memcg->css.cgroup) : 0; 842 842 } 843 843 844 - struct mem_cgroup *mem_cgroup_get_from_ino(unsigned long ino); 844 + struct mem_cgroup *mem_cgroup_get_from_ino(u64 ino); 845 845 846 846 static inline struct mem_cgroup *mem_cgroup_from_seq(struct seq_file *m) 847 847 { ··· 1306 1306 return NULL; 1307 1307 } 1308 1308 1309 - static inline unsigned long mem_cgroup_ino(struct mem_cgroup *memcg) 1309 + static inline u64 mem_cgroup_ino(struct mem_cgroup *memcg) 1310 1310 { 1311 1311 return 0; 1312 1312 } 1313 1313 1314 - static inline struct mem_cgroup *mem_cgroup_get_from_ino(unsigned long ino) 1314 + static inline struct mem_cgroup *mem_cgroup_get_from_ino(u64 ino) 1315 1315 { 1316 1316 return NULL; 1317 1317 }
+1 -1
mm/memcontrol.c
··· 3620 3620 return mem_cgroup_from_private_id(id); 3621 3621 } 3622 3622 3623 - struct mem_cgroup *mem_cgroup_get_from_ino(unsigned long ino) 3623 + struct mem_cgroup *mem_cgroup_get_from_ino(u64 ino) 3624 3624 { 3625 3625 struct cgroup *cgrp; 3626 3626 struct cgroup_subsys_state *css;
+4 -3
mm/shrinker_debug.c
··· 70 70 memcg_aware ? memcg : NULL, 71 71 count_per_node); 72 72 if (total) { 73 - seq_printf(m, "%lu", mem_cgroup_ino(memcg)); 73 + seq_printf(m, "%llu", mem_cgroup_ino(memcg)); 74 74 for_each_node(nid) 75 75 seq_printf(m, " %lu", count_per_node[nid]); 76 76 seq_putc(m, '\n'); ··· 106 106 size_t size, loff_t *pos) 107 107 { 108 108 struct shrinker *shrinker = file->private_data; 109 - unsigned long nr_to_scan = 0, ino, read_len; 109 + unsigned long nr_to_scan = 0, read_len; 110 + u64 ino; 110 111 struct shrink_control sc = { 111 112 .gfp_mask = GFP_KERNEL, 112 113 }; ··· 120 119 return -EFAULT; 121 120 kbuf[read_len] = '\0'; 122 121 123 - if (sscanf(kbuf, "%lu %d %lu", &ino, &nid, &nr_to_scan) != 3) 122 + if (sscanf(kbuf, "%llu %d %lu", &ino, &nid, &nr_to_scan) != 3) 124 123 return -EINVAL; 125 124 126 125 if (nid < 0 || nid >= nr_node_ids)