]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm: list_lru: lock_list_lru_of_memcg() cannot return NULL if !skip_empty
authorJohannes Weiner <hannes@cmpxchg.org>
Wed, 27 May 2026 20:45:09 +0000 (16:45 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 9 Jun 2026 01:21:23 +0000 (18:21 -0700)
skip_empty is only for the shrinker to abort and skip a list that's empty
or whose cgroup is being deleted.

For list additions and deletions, the cgroup hierarchy is walked upwards
until a valid list_lru head is found, or it will fall back to the node
list.  Acquiring the lock won't fail.  Remove the NULL checks in those
callers.

Link: https://lore.kernel.org/20260527204757.2544958-3-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Liam R. Howlett (Oracle) <liam@infradead.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Kairui Song <ryncsn@gmail.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Nico Pache <npache@redhat.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/list_lru.c

index 45d1b97737eae559f3b91dd6b427f1cf96627f8d..77999ed78fa5ef6e8f30c497cb9651a0995a29b6 100644 (file)
@@ -165,8 +165,6 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item, int nid,
        struct list_lru_one *l;
 
        l = lock_list_lru_of_memcg(lru, nid, &memcg, false, false);
-       if (!l)
-               return false;
        if (list_empty(item)) {
                list_add_tail(item, &l->list);
                /*
@@ -208,9 +206,8 @@ bool list_lru_del(struct list_lru *lru, struct list_head *item, int nid,
 {
        struct list_lru_node *nlru = &lru->node[nid];
        struct list_lru_one *l;
+
        l = lock_list_lru_of_memcg(lru, nid, &memcg, false, false);
-       if (!l)
-               return false;
        if (!list_empty(item)) {
                list_del_init(item);
                l->nr_items--;