Re: [PATCH RT] mm/swap: use local lock in deactivate_page()
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: 2020-11-26 16:36:12
On 2020-11-25 22:28:58 [+0800], zqiu2000@126.com wrote:
From: Zanxiong Qiu <redacted> 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.
…
2154a0abcc9 ("mm: Revert the DEFINE_PER_CPU_PAGEVEC implementation")
reverted the lock/unlock_swap_pvec function, however, get_cpu_var()
was added back in deactivate_page(), actually, get_locked_var()
shall be used instead to avoid preempt_disable() call for RT.
The commit is
32154a0abcc97 ("mm: Revert the DEFINE_PER_CPU_PAGEVEC implementation")
the reasoning is correct. deactivate_page() was added in v5.4 and I
missed that part when I added back the old patches which did not handle
it :/
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
quoted hunk ↗ jump to hunk
Signed-off-by: Zanxiong Qiu <redacted> --- mm/swap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)diff --git a/mm/swap.c b/mm/swap.c index cdb4f1fa3a48..463cac334fcf 100644 --- a/mm/swap.c +++ b/mm/swap.c@@ -666,12 +666,13 @@ void deactivate_file_page(struct page *page) void deactivate_page(struct page *page) { if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) { - 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); } }
Sebastian