Re: [PATCH 3/5] mm: Attempt to migrate page in lieu of discard
From: Keith Busch
Date: Fri Mar 22 2019 - 12:33:42 EST
On Thu, Mar 21, 2019 at 04:58:16PM -0700, Yang Shi wrote:
> On Thu, Mar 21, 2019 at 1:03 PM Keith Busch <keith.busch@xxxxxxxxx> wrote:
> > + if (!PageCompound(page)) {
> > + if (migrate_demote_mapping(page)) {
> > + unlock_page(page);
> > + if (likely(put_page_testzero(page)))
> > + goto free_it;
> > +
> > + /*
> > + * Speculative reference will free this page,
> > + * so leave it off the LRU.
> > + */
> > + nr_reclaimed++;
> > + continue;
> > + }
> > + }
>
> It looks the reclaim path would fall through if the migration is
> failed. But, it looks, with patch #4, you may end up trying reclaim an
> anon page on swapless system if migration is failed?
Right, and add_to_swap() will fail and the page jumps to activate_locked
label, placing it back where it was before.
> And, actually I have the same question with Yan Zi. Why not just put
> the demote candidate into a separate list, then migrate all the
> candidates in bulk with migrate_pages()?
The page is already locked at the point we know we want to migrate it.