Re: [PATCH] mm: fix unevictable page reclaim when calling madvise_pageout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 31-10-19 07:48:11, Minchan Kim wrote:
> On Thu, Oct 31, 2019 at 10:16:01AM +0100, Michal Hocko wrote:
> > On Wed 30-10-19 15:33:07, Johannes Weiner wrote:
> > > On Wed, Oct 30, 2019 at 06:45:33PM +0100, Michal Hocko wrote:
> > > > On Wed 30-10-19 09:52:39, Minchan Kim wrote:
> > [...]
> > > > > madvise_pageout could work with a shared page and one of the vmas among processes
> > > > > could do mlock so it could pass Unevictable LRU pages into shrink_page_list.
> > > > > It's pointless to try reclaim unevictable pages from the beginning so I want to fix
> > > > > madvise_pageout via introducing only_evictable flag into the API so that
> > > > > madvise_pageout uses it as "true".
> > > > > 
> > > > > If we want to remove the PageUnevictable VM_BUG_ON_PAGE in shrink_page_list,
> > > > > I want to see more strong reason why it happens and why caller couldn't
> > > > > filter them out from the beginning.
> > > > 
> > > > Why is this preferable over removing the VM_BUG_ON condition? In other
> > > > words why should we keep PageUnevictable check there?
> > > 
> > > The mlock LRU shuffling is a bit tricky and can race with page reclaim
> > > or others isolating the page from the LRU list. If another isolator
> > > wins, it has to move the page during putback on behalf of mlock.
> > > 
> > > See the implementation and comments in __pagevec_lru_add_fn().
> > > 
> > > That's why page reclaim can see !page_evictable(), but it must not see
> > > pages that have the PageUnevictable lru bit already set. Because that
> > > would mean the isolation/putback machinery messed up somewhere and the
> > > page LRU state is corrupt.
> > > 
> > > As that machinery is non-trivial, it's useful to have that sanity
> > > check in page reclaim.
> > 
> > Thanks for the clarification! This sounds reasonable (as much as the
> > mlock juggling does) to me. This is probably worth a comment right above
> > the bug_on.
> > 
> > I have to confess that I am still not clear on all the details here,
> > though. E.g. migrate_misplaced_transhuge_page sets the flag without
> > lru_lock and relies only on page lock IIUC and the bug on is done right
> > after the lock is released. Maybe I am just confused or maybe the race
> > window is too small to matter but isn't this race possible at least
> > theoretically?
> 
> IIUC, reclaim couldn't see the page from LRU list because it was isolated by
> numamigrate_isolate_page.

Right you are. I have missed numamigrate_isolate_page. Thanks!

-- 
Michal Hocko
SUSE Labs




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux