Skip to content

Commit

Permalink
mm/swap: use local lock in deactivate_page()
Browse files Browse the repository at this point in the history
get_cpu_var() calls preempt_disable(), while on RT kernel,
pagevec_lru_move_fn() will call spinlock and might schedule
the context out and hence the schedule bug occurred, issue
is found on 5.4.70-rt40 and reproducable on 5.4.74-rt41.

32154a0abcc ("mm: Revert the DEFINE_PER_CPU_PAGEVEC implementation")
reverted the lock/unlock_swap_pvec function, however,
deactivate_page() part was missed at that time as it's newly
added in v5.4.

Link: https://lore.kernel.org/r/[email protected]
Acked-by: Sebastian Andrzej Siewior <[email protected]>
Signed-off-by: Zanxiong Qiu <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
Signed-off-by: Alexander Winkowski <[email protected]>
  • Loading branch information
zqiu2000 authored and dereference23 committed Jun 18, 2023
1 parent 5acd724 commit 2a03478
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mm/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,13 @@ void deactivate_file_page(struct page *page)
void deactivate_page(struct page *page)
{
if (PageLRU(page) && !PageUnevictable(page) && (PageActive(page) || lru_gen_enabled())) {
struct pagevec *pvec = &get_cpu_var(lru_deactivate_pvecs);
struct pagevec *pvec = &get_locked_var(swapvec_lock,
lru_deactivate_pvecs);

get_page(page);
if (!pagevec_add(pvec, page) || PageCompound(page))
pagevec_lru_move_fn(pvec, lru_deactivate_fn, NULL);
put_cpu_var(lru_deactivate_pvecs);
put_locked_var(swapvec_lock, lru_deactivate_pvecs);
}
}

Expand Down

0 comments on commit 2a03478

Please sign in to comment.