Hi Peter On Fri, 10 Apr 2020 11:32:34 -0400 Peter Xu wrote: > > I'm not sure this is correct. As I mentioned, the commit wanted to > apply the uffd-wp bit even for the swap entries so that even the swap > entries got swapped in, the page will still be write protected. So > IIUC think we can't remove that. > Thank you for explaining that we would flip-flop uffd-wp in f45ec5ff16. The input to test robot now looks like the diff below after restoring CONFIG_MIGRATION. --- b/mm/mprotect.c +++ c/mm/mprotect.c @@ -139,9 +139,9 @@ static unsigned long change_pte_range(st } ptep_modify_prot_commit(vma, addr, pte, oldpte, ptent); pages++; - } else if (is_swap_pte(oldpte)) { + } else if (IS_ENABLED(CONFIG_MIGRATION)) { swp_entry_t entry = pte_to_swp_entry(oldpte); - pte_t newpte; + pte_t newpte = oldpte; if (is_write_migration_entry(entry)) { /* @@ -154,7 +154,9 @@ static unsigned long change_pte_range(st newpte = pte_swp_mksoft_dirty(newpte); if (pte_swp_uffd_wp(oldpte)) newpte = pte_swp_mkuffd_wp(newpte); - } else if (is_write_device_private_entry(entry)) { + } + + if (is_write_device_private_entry(entry)) { /* * We do not preserve soft-dirtiness. See * copy_one_pte() for explanation. @@ -163,8 +165,6 @@ static unsigned long change_pte_range(st newpte = swp_entry_to_pte(entry); if (pte_swp_uffd_wp(oldpte)) newpte = pte_swp_mkuffd_wp(newpte); - } else { - newpte = oldpte; } if (uffd_wp)