Linux Documentation
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
	Hugh Dickins <hughd@google.com>
Cc: linux-mm@kvack.org,
	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>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Lorenzo Stoakes <ljs@kernel.org>
Subject: Re: [RFC V2 3/3] mm: Replace pgtable entry prints with new format
Date: Thu, 2 Jul 2026 14:34:22 +0530	[thread overview]
Message-ID: <e4ec99fc-dfb1-4205-a193-f694e9f6a13b@arm.com> (raw)
In-Reply-To: <82902a84-7e62-496b-b1c0-62bad1be4525@kernel.org>


On 02/07/26 1:02 PM, David Hildenbrand (Arm) wrote:
> On 7/2/26 06:29, Anshuman Khandual wrote:
>>
>>
>> On 30/06/26 7:06 PM, David Hildenbrand (Arm) wrote:
>>> On 6/16/26 08:19, Hugh Dickins wrote:
>>>>
>>>> Yes, that's what it's for. What we really want is to understand what went
>>>> wrong: that's too much to ask of a printk, but it can give us a good clue.
>>>>
>>>>
>>>> Page table entry and pmd entry are good enough: higher levels got
>>>> added at some stage, but they are unlikely to be useful here.
>>>
>>> Yes, I added them when we're processing PUD entries we'd also want
>>> P4D entry + PUD entry.
>>>
>>> This is one approach of having the printing be done mostly
>>> manually, supporting 32, 64 and 128bit pte_val(). As raised by Ryan,
>>> using local bufs to store the data to not involve printk.
>>>
>>>
>>> I played with printing the byte stream manually, but didn't really like it.
>>>
>>> Gave it a quick test and it seems to do its trick. I have the feeling that
>>> this can be beautified a bit more.
>>>
>>>
>>> From 05af7317b126991a61b0a3d01c2863ce5a578d1b Mon Sep 17 00:00:00 2001
>>> From: "David Hildenbrand (Arm)" <david@kernel.org>
>>> Date: Tue, 30 Jun 2026 15:23:02 +0200
>>> Subject: [PATCH] tmp
>>>
>>> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
>>> ---
>>>  mm/memory.c | 110 +++++++++++++++++++++++++++++++++++++++++-----------
>>>  1 file changed, 87 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/mm/memory.c b/mm/memory.c
>>> index ff338c2abe923..ad39cafe110f9 100644
>>> --- a/mm/memory.c
>>> +++ b/mm/memory.c
>>> @@ -519,9 +519,57 @@ static bool is_bad_page_map_ratelimited(void)
>>>  	return false;
>>>  }
>>>  
>>> +#define PTVAL_STR_MAX	(sizeof(u64) * 4 + 1)
>>> +
>>> +static void ptval_bytes_to_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",
>>> +			 (unsigned long long)*(const u64 *)entry);
>>> +		break;
>>> +	case sizeof(u64) * 2: {
>>
>> Could this be made sizeof(u128) instead ? But overall this
>> approach looks good.
> 
> The would be cleaner. We might have to protect this case by something like
> 
> #defined(__SIZEOF_INT128__)
> 	case sizeof(u128):
> 		...
> 		break;
> #endif
> 	default:

Right - realized that just a bit later :) Not all
platforms and corresponding tool chains might not
support u128.

> 
> 	...
> 
> Can you take over this approach and refine it (and address Andy's comments)?

Sure will do that.
> 
> I'm not quite happy about the
> 
> 	typeof(pud_val(pud)) entry = pud_val(pud);
> 
> stuff, but I didn't see an easy (less ugly) way to avoid it. Maybe there is one :)
>

Could __auto_type be an alternative ?

  reply	other threads:[~2026-07-02  9:04 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 ` [RFC V2 2/3] kunit: printf: Add test " Anshuman Khandual
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 [this message]
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=e4ec99fc-dfb1-4205-a193-f694e9f6a13b@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=hughd@google.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=ljs@kernel.org \
    --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