Re: [PATCH 4/4] mm: migrate: Batch TLB flushing when unmapping pages for migration
From: Mel Gorman
Date: Thu Apr 16 2015 - 15:35:12 EST
On Thu, Apr 16, 2015 at 11:57:15AM -0700, Hugh Dickins wrote:
> > @@ -1098,6 +1098,8 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
> > if (!swapwrite)
> > current->flags |= PF_SWAPWRITE;
> >
> > + alloc_tlb_ubc();
> > +
> > for(pass = 0; pass < 10 && retry; pass++) {
> > retry = 0;
> >
> > @@ -1144,6 +1146,8 @@ out:
> > if (!swapwrite)
> > current->flags &= ~PF_SWAPWRITE;
> >
> > + try_to_unmap_flush();
>
> This is the right place to aim to flush, but I think you have to make
> more changes before it is safe to do so here.
>
> The putback_lru_page(page) in unmap_and_move() is commented "A page
> that has been migrated has all references removed and will be freed".
>
> If you leave TLB flushing until after the page has been freed, then
> there's a risk that userspace will see, not the data it expects at
> whatever virtual address, but data placed in there by the next user
> of this freed page.
>
> So you'll need to do a little restructuring first.
>
Well spotted. I believe you are correct and it almost certainly applies to
patch 2 as well for similar reasons. It also impacts the maximum reasonable
batch size that can be managed while maintaing safety. I'll do the necessary
shuffling tomorrow or Monday.
--
Mel Gorman
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/