On Wed, Oct 02, 2024 at 02:25:34PM +0300, Dan Carpenter wrote:
On Wed, Oct 02, 2024 at 02:24:20PM +0300, Dan Carpenter wrote:
Let's add Kairui Song to the CC list.
One simple thing is that we should add a READ_ONCE() to the comparison. Naresh, could you test the attached diff? I don't know that it will fix it but it's worth checking the easy stuff first.
Actually that's not right. Let me write a different patch.
Try this one.
regards, dan carpenter
diff --git a/mm/list_lru.c b/mm/list_lru.c index 79c2d21504a2..2c429578ed31 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -65,6 +65,7 @@ lock_list_lru_of_memcg(struct list_lru *lru, int nid, struct mem_cgroup *memcg, bool irq, bool skip_empty) { struct list_lru_one *l; + long nr_items; rcu_read_lock(); again: l = list_lru_from_memcg_idx(lru, nid, memcg_kmem_id(memcg)); @@ -73,8 +74,9 @@ lock_list_lru_of_memcg(struct list_lru *lru, int nid, struct mem_cgroup *memcg, spin_lock_irq(&l->lock); else spin_lock(&l->lock); - if (likely(READ_ONCE(l->nr_items) != LONG_MIN)) { - WARN_ON(l->nr_items < 0); + nr_items = READ_ONCE(l->nr_items); + if (likely(nr_items != LONG_MIN)) { + WARN_ON(nr_items < 0); rcu_read_unlock(); return l; }