]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
memcg: mem_cgroup_get_from_ino() returns NULL on error
authorShakeel Butt <shakeel.butt@linux.dev>
Thu, 25 Dec 2025 23:21:11 +0000 (15:21 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 27 Jan 2026 04:02:24 +0000 (20:02 -0800)
Change mem_cgroup_get_from_ino() to return NULL on error instead of
ERR_PTR values.  This simplifies the API: NULL indicates failure, and a
valid pointer indicates success with a CSS reference held that the caller
must release via mem_cgroup_put().

Link: https://lkml.kernel.org/r/20251225232116.294540-4-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>
mm/memcontrol.c
mm/shrinker_debug.c

index e85816960e38dd1b21eb37e2ecf4e1954550ec87..92beb74482fae35cecd2341fa94710161aa0b216 100644 (file)
@@ -3624,17 +3624,15 @@ struct mem_cgroup *mem_cgroup_get_from_ino(unsigned long ino)
 {
        struct cgroup *cgrp;
        struct cgroup_subsys_state *css;
-       struct mem_cgroup *memcg;
+       struct mem_cgroup *memcg = NULL;
 
        cgrp = cgroup_get_from_id(ino);
        if (IS_ERR(cgrp))
-               return ERR_CAST(cgrp);
+               return NULL;
 
        css = cgroup_get_e_css(cgrp, &memory_cgrp_subsys);
        if (css)
                memcg = container_of(css, struct mem_cgroup, css);
-       else
-               memcg = ERR_PTR(-ENOENT);
 
        cgroup_put(cgrp);
 
index 20eaee3e97f7a1bf118b8e2facc8e99d6b002e18..8aaeb8f5c3af07a890fd2b8e13f8925e3cc2950a 100644 (file)
@@ -130,7 +130,7 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file,
 
        if (shrinker->flags & SHRINKER_MEMCG_AWARE) {
                memcg = mem_cgroup_get_from_ino(ino);
-               if (!memcg || IS_ERR(memcg))
+               if (!memcg)
                        return -ENOENT;
 
                if (!mem_cgroup_online(memcg)) {