Re: [PATCH v3 4/7] mm: list_lru: deduplicate lock_list_lru()

From: Lorenzo Stoakes (Oracle)

Date: Tue Mar 24 2026 - 07:43:38 EST


On Wed, Mar 18, 2026 at 03:53:22PM -0400, Johannes Weiner wrote:
> The MEMCG and !MEMCG paths have the same pattern. Share the code.
>
> Reviewed-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>

I like the symmetry also here :) LGTM, so:

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@xxxxxxxxxx>

> ---
> 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 1a39ff490643..4d74c2e9c2a5 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.53.0
>