From: Alistair Popple <alistair@popple.id.au>
To: Peter Xu <peterx@redhat.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Andrew Morton" <akpm@linux-foundation.org>,
"Jérôme Glisse" <jglisse@redhat.com>,
"John Hubbard" <jhubbard@nvidia.com>,
"Ralph Campbell" <rcampbell@nvidia.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/2] mm/rmap: Fixup copying of soft dirty and uffd ptes
Date: Tue, 25 Aug 2020 15:19:50 +1000 [thread overview]
Message-ID: <1650521.I2r5EI4MMx@cleo> (raw)
In-Reply-To: <20200824154359.GA8605@xz-x1>
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,
next prev parent reply other threads:[~2020-08-25 5:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 8:31 [PATCH 1/2] mm/migrate: Fixup setting UFFD_WP flag Alistair Popple
2020-08-24 8:31 ` [PATCH 2/2] mm/rmap: Fixup copying of soft dirty and uffd ptes Alistair Popple
2020-08-24 15:43 ` Peter Xu
2020-08-25 5:19 ` Alistair Popple [this message]
2020-08-24 15:44 ` [PATCH 1/2] mm/migrate: Fixup setting UFFD_WP flag Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1650521.I2r5EI4MMx@cleo \
--to=alistair@popple.id.au \
--cc=akpm@linux-foundation.org \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=rcampbell@nvidia.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.