Message ID | 20201125142858.2559-1-zqiu2000@126.com |
---|---|
State | Superseded |
Headers | show |
Series | [RT] mm/swap: use local lock in deactivate_page() | expand |
On 2020/11/27 上午12:35, Sebastian Andrzej Siewior wrote: > On 2020-11-25 22:28:58 [+0800], zqiu2000@126.com wrote: >> From: Zanxiong Qiu <zqiu2000@126.com> >> >> 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> > My bad, will correct the commit msg and resend, thanks. >> Signed-off-by: Zanxiong Qiu <zqiu2000@126.com> >> --- >> 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 >
On 2020-11-27 19:31:47 [+0800], Zanxiong Qiu wrote:
> My bad, will correct the commit msg and resend, thanks.
Okay, thanks. Please also omit the stack trace from the commit message
as it does not add any additional value. The error is quite obvious if
you look at it.
Sebastian
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); } }