Re: [PATCH v4 1/8] mm: list_lru: lock_list_lru_of_memcg() cannot return NULL if !skip_empty

From: Liam R . Howlett

Date: Thu May 21 2026 - 13:19:59 EST


On 26/05/21 11:02AM, Johannes Weiner wrote:
> 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.
>
> Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@xxxxxxxxxx>
> Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>

Reviewed-by: Liam R. Howlett (Oracle) <liam@xxxxxxxxxxxxx>

> ---
> mm/list_lru.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/mm/list_lru.c b/mm/list_lru.c
> index dd29bcf8eb5f..d3619961a7ac 100644
> --- a/mm/list_lru.c
> +++ b/mm/list_lru.c
> @@ -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);
> /* Set shrinker bit if the first element was added */
> @@ -204,9 +202,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--;
> --
> 2.54.0
>