From: Hillf Danton <hdanton@sina.com>
To: Peter Xu <peterx@redhat.com>
Cc: Hillf Danton <hdanton@sina.com>, mm <linux-mm@kvack.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: f45ec5ff16 ("userfaultfd: wp: support swap and page migration"): [ 140.777858] BUG: Bad rss-counter state mm:b278fc66 type:MM_ANONPAGES val:1
Date: Sun, 12 Apr 2020 20:54:08 +0800 [thread overview]
Message-ID: <20200412125408.18008-1-hdanton@sina.com> (raw)
In-Reply-To: <20200410073209.11164-1-hdanton@sina.com>
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.
Yes you are right.
Now both CONFIG_MIGRATION and swap entry are restored after making uffd_wq
survive migrate the same way as soft_dirty.
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -236,6 +236,8 @@ static bool remove_migration_pte(struct
pte = pte_mkold(mk_pte(new, READ_ONCE(vma->vm_page_prot)));
if (pte_swp_soft_dirty(*pvmw.pte))
pte = pte_mksoft_dirty(pte);
+ if (pte_swp_uffd_wp(*pvmw.pte))
+ pte = pte_mkuffd_wp(pte);
/*
* Recheck VMA as permissions can change since migration started
@@ -243,15 +245,11 @@ static bool remove_migration_pte(struct
entry = pte_to_swp_entry(*pvmw.pte);
if (is_write_migration_entry(entry))
pte = maybe_mkwrite(pte, vma);
- else if (pte_swp_uffd_wp(*pvmw.pte))
- pte = pte_mkuffd_wp(pte);
if (unlikely(is_zone_device_page(new))) {
if (is_device_private_page(new)) {
entry = make_device_private_entry(new, pte_write(pte));
pte = swp_entry_to_pte(entry);
- if (pte_swp_uffd_wp(*pvmw.pte))
- pte = pte_mkuffd_wp(pte);
}
}
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -139,11 +139,13 @@ 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;
- if (is_write_migration_entry(entry)) {
+ if (!non_swap_entry(entry)) {
+ newpte = oldpte;
+ } else if (is_write_migration_entry(entry)) {
/*
* A protection check is difficult so
* just be safe and disable write
@@ -164,7 +166,7 @@ static unsigned long change_pte_range(st
if (pte_swp_uffd_wp(oldpte))
newpte = pte_swp_mkuffd_wp(newpte);
} else {
- newpte = oldpte;
+ continue;
}
if (uffd_wp)
next prev parent reply other threads:[~2020-04-12 12:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-10 0:25 kernel test robot
2020-04-10 7:32 ` Hillf Danton
2020-04-10 15:32 ` Peter Xu
2020-04-10 15:38 ` Matthew Wilcox
2020-04-10 18:14 ` Peter Xu
2020-04-11 1:21 ` f45ec5ff16 ("userfaultfd: wp: support swap and page migration"): BUG: Bad rss-counter state Hillf Danton
2020-04-12 12:54 ` Hillf Danton [this message]
2020-04-12 21:45 ` f45ec5ff16 ("userfaultfd: wp: support swap and page migration"): [ 140.777858] BUG: Bad rss-counter state mm:b278fc66 type:MM_ANONPAGES val:1 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=20200412125408.18008-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox