Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>, linux-mm@kvack.org
Cc: andriy.shevchenko@linux.intel.com, usama.arif@linux.dev,
	hughd@google.com, willy@infradead.org,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: Standardize printing for pgtable entries
Date: Tue, 7 Jul 2026 14:28:43 +0530	[thread overview]
Message-ID: <dcab355d-ca27-47f1-8421-c610a9e58365@arm.com> (raw)
In-Reply-To: <5c128db1-7f82-4e2c-b029-5623880ea56d@kernel.org>



On 07/07/26 12:38 PM, David Hildenbrand (Arm) wrote:
> On 7/7/26 06:17, Anshuman Khandual wrote:
>> From: "David Hildenbrand (Arm)" <david@kernel.org>
>>
>> Bad page map reporting currently stores page table entry values in an
>> unsigned long long and prints them with fixed 64-bit-oriented format
>> strings. This is inconsistent across call sites and does not work well for
>> architectures where page table entry values are not naturally represented
>> as 64-bit values, such as 32-bit or 128-bit entries.
>>
>> Introduce a common helper to convert raw page table entry values into a
>> fixed-width hexadecimal string based on the actual entry size. Use it for
>> bad page map reporting and for dumping the page table walk in
>> __print_bad_page_map_pgtable().
>>
>> Pass page table entry values to the reporting path as raw bytes together
>> with their size, instead of forcing them through an unsigned long long.
>> It keeps the printed output consistent and avoids truncation or misleading
>> formatting for non-64-bit page table entries.
>>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: linux-mm@kvack.org
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> 
> You should add a Co-developed-by here :)

Have not done much changes from your original patch :)

> >> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
> 
> [...]
> 
>> +
>> +static 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");
>> +		return;
>> +	}
>> +
>> +	switch (entry_size) {
>> +	case sizeof(u32):
>> +		snprintf(buf, buf_size, "%08x", *(const u32 *)entry);
>> +		break;
>> +	case sizeof(u64):
>> +		snprintf(buf, buf_size, "%016llx", *(const u64 *)entry);
>> +		break;
>> +#if defined(__SIZEOF_INT128__)
>> +	case sizeof(u128): {
>> +		const u64 *val = entry;
>> +
>> +		if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
>> +			snprintf(buf, buf_size, "%016llx%016llx", val[0], val[1]);
>> +		else
>> +			snprintf(buf, buf_size, "%016llx%016llx", val[1], val[0]);
>> +		break;
> 
> As discussed, can we simplify that by casting to (u128) and then shifting the
> values into place?

which would be something like the following - had similar
construct in D128 RFC V2 series as well.

snprintf(buf, buf_size, "%016llx%016llx",
	(unsigned long long)*(const u128 *)entry >> 64),
	(unsigned long long)*(const u128 *)entry;

I did think about it but is not the proposed chunk bit cleaner
instead and easier to follow. Do you have concern regarding u64
pointers into u128 then accessed in chunks ? Regardless don't
have a strong opinion either way.


  reply	other threads:[~2026-07-07  9:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  4:17 [PATCH] mm: Standardize printing for pgtable entries Anshuman Khandual
2026-07-07  4:53 ` Matthew Wilcox
2026-07-07  4:57   ` Anshuman Khandual
2026-07-07  7:08 ` David Hildenbrand (Arm)
2026-07-07  8:58   ` Anshuman Khandual [this message]
2026-07-07  9:28     ` 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=dcab355d-ca27-47f1-8421-c610a9e58365@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=david@kernel.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=usama.arif@linux.dev \
    --cc=willy@infradead.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