Skip to content

Commit e46f881

Browse files
Muchun Songjfvogel
authored andcommitted
mm: zswap: prevent lruvec release in zswap_folio_swapin()
In the near future, a folio will no longer pin its corresponding memory cgroup. So an lruvec returned by folio_lruvec() could be released without the rcu read lock or a reference to its memory cgroup. In the current patch, the rcu read lock is employed to safeguard against the release of the lruvec in zswap_folio_swapin(). This serves as a preparatory measure for the reparenting of the LRU pages. Signed-off-by: Muchun Song <[email protected]> Orabug: 37997580 This suppresses the warning: WARNING: CPU: 0 PID: 4240 at include/linux/memcontrol.h:407 zswap_folio_swapin+0x11b/0x160 [...] Call Trace: <TASK> swap_read_folio+0xec/0x2f0 swap_cluster_readahead+0x19e/0x310 do_swap_page+0x216/0x1200 ? srso_alias_return_thunk+0x5/0xfbef5 ? lock_acquire+0x107/0x140 ? __pte_offset_map+0x2a/0x2a0 ? srso_alias_return_thunk+0x5/0xfbef5 ? __pfx_default_wake_function+0x10/0x10 __handle_mm_fault+0x592/0x770 handle_mm_fault+0x104/0x3a0 do_user_addr_fault+0x22b/0x7b0 exc_page_fault+0x77/0x270 asm_exc_page_fault+0x26/0x30 </TASK> Link: https://lore.kernel.org/linux-mm/[email protected]/ Fixes: 4717687 ("mm: memcontrol: make all the callers of {folio,page}_memcg() safe") Reviewed-by: Imran Khan <[email protected]> Signed-off-by: Harry Yoo <[email protected]>
1 parent cafcea4 commit e46f881

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/zswap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,10 @@ void zswap_folio_swapin(struct folio *folio)
745745
struct lruvec *lruvec;
746746

747747
if (folio) {
748+
rcu_read_lock();
748749
lruvec = folio_lruvec(folio);
749750
atomic_long_inc(&lruvec->zswap_lruvec_state.nr_disk_swapins);
751+
rcu_read_unlock();
750752
}
751753
}
752754

0 commit comments

Comments
 (0)