[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1650521.I2r5EI4MMx@cleo>
Date: Tue, 25 Aug 2020 15:19:50 +1000
From: Alistair Popple <alistair@...ple.id.au>
To: Peter Xu <peterx@...hat.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Jérôme Glisse <jglisse@...hat.com>,
John Hubbard <jhubbard@...dia.com>,
Ralph Campbell <rcampbell@...dia.com>, stable@...r.kernel.org
Subject: Re: [PATCH 2/2] mm/rmap: Fixup copying of soft dirty and uffd ptes
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,
Powered by blists - more mailing lists