Re: [PATCH] mm, migrate: Check return value of try_to_unmap()

From: Huang\, Ying
Date: Tue Mar 03 2020 - 01:19:24 EST


Hi, Hugh,

Hugh Dickins <hughd@xxxxxxxxxx> writes:
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index 3900044cfaa6..981f8374a6ef 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -1116,8 +1116,11 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
>> /* Establish migration ptes */
>> VM_BUG_ON_PAGE(PageAnon(page) && !PageKsm(page) && !anon_vma,
>> page);
>> - try_to_unmap(page,
>> - TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);
>> + if (!try_to_unmap(page,
>> + TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS)) {
>> + rc = -EIO;
>> + goto out_unlock_both;
>
> No: even if try_to_unmap() says that it did not entirely succeed,
> it may have unmapped some ptes, inserting migration entries in their
> place. Those need to be replaced by proper ptes before the page is
> unlocked, which page_was_mapped 1 and remove_migration_ptes() do;
> but this goto skips those.

Yes. You are right. I misunderstand the original code. Please ignore
this patch.

Best Regards,
Huang, Ying