[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <66d181c41b7ced35dbd39ffd3f5774a11aef266a.1718327124.git.baolin.wang@linux.alibaba.com>
Date: Fri, 14 Jun 2024 09:07:42 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: akpm@...ux-foundation.org
Cc: mhocko@...nel.org,
roman.gushchin@...ux.dev,
shakeel.butt@...ux.dev,
muchun.song@...ux.dev,
hannes@...xchg.org,
baolin.wang@...ux.alibaba.com,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] mm: memcontrol: add VM_BUG_ON_FOLIO() to catch lru folio in mem_cgroup_migrate()
The mem_cgroup_migrate() will clear the memcg data of the old folio,
therefore, the callers must make sure the old folio is no longer on
the LRU list, otherwise the old folio can not get the correct lruvec
object without the memcg data, which could lead to potential problems [1].
Thus adding a VM_BUG_ON_FOLIO() to catch this issue.
[1] https://lore.kernel.org/all/5ab860d8ee987955e917748f9d6da525d3b52690.1718326003.git.baolin.wang@linux.alibaba.com/
Suggested-by: Shakeel Butt <shakeel.butt@...ux.dev>
Signed-off-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
---
mm/memcontrol.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4d9fda1d84a0..62fa3869065c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -7844,6 +7844,7 @@ void mem_cgroup_migrate(struct folio *old, struct folio *new)
VM_BUG_ON_FOLIO(!folio_test_locked(new), new);
VM_BUG_ON_FOLIO(folio_test_anon(old) != folio_test_anon(new), new);
VM_BUG_ON_FOLIO(folio_nr_pages(old) != folio_nr_pages(new), new);
+ VM_BUG_ON_FOLIO(folio_test_lru(old), old);
if (mem_cgroup_disabled())
return;
--
2.39.3
Powered by blists - more mailing lists