mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
mm: list_lru: deduplicate unlock_list_lru()
The MEMCG and !MEMCG variants are the same. lock_list_lru() has the same pattern when bailing. Consolidate into a common implementation. Link: https://lore.kernel.org/20260527204757.2544958-4-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>
This commit is contained in:
parent
1923b1d76b
commit
82d8bca1c7
|
|
@ -15,6 +15,14 @@
|
|||
#include "slab.h"
|
||||
#include "internal.h"
|
||||
|
||||
static inline void unlock_list_lru(struct list_lru_one *l, bool irq_off)
|
||||
{
|
||||
if (irq_off)
|
||||
spin_unlock_irq(&l->lock);
|
||||
else
|
||||
spin_unlock(&l->lock);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MEMCG
|
||||
static LIST_HEAD(memcg_list_lrus);
|
||||
static DEFINE_MUTEX(list_lrus_mutex);
|
||||
|
|
@ -67,10 +75,7 @@ static inline bool lock_list_lru(struct list_lru_one *l, bool irq)
|
|||
else
|
||||
spin_lock(&l->lock);
|
||||
if (unlikely(READ_ONCE(l->nr_items) == LONG_MIN)) {
|
||||
if (irq)
|
||||
spin_unlock_irq(&l->lock);
|
||||
else
|
||||
spin_unlock(&l->lock);
|
||||
unlock_list_lru(l, irq);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -101,14 +106,6 @@ lock_list_lru_of_memcg(struct list_lru *lru, int nid,
|
|||
*memcg = parent_mem_cgroup(*memcg);
|
||||
goto again;
|
||||
}
|
||||
|
||||
static inline void unlock_list_lru(struct list_lru_one *l, bool irq_off)
|
||||
{
|
||||
if (irq_off)
|
||||
spin_unlock_irq(&l->lock);
|
||||
else
|
||||
spin_unlock(&l->lock);
|
||||
}
|
||||
#else
|
||||
static void list_lru_register(struct list_lru *lru)
|
||||
{
|
||||
|
|
@ -147,14 +144,6 @@ lock_list_lru_of_memcg(struct list_lru *lru, int nid,
|
|||
|
||||
return l;
|
||||
}
|
||||
|
||||
static inline void unlock_list_lru(struct list_lru_one *l, bool irq_off)
|
||||
{
|
||||
if (irq_off)
|
||||
spin_unlock_irq(&l->lock);
|
||||
else
|
||||
spin_unlock(&l->lock);
|
||||
}
|
||||
#endif /* CONFIG_MEMCG */
|
||||
|
||||
/* The caller must ensure the memcg lifetime. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user