Skip to content

Commit 8bb0a9f

Browse files
Harry Yoojfvogel
authored andcommitted
mm: multi-gen LRU: fix two warnings in evict_folios()
evict_folios() does not take lruvec lock before calling reset_batch_size(), leading to a warning: WARNING: CPU: 19 PID: 235 at include/linux/mm_inline.h:44 reset_batch_size+0x1aa/0x1f0 [...] Call Trace: <TASK> ? evict_folios+0x25e/0x8c0 evict_folios+0x83e/0x8c0 try_to_shrink_lruvec+0x195/0x2c0 shrink_one+0x107/0x1c0 shrink_many+0x1e6/0x900 ? shrink_many+0x73/0x900 shrink_node+0x3e3/0x440 ? balance_pgdat+0xdb/0x7d0 balance_pgdat+0x2d7/0x7d0 kswapd+0x114/0x1e0 ? __pfx_kswapd+0x10/0x10 kthread+0xd6/0x110 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x34/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Fix this by taking the lock. Also, both reset_batch_size() and __mod_lruvec_state() should be called with irq disabled. Not disabling irq causes another warning: WARNING: CPU: 19 PID: 235 at mm/vmstat.c:393 __mod_node_page_state+0x84/0xd0 [...] Call Trace: <TASK> __mod_lruvec_state+0x26/0x50 evict_folios+0x65a/0x8c0 try_to_shrink_lruvec+0x195/0x2c0 shrink_one+0x107/0x1c0 shrink_many+0x1e6/0x900 ? shrink_many+0x73/0x900 shrink_node+0x3e3/0x440 ? balance_pgdat+0xdb/0x7d0 balance_pgdat+0x2d7/0x7d0 kswapd+0x114/0x1e0 ? __pfx_kswapd+0x10/0x10 kthread+0xd6/0x110 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x34/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Disable IRQ before reset_batch_size() and __mod_lruvec_state(). These two issues appear to be a mistake in commit d6530a1 ("mm: vmscan: rework move_pages_to_lru()"). The latest version [1] of Muchun's lruvec reparenting series handles this correctly. Orabug: 37997618 Link: https://lore.kernel.org/linux-mm/[email protected] [1] Fixes: d6530a1 ("mm: vmscan: rework move_pages_to_lru()") Reviewed-by: Sidhartha Kumar <[email protected]> Reviewed-by: Imran Khan <[email protected]> Signed-off-by: Harry Yoo <[email protected]>
1 parent bda4f88 commit 8bb0a9f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mm/vmscan.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4641,16 +4641,18 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
46414641

46424642
move_folios_to_lru(&list);
46434643

4644+
local_irq_disable();
46444645
walk = current->reclaim_state->mm_walk;
46454646
if (walk && walk->batched) {
46464647
walk->lruvec = lruvec;
4648+
spin_lock(&lruvec->lru_lock);
46474649
reset_batch_size(walk);
4650+
spin_unlock(&lruvec->lru_lock);
46484651
}
46494652

46504653
__mod_lruvec_state(lruvec, PGDEMOTE_KSWAPD + reclaimer_offset(),
46514654
stat.nr_demoted);
46524655

4653-
local_irq_disable();
46544656
item = PGSTEAL_KSWAPD + reclaimer_offset();
46554657
if (!cgroup_reclaim(sc))
46564658
__count_vm_events(item, reclaimed);

0 commit comments

Comments
 (0)