[PATCH 1/8] mm: Make ptval_to_str() generally available
Anshuman Khandual
anshuman.khandual at arm.com
Sun Aug 30 22:43:23 PDT 2026
Move ptval_to_str() inside a header thus making the helper more generally
available for new users which are being added later. While here, also move
another related string size macro PTVAL_STR_MAX inside the header as well.
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: David Hildenbrand <david at kernel.org>
Cc: Lorenzo Stoakes <ljs at kernel.org>
Cc: linux-mm at kvack.org
Cc: linux-kernel at vger.kernel.org
Acked-by: David Hildenbrand (Arm) <david at kernel.org>
Acked-by: Mike Rapoport (Microsoft) <rppt at kernel.org>
Signed-off-by: Anshuman Khandual <anshuman.khandual at arm.com>
---
Changes in V1:
- Moved ptval_to_str() and adjcent declarations inside <include/linux/pgtable.h>
- Fixed type s/ptrval_to_str/ptval_to_str in [PATCH 1/8]
include/linux/pgtable.h | 14 ++++++++++++++
mm/memory.c | 15 +--------------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 8c093c119e5a..e3c8ab96941c 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -2313,6 +2313,20 @@ static inline const char *pgtable_level_to_str(enum pgtable_level level)
}
}
+void ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry, size_t entry_size);
+
+#define ptval_to_str(buf, val) \
+ do { \
+ auto __val = (val); \
+ \
+ ptval_bytes_to_hex_str((buf), sizeof(buf), &__val, sizeof(__val)); \
+ } while (0)
+
+#if defined(__SIZEOF_INT128__)
+#define PTVAL_STR_MAX (32 + 1) /* Max 128-bit value in hex + NUL */
+#else
+#define PTVAL_STR_MAX (16 + 1) /* Max 64-bit value in hex + NUL */
+#endif
#endif /* !__ASSEMBLER__ */
#if !defined(MAX_POSSIBLE_PHYSMEM_BITS) && !defined(CONFIG_64BIT)
diff --git a/mm/memory.c b/mm/memory.c
index 8b0c2c735d3d..aa6b2fc770fc 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -519,7 +519,7 @@ static bool is_bad_page_map_ratelimited(void)
return false;
}
-static void ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry, size_t entry_size)
+void ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry, size_t entry_size)
{
if (WARN_ON_ONCE(buf_size < entry_size * 2 + 1)) {
snprintf(buf, buf_size, "overflow");
@@ -546,19 +546,6 @@ static void ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry
}
}
-#define ptval_to_str(buf, val) \
- do { \
- auto __val = (val); \
- \
- ptval_bytes_to_hex_str((buf), sizeof(buf), &__val, sizeof(__val)); \
- } while (0)
-
-#if defined(__SIZEOF_INT128__)
-#define PTVAL_STR_MAX (32 + 1) /* Max 128-bit value in hex + NUL */
-#else
-#define PTVAL_STR_MAX (16 + 1) /* Max 64-bit value in hex + NUL */
-#endif
-
static void __print_bad_page_map_pgtable(struct mm_struct *mm, unsigned long addr)
{
char pgd_str[PTVAL_STR_MAX];
--
2.43.0
More information about the linux-snps-arc
mailing list