From: "Thomas Hellström (VMware)" <thomas_os@shipmail.org>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
torvalds@linux-foundation.org, kirill@shutemov.name
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Subject: [RFC PATCH 4/4] mm: mapping_dirty_helpers: Handle huge pmds correctly
Date: Thu, 10 Oct 2019 15:40:58 +0200 [thread overview]
Message-ID: <20191010134058.11949-5-thomas_os@shipmail.org> (raw)
In-Reply-To: <20191010134058.11949-1-thomas_os@shipmail.org>
From: Thomas Hellstrom <thellstrom@vmware.com>
We always do dirty tracking on the PTE level. This means that any huge
pmds we encounter should be read-only and not dirty: We can just skip
those. Write-enabled huge pmds should not exist. They should have been
split when made write-enabled. Warn and attempt to split them.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
---
mm/mapping_dirty_helpers.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/mm/mapping_dirty_helpers.c b/mm/mapping_dirty_helpers.c
index 799b9154b48f..f61bb9de1530 100644
--- a/mm/mapping_dirty_helpers.c
+++ b/mm/mapping_dirty_helpers.c
@@ -115,11 +115,18 @@ static int clean_record_pte(pte_t *pte, unsigned long addr,
static int wp_clean_pmd_entry(pmd_t *pmd, unsigned long addr, unsigned long end,
struct mm_walk *walk)
{
- /* Dirty-tracking should be handled on the pte level */
pmd_t pmdval = pmd_read_atomic(pmd);
- if (pmd_trans_huge(pmdval) || pmd_devmap(pmdval))
- WARN_ON(pmd_write(pmdval) || pmd_dirty(pmdval));
+ /*
+ * Dirty-tracking should be handled on the pte level, and write-
+ * enabled huge PMDS should never have been created. Warn on those.
+ * Read-only huge PMDS can't be dirty so we just skip them.
+ */
+ if (pmd_trans_huge(pmdval) || pmd_devmap(pmdval)) {
+ if (WARN_ON(pmd_write(pmdval) || pmd_dirty(pmdval)))
+ return 0;
+ return PAGE_WALK_CONTINUE;
+ }
return 0;
}
--
2.21.0
prev parent reply other threads:[~2019-10-10 13:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 13:40 [RFC PATCH 0/4] mm: pagewalk: Rework callback return values and optionally skip the pte level Thomas Hellström (VMware)
2019-10-10 13:40 ` [RFC PATCH 1/4] mm: Have the mempolicy pagewalk to avoid positive callback return codes Thomas Hellström (VMware)
2019-10-11 13:08 ` Kirill A. Shutemov
2019-10-10 13:40 ` [RFC PATCH 2/4] fs: task_mmu: Have the pagewalk " Thomas Hellström (VMware)
2019-10-10 13:40 ` [RFC PATCH 3/4] mm: pagewalk: Disallow user positive callback return values and use them for walk control Thomas Hellström (VMware)
2019-10-10 13:40 ` Thomas Hellström (VMware) [this message]
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=20191010134058.11949-5-thomas_os@shipmail.org \
--to=thomas_os@shipmail.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=thellstrom@vmware.com \
--cc=torvalds@linux-foundation.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).