* [PATCH] mm: memcontrol: add VM_BUG_ON_FOLIO() to catch lru folio in mem_cgroup_migrate()
@ 2024-06-14 1:07 Baolin Wang
2024-06-14 15:03 ` Shakeel Butt
0 siblings, 1 reply; 2+ messages in thread
From: Baolin Wang @ 2024-06-14 1:07 UTC (permalink / raw)
To: akpm
Cc: mhocko, roman.gushchin, shakeel.butt, muchun.song, hannes,
baolin.wang, linux-mm, linux-kernel
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@linux.dev>
Signed-off-by: Baolin Wang <baolin.wang@linux.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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm: memcontrol: add VM_BUG_ON_FOLIO() to catch lru folio in mem_cgroup_migrate()
2024-06-14 1:07 [PATCH] mm: memcontrol: add VM_BUG_ON_FOLIO() to catch lru folio in mem_cgroup_migrate() Baolin Wang
@ 2024-06-14 15:03 ` Shakeel Butt
0 siblings, 0 replies; 2+ messages in thread
From: Shakeel Butt @ 2024-06-14 15:03 UTC (permalink / raw)
To: Baolin Wang
Cc: akpm, mhocko, roman.gushchin, muchun.song, hannes, linux-mm,
linux-kernel
On Fri, Jun 14, 2024 at 09:07:42AM GMT, Baolin Wang wrote:
> 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@linux.dev>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-14 15:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14 1:07 [PATCH] mm: memcontrol: add VM_BUG_ON_FOLIO() to catch lru folio in mem_cgroup_migrate() Baolin Wang
2024-06-14 15:03 ` Shakeel Butt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox