From: Maxwell Bland <mbland@motorola.com>
To: linux-mm@kvack.org
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>,
Ard Biesheuvel <ardb@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Maxwell Bland <mbland@motorola.com>,
Alexandre Ghiti <alexghiti@rivosinc.com>,
linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v5 1/6] mm: add ARCH_SUPPORTS_NON_LEAF_PTDUMP
Date: Mon, 24 Jun 2024 17:11:12 -0500 [thread overview]
Message-ID: <yrgrhwfbl7rnmgekiolmojutaqf24x5zphyrwijakzma5pjhre@3yncjv5tqvar> (raw)
In-Reply-To: <2bcb3htsjhepxdybpw2bwot2jnuezl3p5mnj5rhjwgitlsufe7@xzhkyntridw3>
Provide a Kconfig option indicating if note_page can be called for
intermediate page directories during ptdump.
Signed-off-by: Maxwell Bland <mbland@motorola.com>
---
mm/Kconfig.debug | 8 ++++++++
mm/ptdump.c | 26 ++++++++++++++++++--------
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
index afc72fde0f03..41071539bf9e 100644
--- a/mm/Kconfig.debug
+++ b/mm/Kconfig.debug
@@ -201,6 +201,14 @@ config PTDUMP_DEBUGFS
If in doubt, say N.
+config ARCH_SUPPORTS_NON_LEAF_PTDUMP
+ bool "Include intermediate directory entries in pagetable dumps"
+ help
+ Enable the inclusion of intermediate page directory entries in calls
+ to the ptdump API. Once an architecture defines correct ptdump
+ behavior for PGD, PUD, P4D, and PMD entries, this config can be
+ selected.
+
config HAVE_DEBUG_KMEMLEAK
bool
diff --git a/mm/ptdump.c b/mm/ptdump.c
index 106e1d66e9f9..3c8eea232282 100644
--- a/mm/ptdump.c
+++ b/mm/ptdump.c
@@ -26,6 +26,11 @@ static inline int note_kasan_page_table(struct mm_walk *walk,
}
#endif
+static inline bool has_non_leaf_ptdump(void)
+{
+ return IS_ENABLED(CONFIG_ARCH_SUPPORTS_NON_LEAF_PTDUMP);
+}
+
static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
@@ -41,10 +46,11 @@ static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr,
if (st->effective_prot)
st->effective_prot(st, 0, pgd_val(val));
- if (pgd_leaf(val)) {
+ if (has_non_leaf_ptdump() || pgd_leaf(val))
st->note_page(st, addr, 0, pgd_val(val));
+
+ if (pgd_leaf(val))
walk->action = ACTION_CONTINUE;
- }
return 0;
}
@@ -64,10 +70,11 @@ static int ptdump_p4d_entry(p4d_t *p4d, unsigned long addr,
if (st->effective_prot)
st->effective_prot(st, 1, p4d_val(val));
- if (p4d_leaf(val)) {
+ if (has_non_leaf_ptdump() || p4d_leaf(val))
st->note_page(st, addr, 1, p4d_val(val));
+
+ if (p4d_leaf(val))
walk->action = ACTION_CONTINUE;
- }
return 0;
}
@@ -87,10 +94,11 @@ static int ptdump_pud_entry(pud_t *pud, unsigned long addr,
if (st->effective_prot)
st->effective_prot(st, 2, pud_val(val));
- if (pud_leaf(val)) {
+ if (has_non_leaf_ptdump() || pud_leaf(val))
st->note_page(st, addr, 2, pud_val(val));
+
+ if (pud_leaf(val))
walk->action = ACTION_CONTINUE;
- }
return 0;
}
@@ -108,10 +116,12 @@ static int ptdump_pmd_entry(pmd_t *pmd, unsigned long addr,
if (st->effective_prot)
st->effective_prot(st, 3, pmd_val(val));
- if (pmd_leaf(val)) {
+
+ if (has_non_leaf_ptdump() || pmd_leaf(val))
st->note_page(st, addr, 3, pmd_val(val));
+
+ if (pmd_leaf(val))
walk->action = ACTION_CONTINUE;
- }
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2024-06-24 22:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 22:07 [PATCH v5 0/6] ptdump: add intermediate directory support Maxwell Bland
2024-06-24 22:11 ` Maxwell Bland [this message]
2024-07-05 2:52 ` [PATCH v5 1/6] mm: add ARCH_SUPPORTS_NON_LEAF_PTDUMP kernel test robot
2024-07-15 21:24 ` Maxwell Bland
2024-06-24 22:12 ` [PATCH v5 2/6] arm64: add APTable encoding to pagetable defs Maxwell Bland
2024-06-24 22:13 ` [PATCH v5 3/6] arm64: table descriptor ptdump support Maxwell Bland
2024-06-24 22:14 ` [PATCH v5 4/6] arm64: indent ptdump by level, aligning attributes Maxwell Bland
2024-06-24 22:15 ` [PATCH v5 5/6] arm64: exclusive upper bound for ptdump entries Maxwell Bland
2024-06-24 22:16 ` [PATCH v5 6/6] arm64: add attrs and format to ptdump document Maxwell Bland
2024-06-26 23:45 ` Randy Dunlap
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=yrgrhwfbl7rnmgekiolmojutaqf24x5zphyrwijakzma5pjhre@3yncjv5tqvar \
--to=mbland@motorola.com \
--cc=akpm@linux-foundation.org \
--cc=alexghiti@rivosinc.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=corbet@lwn.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=will@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