On Tuesday, 25 August 2020 1:43:59 AM AEST Peter Xu wrote: > > --- a/mm/migrate.c > > +++ b/mm/migrate.c > > @@ -2427,9 +2427,11 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, > > > > entry = make_migration_entry(page, mpfn & > > > > MIGRATE_PFN_WRITE); > > > > swp_pte = swp_entry_to_pte(entry); > > > > - if (pte_soft_dirty(pte)) > > + if ((is_swap_pte(pte) && pte_swp_soft_dirty(pte)) > > + || (!is_swap_pte(pte) && pte_soft_dirty(pte))) > > > > swp_pte = pte_swp_mksoft_dirty(swp_pte); > > > > - if (pte_uffd_wp(pte)) > > + if ((is_swap_pte(pte) && pte_swp_uffd_wp(pte)) > > + || (!is_swap_pte(pte) && pte_uffd_wp(pte))) > > > > swp_pte = pte_swp_mkuffd_wp(swp_pte); > > > > set_pte_at(mm, addr, ptep, swp_pte); > > The worst case is we'll call is_swap_pte() four times for each entry. Also > considering we know it's not a pte_none() when reach here, how about: > > if (pte_present(pte)) { > // pte handling of both soft dirty and uffd-wp > } else { > // swap handling of both soft dirty and uffd-wp > } > > ? Works for me, I'd missed we knew it was not a pte_none() so will respin. Thanks! - Alistair > Thanks,