From: Pasha Tatashin <pasha.tatashin@soleen.com>
To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, linux-doc@vger.kernel.org,
akpm@linux-foundation.org, rientjes@google.com, pjt@google.com,
weixugc@google.com, gthelen@google.com, mingo@redhat.com,
corbet@lwn.net, will@kernel.org, rppt@kernel.org,
keescook@chromium.org, tglx@linutronix.de, peterz@infradead.org,
masahiroy@kernel.org, samitolvanen@google.com,
dave.hansen@linux.intel.com, x86@kernel.org, frederic@kernel.org,
hpa@zytor.com, aneesh.kumar@linux.ibm.com, jirislaby@kernel.org,
songmuchun@bytedance.com, qydwhotmail@gmail.com
Subject: [PATCH v2 1/4] mm: change page type prior to adding page table entry
Date: Sat, 4 Dec 2021 18:23:11 +0000 [thread overview]
Message-ID: <20211204182314.1470076-2-pasha.tatashin@soleen.com> (raw)
In-Reply-To: <20211204182314.1470076-1-pasha.tatashin@soleen.com>
In do_swap_page() we first insert the entry into user page table, and
later change the struct page to indicate that this is anonymous page.
In all other places we first configure the page metadata and then insert
entries into the page table.
While odd, the behaviour is benign. Page table check, however, will use
the information from struct page to verify the type of entry is
inserted.
Change the order in do_swap_page() to first update struct page, and later
insert pte entry into the page table.
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
---
mm/memory.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index ced3274c3deb..9eef54950910 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3635,9 +3635,6 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
pte = pte_mkuffd_wp(pte);
pte = pte_wrprotect(pte);
}
- set_pte_at(vma->vm_mm, vmf->address, vmf->pte, pte);
- arch_do_swap_page(vma->vm_mm, vma, vmf->address, pte, vmf->orig_pte);
- vmf->orig_pte = pte;
/* ksm created a completely new copy */
if (unlikely(page != swapcache && swapcache)) {
@@ -3647,6 +3644,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
do_page_add_anon_rmap(page, vma, vmf->address, exclusive);
}
+ set_pte_at(vma->vm_mm, vmf->address, vmf->pte, pte);
+ arch_do_swap_page(vma->vm_mm, vma, vmf->address, pte, vmf->orig_pte);
+ vmf->orig_pte = pte;
+
swap_free(entry);
if (mem_cgroup_swap_full(page) ||
(vma->vm_flags & VM_LOCKED) || PageMlocked(page))
--
2.34.1.400.ga245620fadb-goog
next prev parent reply other threads:[~2021-12-04 18:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-04 18:23 [PATCH v2 0/4] page table check Pasha Tatashin
2021-12-04 18:23 ` Pasha Tatashin [this message]
2021-12-04 18:23 ` [PATCH v2 2/4] mm: ptep_clear() page table helper Pasha Tatashin
2021-12-04 18:23 ` [PATCH v2 3/4] mm: page table check Pasha Tatashin
2021-12-08 0:05 ` Andrew Morton
2021-12-08 17:35 ` Pasha Tatashin
2021-12-04 18:23 ` [PATCH v2 4/4] x86: mm: add x86_64 support for " Pasha Tatashin
2021-12-21 13:09 ` [PATCH v2 0/4] " Fusion Future
2021-12-21 14:48 ` Pasha Tatashin
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=20211204182314.1470076-2-pasha.tatashin@soleen.com \
--to=pasha.tatashin@soleen.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=frederic@kernel.org \
--cc=gthelen@google.com \
--cc=hpa@zytor.com \
--cc=jirislaby@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=masahiroy@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=qydwhotmail@gmail.com \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=samitolvanen@google.com \
--cc=songmuchun@bytedance.com \
--cc=tglx@linutronix.de \
--cc=weixugc@google.com \
--cc=will@kernel.org \
--cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).