From: Anshuman Khandual <anshuman.khandual@arm.com>
To: linux-mm@kvack.org
Cc: Anshuman Khandual <anshuman.khandual@arm.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
Jonathan Corbet <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Subject: [RFC V2 2/3] kunit: printf: Add test for pgtable entries
Date: Wed, 10 Jun 2026 05:35:44 +0100 [thread overview]
Message-ID: <20260610043545.3725735-3-anshuman.khandual@arm.com> (raw)
In-Reply-To: <20260610043545.3725735-1-anshuman.khandual@arm.com>
Add test for new pgtable entry print formats with entry size being 64 bits.
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: linux-kernel@vger.kernel.org
lib/tests/printf_kunit.c | 57 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c
index bb70b9cddadd..850bfc0e3409 100644
--- a/lib/tests/printf_kunit.c
+++ b/lib/tests/printf_kunit.c
@@ -791,6 +791,62 @@ errptr(struct kunit *kunittest)
#endif
}
+struct pgtable_test {
+ u64 val;
+ const char *name;
+};
+
+static struct pgtable_test pgtable_test_cases[] = {
+ { .val = 0xc0ffee, .name = "0x0000000000c0ffee"},
+ { .val = 0xdeadbeef, .name = "0x00000000deadbeef"},
+ { .val = 0xaabbcc, .name = "0x0000000000aabbcc"},
+ { .val = 0xcc, .name = "0x00000000000000cc"},
+ { .val = 0x1, .name = "0x0000000000000001"},
+ { .val = 0x11, .name = "0x0000000000000011"},
+ { .val = 0x111, .name = "0x0000000000000111"},
+ { .val = 0x10000010001, .name = "0x0000010000010001"},
+ { .val = 0xc0ffeec0ffee, .name = "0x0000c0ffeec0ffee"},
+ { .val = 0x10000000000, .name = "0x0000010000000000"},
+ { .val = 0x11000000000, .name = "0x0000011000000000"},
+ { .val = 0x1000000000000001, .name = "0x1000000000000001"},
+ { .val = 0x1100000000000010, .name = "0x1100000000000010"},
+ { .val = 0x1110000000000100, .name = "0x1110000000000100"},
+ { .val = 0xfff000000000ff00, .name = "0xfff000000000ff00"},
+};
+
+static void
+pgtable_ptr(struct kunit *kunittest)
+{
+ char buf[64];
+ int i;
+
+ if (sizeof(pte_t) != 8)
+ kunit_skip(kunittest, "pte_t size is not 64 bits");
+
+ for (i = 0; i < ARRAY_SIZE(pgtable_test_cases); i++) {
+ pte_t pte = __pte(pgtable_test_cases[i].val);
+ pmd_t pmd = __pmd(pgtable_test_cases[i].val);
+ pud_t pud = __pud(pgtable_test_cases[i].val);
+ p4d_t p4d = __p4d(pgtable_test_cases[i].val);
+ pgd_t pgd = __pgd(pgtable_test_cases[i].val);
+
+ snprintf(buf, sizeof(buf), "%ppte", &pte);
+ KUNIT_EXPECT_STREQ(kunittest, buf, pgtable_test_cases[i].name);
+
+ snprintf(buf, sizeof(buf), "%ppmd", &pmd);
+ KUNIT_EXPECT_STREQ(kunittest, buf, pgtable_test_cases[i].name);
+
+ snprintf(buf, sizeof(buf), "%ppud", &pud);
+ KUNIT_EXPECT_STREQ(kunittest, buf, pgtable_test_cases[i].name);
+
+ snprintf(buf, sizeof(buf), "%pp4d", &p4d);
+ KUNIT_EXPECT_STREQ(kunittest, buf, pgtable_test_cases[i].name);
+
+ snprintf(buf, sizeof(buf), "%ppgd", &pgd);
+ KUNIT_EXPECT_STREQ(kunittest, buf, pgtable_test_cases[i].name);
+ }
+}
+
static int printf_suite_init(struct kunit_suite *suite)
{
total_tests = 0;
@@ -839,6 +895,7 @@ static struct kunit_case printf_test_cases[] = {
KUNIT_CASE(errptr),
KUNIT_CASE(fwnode_pointer),
KUNIT_CASE(fourcc_pointer),
+ KUNIT_CASE(pgtable_ptr),
{}
};
--
2.30.2
next prev parent reply other threads:[~2026-06-10 4:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 4:35 [RFC V2 0/3] lib/vsprintf: Add support for pgtable entries Anshuman Khandual
2026-06-10 4:35 ` [RFC V2 1/3] " Anshuman Khandual
2026-06-10 11:13 ` Usama Arif
2026-06-11 5:15 ` Anshuman Khandual
2026-06-11 7:17 ` Andy Shevchenko
2026-06-11 9:50 ` Anshuman Khandual
2026-06-11 18:59 ` Andy Shevchenko
2026-06-10 4:35 ` Anshuman Khandual [this message]
2026-06-10 4:35 ` [RFC V2 3/3] mm: Replace pgtable entry prints with new format Anshuman Khandual
2026-06-11 11:32 ` David Hildenbrand (Arm)
2026-06-12 11:08 ` David Hildenbrand (Arm)
2026-06-12 21:26 ` Hugh Dickins
2026-06-15 16:01 ` David Hildenbrand (Arm)
2026-06-16 6:19 ` Hugh Dickins
2026-06-30 13:36 ` David Hildenbrand (Arm)
2026-07-01 9:00 ` Andy Shevchenko
2026-07-02 4:29 ` Anshuman Khandual
2026-07-02 7:32 ` David Hildenbrand (Arm)
2026-07-02 9:04 ` Anshuman Khandual
2026-07-02 9:20 ` Andy Shevchenko
2026-07-02 9:36 ` David Hildenbrand (Arm)
2026-06-11 19:15 ` [RFC V2 0/3] lib/vsprintf: Add support for pgtable entries Matthew Wilcox
2026-06-11 19:33 ` Andy Shevchenko
2026-06-11 19:37 ` Matthew Wilcox
2026-06-12 11:14 ` David Hildenbrand (Arm)
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=20260610043545.3725735-3-anshuman.khandual@arm.com \
--to=anshuman.khandual@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.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