Re: [PATCH] mm: mempolicy: handle vma with unmovable pages mapped correctly in mbind

From: Yang Shi
Date: Wed Jun 19 2019 - 12:26:20 EST

On 6/19/19 1:22 AM, Vlastimil Babka wrote:
On 6/19/19 7:21 AM, Michal Hocko wrote:
On Tue 18-06-19 14:13:16, Yang Shi wrote:
I used to have !__PageMovable(page), but it was removed since the
aforementioned reason. I could add it back.

For the temporary off LRU page, I did a quick search, it looks the most
paths have to acquire mmap_sem, so it can't race with us here. Page
reclaim/compaction looks like the only race. But, since the mapping should
be preserved even though the page is off LRU temporarily unless the page is
reclaimed, so we should be able to exclude temporary off LRU pages by
calling page_mapping() and page_anon_vma().

So, the fix may look like:

if (!PageLRU(head) && !__PageMovable(page)) {
ÂÂÂ if (!(page_mapping(page) || page_anon_vma(page)))
ÂÂÂ ÂÂÂ return -EIO;
This is getting even more muddy TBH. Is there any reason that we have to
handle this problem during the isolation phase rather the migration?
I think it was already said that if pages can't be isolated, then
migration phase won't process them, so they're just ignored.


However I think the patch is wrong to abort immediately when
encountering such page that cannot be isolated (AFAICS). IMHO it should
still try to migrate everything it can, and only then return -EIO.

It is fine too. I don't see mbind semantics define how to handle such case other than returning -EIO.