[RFC V2 0/3] lib/vsprintf: Add support for pgtable entries
From: Anshuman Khandual
Date: Wed Jun 10 2026 - 00:36:29 EST
Printing page table entries has been a common requirement both in generic
and platform memory management for various purposes. Hence let's create a
dedicated printk format for such entries which will also help standardize
pgtable printing across different platforms.
Also add a test for this new print format in lib/tests/printf_kunit.c via
existing CONFIG_PRINTF_KUNIT_TEST.
This series applies on v7.1-rc7
This series has been tested on arm64 but built tested on several others
including x86, powerpc, s390, riscv, and mips etc. Although it does not
build on arm32 platform due to existing pgdp_get() concerns.
Changes in V2:
Accommodated most suggestions from Petr Mladek and others
- Moved __print_bad_page_map_pgtable() changes into a separate patch
- Added helper pxd_pointer() for pgtable print format
- Added buffer check via check_pointer()
- Added special_hex_number() for base case printing
- Added static_assert() to ensure acceptable pxd_t size
- Avoided direct dereferences and used pxdp_get() helpers instead
- Improved printf KUNIT tests for all level page table entries
Changes in V1:
https://lore.kernel.org/all/20250618041235.1716143-1-anshuman.khandual@xxxxxxx/
Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Cc: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
Cc: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
Cc: Petr Mladek <pmladek@xxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Jonathan Corbet <corbet@xxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: David Hildenbrand <david@xxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-doc@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx
Anshuman Khandual (3):
lib/vsprintf: Add support for pgtable entries
kunit: printf: Add test for pgtable entries
mm: Replace pgtable entry prints with new format
Documentation/core-api/printk-formats.rst | 19 ++++++++
lib/tests/printf_kunit.c | 57 ++++++++++++++++++++++
lib/vsprintf.c | 58 +++++++++++++++++++++++
mm/memory.c | 15 ++----
scripts/checkpatch.pl | 2 +-
5 files changed, 140 insertions(+), 11 deletions(-)
--
2.30.2