Re: [PATCH v4 4/8] mm: list_lru: deduplicate lock_list_lru()

From: Liam R . Howlett

Date: Thu May 21 2026 - 13:38:07 EST


On 26/05/21 11:02AM, Johannes Weiner wrote:
> The MEMCG and !MEMCG paths have the same pattern. Share the code.
>
> 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 | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/mm/list_lru.c b/mm/list_lru.c
> index 9da6fce19832..65962dbf6dda 100644
> --- a/mm/list_lru.c
> +++ b/mm/list_lru.c
> @@ -15,6 +15,14 @@
> #include "slab.h"
> #include "internal.h"
>
> +static inline void lock_list_lru(struct list_lru_one *l, bool irq)
> +{
> + if (irq)
> + spin_lock_irq(&l->lock);
> + else
> + spin_lock(&l->lock);
> +}
> +
> static inline void unlock_list_lru(struct list_lru_one *l, bool irq_off)
> {
> if (irq_off)
> @@ -68,14 +76,6 @@ list_lru_from_memcg_idx(struct list_lru *lru, int nid, int idx)
> return &lru->node[nid].lru;
> }
>
> -static inline void lock_list_lru(struct list_lru_one *l, bool irq)
> -{
> - if (irq)
> - spin_lock_irq(&l->lock);
> - else
> - spin_lock(&l->lock);
> -}
> -
> static inline struct list_lru_one *
> lock_list_lru_of_memcg(struct list_lru *lru, int nid, struct mem_cgroup *memcg,
> bool irq, bool skip_empty)
> @@ -136,10 +136,7 @@ lock_list_lru_of_memcg(struct list_lru *lru, int nid, struct mem_cgroup *memcg,
> {
> struct list_lru_one *l = &lru->node[nid].lru;
>
> - if (irq)
> - spin_lock_irq(&l->lock);
> - else
> - spin_lock(&l->lock);
> + lock_list_lru(l, irq);
>
> return l;
> }
> --
> 2.54.0
>