linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: vmscan: always allow writeback during memcg reclaim
@ 2025-12-13  8:36 Deepanshu Kartikey
  2025-12-14 23:49 ` Andrew Morton
  2025-12-15  4:12 ` Johannes Weiner
  0 siblings, 2 replies; 20+ messages in thread
From: Deepanshu Kartikey @ 2025-12-13  8:36 UTC (permalink / raw)
  To: akpm, axelrasmussen, yuanchu, weixugc, hannes, david, mhocko,
	zhengqi.arch, shakeel.butt, lorenzo.stoakes, yuzhao, heftig,
	oleksandr, bgeffon
  Cc: linux-mm, linux-kernel, Deepanshu Kartikey, syzbot+90fcab4d88cffed6d0d8

When laptop_mode is enabled, may_writepage is set to 0 in
try_to_free_mem_cgroup_pages(). This triggers a warning in MGLRU's
lru_gen_shrink_lruvec():

    VM_WARN_ON_ONCE(!sc->may_writepage || !sc->may_unmap);

The warning occurs because MGLRU expects full reclaim capabilities to
function correctly. The call path is:

    mem_cgroup_resize_max()
      try_to_free_mem_cgroup_pages()
        do_try_to_free_pages()
          shrink_node()
            shrink_lruvec()
              lru_gen_shrink_lruvec()  <-- WARNING

Unlike kswapd or direct reclaim where laptop_mode's disk-saving behavior
is a reasonable optimization, memcg limit enforcement is a hard
requirement - memory MUST be freed when a cgroup exceeds its limit.
The may_unmap field is already set unconditionally to 1 in this path,
acknowledging that memcg reclaim needs full capabilities.

Set may_writepage unconditionally to 1 for memcg reclaim to ensure
MGLRU works correctly and memory limits are properly enforced.

Fixes: bd74fdaea146 ("mm: multi-gen LRU: support page table walks")
Reported-by: syzbot+90fcab4d88cffed6d0d8@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=90fcab4d88cffed6d0d8
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>

---
Note: Only compile-tested. No reproducer available from syzbot.
---
 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 900c74b6aa62..5e1c99d9cbd7 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -6669,7 +6669,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,
 		.reclaim_idx = MAX_NR_ZONES - 1,
 		.target_mem_cgroup = memcg,
 		.priority = DEF_PRIORITY,
-		.may_writepage = !laptop_mode,
+		.may_writepage = 1,
 		.may_unmap = 1,
 		.may_swap = !!(reclaim_options & MEMCG_RECLAIM_MAY_SWAP),
 		.proactive = !!(reclaim_options & MEMCG_RECLAIM_PROACTIVE),
-- 
2.43.0



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2025-12-19  5:14 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-13  8:36 [PATCH] mm: vmscan: always allow writeback during memcg reclaim Deepanshu Kartikey
2025-12-14 23:49 ` Andrew Morton
2025-12-15  4:12 ` Johannes Weiner
2025-12-15  4:51   ` Deepanshu Kartikey
2025-12-15 19:42     ` Yuanchu Xie
2025-12-15 20:22       ` Johannes Weiner
2025-12-19  5:13       ` Kairui Song
2025-12-15  6:59   ` retiring laptop_mode? was " Christoph Hellwig
2025-12-15 16:33     ` Jens Axboe
2025-12-15 20:08     ` Johannes Weiner
2025-12-16  2:23       ` Jens Axboe
2025-12-16  7:41       ` Christoph Hellwig
2025-12-16 18:52         ` Johannes Weiner
2025-12-16 18:54           ` Jens Axboe
2025-12-16 23:23           ` Shakeel Butt
2025-12-17 19:59             ` Johannes Weiner
2025-12-18  7:21               ` Shakeel Butt
2025-12-17 19:34           ` Michal Hocko
2025-12-18  6:00           ` Christoph Hellwig
2025-12-15 17:49   ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox