mm, vsprintf: dump full information of page flags in pGp
Subsystems (5)
v2 cover mm, vsprintf: dump full information of page flags in pGp
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
This patchset also includes some code cleanup in mm/slub.c.
Below is the example of the output in mm/slub.c.
- Before the patchset
[ 6155.716018] INFO: Slab 0x000000004027dd4f objects=33 used=3 fp=0x000000008cd1579c flags=0x17ffffc0010200
- After the patchset
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)
The documentation and test cases of pGp are also updated.
Below is the result of the test_printf,
[ 5091.307308] test_printf: loaded. [ 5091.308285] test_printf: all 388 tests passed [ 5091.309105] test_printf: unloaded.
v2:
- various coding improvement, per Joe, Miaohe, Vlastimil and Andy
- remove the prefix completely in patch #2, per Vlastimil
- Update the test cases, per Andy
Yafang Shao (3):
mm, slub: use pGp to print page flags
mm, slub: don't combine pr_err with INFO
vsprintf: dump full information of page flags in pGp
Documentation/core-api/printk-formats.rst | 2 +- lib/test_printf.c | 65 ++++++++++++++++++----- lib/vsprintf.c | 58 +++++++++++++++++++- mm/slub.c | 13 ++--- 4 files changed, 116 insertions(+), 22 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/3 mm, slub: use pGp to print page flags
As pGp has been already introduced in printk, we'd better use it to make the output human readable.
Before this change, the output is,
[ 6155.716018] INFO: Slab 0x000000004027dd4f objects=33 used=3 fp=0x000000008cd1579c flags=0x17ffffc0010200
While after this change, the output is,
[ 8846.517809] INFO: Slab 0x00000000f42a2c60 objects=33 used=3 fp=0x0000000060d32ca8 flags=0x17ffffc0010200(slab|head)
--- mm/slub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/slub.c +3 -2
@@ -638,8 +638,9 @@ void print_tracking(struct kmem_cache *s, void *object)static void print_page_info (struct page *page) { -pr_err ("INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n" , - page, page->objects, page->inuse, page->freelist, page->flags); +pr_err ("INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=%#lx(%pGp)\n" , + page, page->objects, page->inuse, page->freelist, + page->flags, &page->flags); }
Signature · 1 line
2.17.1
PATCH v2 2/3 mm, slub: don't combine pr_err with INFO
In reply to Yafang ShaoIt is strange to combine "pr_err" with "INFO", so let's remove the prefix completely.
This patch is motivated by David's comment[1].
- before the patch
[ 8846.517809] INFO: Slab 0x00000000f42a2c60 objects=33 used=3 fp=0x0000000060d32ca8 flags=0x17ffffc0010200(slab|head)
- after the patch
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)
[1]. https://lore.kernel.org/linux-mm/[email protected]/#t
--- mm/slub.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
mm/slub.c +5 -5
@@ -612,7 +612,7 @@ static void print_track(const char *s, struct track *t, unsigned long pr_time)if (!t->addr)return ; -pr_err ("INFO: %s in %pS age=%lu cpu=%u pid=%d\n" , +pr_err ("%s in %pS age=%lu cpu=%u pid=%d\n" , s, (void *)t->addr, pr_time - t->when, t->cpu, t->pid);#ifdef CONFIG_STACKTRACE {
@@ -638,7 +638,7 @@ void print_tracking(struct kmem_cache *s, void *object)static void print_page_info (struct page *page) { -pr_err ("INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=%#lx(%pGp)\n" , +pr_err ("Slab 0x%p objects=%u used=%u fp=0x%p flags=%#lx(%pGp)\n" , page, page->objects, page->inuse, page->freelist, page->flags, &page->flags);
@@ -695,7 +695,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)print_page_info (page); -pr_err ("INFO: Object 0x%p @offset=%tu fp=0x%p\n\n" , +pr_err ("Object 0x%p @offset=%tu fp=0x%p\n\n" , p, p - addr,get_freepointer (s, p));if (s->flags &SLAB_RED_ZONE )
@@ -788,7 +788,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page, end--;slab_bug (s,"%s overwritten" , what); -pr_err ("INFO: 0x%p-0x%p @offset=%tu. First byte 0x%x instead of 0x%x\n" , +pr_err ("0x%p-0x%p @offset=%tu. First byte 0x%x instead of 0x%x\n" , fault, end -1 , fault - addr, fault[0 ], value);print_trailer (s, page, object);
@@ -3854,7 +3854,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,for_each_object (p, s, addr, page->objects) {if (!test_bit (__obj_to_index (s, addr, p), map)) { -pr_err ("INFO: Object 0x%p @offset=%tu\n" , p, p - addr); +pr_err ("Object 0x%p @offset=%tu\n" , p, p - addr);print_tracking (s, p); } }
Signature · 1 line
2.17.1
PATCH v2 3/3 vsprintf: dump full information of page flags in pGp
In reply to Yafang ShaoCurrently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)
- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)
The Documentation and test cases are also updated.
--- Documentation/core-api/printk-formats.rst | 2 +- lib/test_printf.c | 65 ++++++++++++++++++----- lib/vsprintf.c | 58 +++++++++++++++++++- 3 files changed, 109 insertions(+), 16 deletions(-)
Documentation/core-api/printk-formats.rst +1 -1
@@ -538,7 +538,7 @@ Flags bitfields such as page flags, gfp_flags :: - %pGp referenced|uptodate|lru|active|private + %pGp Node 0,Zone 2,referenced|uptodate|lru|active|private %pGg GFP_USER|GFP_DMA32|GFP_NOWARN %pGv read|exec|mayread|maywrite|mayexec|denywrite
lib/test_printf.c +51 -14
84 lines not on this page · raw message
lib/vsprintf.c +57 -1
70 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 10 lines · Yafang Shao
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)
While debugfs is not an ABI, this format is exported in debugfs to userspace via mm/page_owner.c read_page_owner/print_page_owner.
Does changing the output format matter to anyone?
lib/vsprintf.c
Quoted 1 line
lib/vsprintf.c +0
-0
[]
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1944
Quoted 5 lines
lib/vsprintf.c +5
-0+static +char *format_page_flags (char *buf,char *end,unsigned long page_flags) +{ +unsigned long flags = page_flags & ((1UL <<NR_PAGEFLAGS ) -1 ); +int size =ARRAY_SIZE (pfl);
There's no real value in used-once variables.
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1948
Quoted 4 lines
lib/vsprintf.c +4
-0+bool separator = false; +int i; + +for (i =0 ; i < size; i++) {
Use ARRAY_SIZE here instead
for (i = 0; i < ARRAY_SIZE(pfl); i++) {Quoted 6 lines
lib/vsprintf.c +6
-0+if (pfl[i].width ==0 ) +continue ; + +if (separator) { +if (buf < end) + *buf =',' ;
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1964
Quoted 10 lines
lib/vsprintf.c +10
-0+ buf++; + } + + + buf =string (buf, end, pfl[i].name, *pfl[i].spec); + + buf =number (buf, end, (page_flags >> pfl[i].shift) & pfl[i].mask, + *pfl[i].spec); + separator = true; + }
Style question:
Might this array be more intelligible with pointers instead of indexes? Something like:
struct page_flags_layout *p;
for (p = pfl; p < pfl + ARRAY_SIZE(pfl); p++) {
if (p->width == 0)
continue;
if (p > pfl) {
if (buf < end)
*buf = ',';
buf++;
}
buf = string(buf, end, p->name, *p->spec);
buf = number(buf, end, (page_flags >> p->shift) & p->mask, *p->spec);
}lib/vsprintf.c
Quoted 2 lines
lib/vsprintf.c +2
-0+ +if (flags) {
Maybe:
if (page_flags & (BIT(NR_PAGEFLAGS) - 1)) {Quoted 8 lines
lib/vsprintf.c +8
-0+if (buf < end) + *buf =',' ; + buf++; + } + +return buf; +} +
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 7 lines · Joe Perches
Quoted 5 lines · Yafang Shao
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
Quoted 9 lines
Quoted 5 lines
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)While debugfs is not an ABI, this format is exported in debugfs to userspace via
mm/page_owner.cread_page_owner/print_page_owner.
Right, the page_owner will be affected by this change.
Quoted 2 lines
Does changing the output format matter to anyone?
The user tools which parse the page_owner may be affected. If we don't want to affect the userspace tools, I think we can make a little change in page_owner as follows,
unsigned long masked_flags = page->flags & (BIT(NR_PAGEFLAGS) - 1);
snprintf("..., %#lx(%pGp)\n", page->flags, &masked_flags);Quoted 10 lines
lib/vsprintf.c
Quoted 1 line
lib/vsprintf.c +0
-0[]
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1944
Quoted 5 lines
lib/vsprintf.c +5
-0+static +char *format_page_flags (char *buf,char *end,unsigned long page_flags) +{ +unsigned long flags = page_flags & ((1UL <<NR_PAGEFLAGS ) -1 ); +int size =ARRAY_SIZE (pfl);There's no real value in used-once variables.
Quoted 7 lines
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1948
Quoted 4 lines
lib/vsprintf.c +4
-0+bool separator = false; +int i; + +for (i =0 ; i < size; i++) {Use
ARRAY_SIZEhere instead
Sure
Quoted 13 lines
for (i = 0; i < ARRAY_SIZE(pfl); i++) {Quoted 11 lines
lib/vsprintf.c +11
-0+if (pfl[i].width ==0 ) +continue ; + +if (separator) { +if (buf < end) + *buf =',' ; + buf++; + } + + + buf =string (buf, end, pfl[i].name, *pfl[i].spec);
Quoted 8 lines
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1964
Quoted 5 lines
lib/vsprintf.c +5
-0+ + buf =number (buf, end, (page_flags >> pfl[i].shift) & pfl[i].mask, + *pfl[i].spec); + separator = true; + }Style question:
Might this array be more intelligible with pointers instead of indexes?
Good suggestion!
I will change it in the next version.
Quoted 14 lines
Something like:
struct page_flags_layout *p; for (p = pfl; p < pfl + ARRAY_SIZE(pfl); p++) { if (p->width == 0) continue; if (p > pfl) { if (buf < end) *buf = ','; buf++; }
It doesn't work, because there's a 'continue' above, meaning that the p may be greater than pfl without doing anything.
Quoted 5 lines
buf = string(buf, end, p->name, *p->spec);
buf = number(buf, end, (page_flags >> p->shift) & p->mask, *p->spec);
}Quoted 7 lines
lib/vsprintf.c
Quoted 2 lines
lib/vsprintf.c +2
-0+ +if (flags) {Maybe:
if (page_flags & (BIT(NR_PAGEFLAGS) - 1)) {
Sure.
Quoted 10 lines
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1974
Quoted 8 lines
lib/vsprintf.c +8
-0+if (buf < end) + *buf =',' ; + buf++; + } + +return buf; +} +
--
Thanks
Yafang
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
In reply to Yafang ShaoQuoted 10 lines · Yafang Shao
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)
For debugging purposes, it might be helpful to have the actual zone name (and to know if the value is sane). You could obtain it (without other modifications) via
const char zname = "Invalid";
if (zone < MAX_NR_ZONES)
zname = first_online_pgdat()->node_zones[zone].name;
Similarly, it might also be helpful to indicate if a node is online/offline/invalid/.
const char nstate = "Invalid";
if (node_online(nid))
nstate = "Online"; else if (node_possible(nid)) nstate = "Offline";
Printing that in addition to the raw value could be helpful. Just some thoughts.
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 25 lines · David Hildenbrand
Quoted 10 lines · Yafang Shao
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)For debugging purposes, it might be helpful to have the actual zone name (and to know if the value is sane). You could obtain it (without other modifications) via
const char zname = "Invalid";
if (zone <
MAX_NR_ZONES)zname = first_online_pgdat()->node_zones[zone].name;Similarly, it might also be helpful to indicate if a node is online/offline/invalid/.
Quoted 6 lines
const char nstate = "Invalid";
if (
node_online(nid))nstate = "Online"; else if (node_possible(nid)) nstate = "Offline";
Just remembering that we have to take care of nid limits:
if (nid >= 0 && nid < MAX_NUMNODES) {
if (node_online(nid))
nstate = "Online";
else if (node_possible(nid))
nstate = "Offline";
}Signature · 3 lines
Thanks, David / dhildenb
Andy Shevchenko
reviewerRe: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
In reply to David HildenbrandQuoted 27 lines · David Hildenbrand
Quoted 10 lines · Yafang Shao
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)For debugging purposes, it might be helpful to have the actual zone name (and to know if the value is sane). You could obtain it (without other modifications) via
const char zname = "Invalid";
if (zone <
MAX_NR_ZONES)zname = first_online_pgdat()->node_zones[zone].name;Similarly, it might also be helpful to indicate if a node is online/offline/invalid/.
const char nstate = "Invalid";
Quoted 8 lines
if (
node_online(nid))nstate = "Online"; else if (node_possible(nid)) nstate = "Offline";Printing that in addition to the raw value could be helpful. Just some thoughts.
printf() buffer is not a black hole, esp. when you get it messed with critical messages (Oops). I suggest to reduce a burden as much as possible. If you wish to get this, make it caller-configurable, i.e. adding another letter to the specifier.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 35 lines · Andy Shevchenko
Quoted 33 lines · David Hildenbrand
Quoted 10 lines · Yafang Shao
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)For debugging purposes, it might be helpful to have the actual zone name (and to know if the value is sane). You could obtain it (without other modifications) via
const char zname = "Invalid";
if (zone <
MAX_NR_ZONES)zname = first_online_pgdat()->node_zones[zone].name;Similarly, it might also be helpful to indicate if a node is online/offline/invalid/.
const char nstate = "Invalid";
if (
node_online(nid))nstate = "Online"; else if (node_possible(nid)) nstate = "Offline";
Quoted 8 lines
Quoted 2 lines
Printing that in addition to the raw value could be helpful. Just some thoughts.
printf()buffer is not a black hole, esp. when you get it messed with critical messages (Oops). I suggest to reduce a burden as much as possible. If you wish to get this, make it caller-configurable, i.e. adding another letter to the specifier.
I think David's suggestion will help us to identify issues.
You mean that we should use another one like "%pGpd" - means pGp debug
- to implement it ?
Signature · 2 lines
Thanks Yafang
Andy Shevchenko
reviewerRe: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 4 lines · Yafang Shao
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · David Hildenbrand
On 01.02.21 12:56, Yafang Shao wrote:
...
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Printing that in addition to the raw value could be helpful. Just some thoughts.
printf()buffer is not a black hole, esp. when you get it messed with critical messages (Oops). I suggest to reduce a burden as much as possible. If you wish to get this, make it caller-configurable, i.e. adding another letter to the specifier.
Quoted 4 lines
I think David's suggestion will help us to identify issues.
You mean that we should use another one like "%pGpd" - means pGp debug
- to implement it ?
Yes.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
reviewerRe: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
In reply to Yafang ShaoQuoted 5 lines · Yafang Shao
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
Quoted 7 lines
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)The Documentation and test cases are also updated.
Thanks for an update, my comments below.
...
Documentation/core-api/printk-formats.rst Flags bitfields such as page flags, gfp_flags · line 541
Quoted 2 lines
Documentation/core-api/printk-formats.rst +1
-1- %pGp referenced|uptodate|lru|active|private + %pGp Node 0,Zone 2,referenced|uptodate|lru|active|private
Since of the nature of printf() buffer, I wonder if these should be at the end. I.o.w. the question is is the added material more important to user to see than the existed one?
...
lib/test_printf.c netdev_features(void) · line 581
Quoted 10 lines
lib/test_printf.c +10
-0+static void __init +page_flags_test (int section,int node,int zone,int last_cpupid, +int kasan_tag,int flags,const char *name,char *cmp_buf) +{ +unsigned long page_flags =0 ; +unsigned long size =0 ; + +#ifdef SECTION_IN_PAGE_FLAGS + page_flags |= (sec &SECTIONS_MASK ) <<SECTIONS_PGSHIFT ; +snprintf (cmp_buf,BUF_SIZE ,"Section %#x," , sec);
I would keep it in the same form as latter ones, i.e.
snprintf(cmp_buf + size, BUF_SIZE - size, "Section %#x,", sec);
In this case it will be easier if at some point we might need to reshuffle.
Quoted 16 lines
lib/test_printf.c +16
-0+ size =strlen (cmp_buf); +#endif + + page_flags |= (node &NODES_MASK ) <<NODES_PGSHIFT ; +snprintf (cmp_buf + size,BUF_SIZE - size,"Node %d" , node); + size =strlen (cmp_buf); + + page_flags |= (zone &ZONES_MASK ) <<ZONES_PGSHIFT ; +snprintf (cmp_buf + size,BUF_SIZE - size,",Zone %d" , zone); + size =strlen (cmp_buf); + +#ifndef LAST_CPUPID_NOT_IN_PAGE_FLAGS + page_flags |= (last_cpupid &LAST_CPUPID_MASK ) <<LAST_CPUPID_PGSHIFT ; +snprintf (cmp_buf + size,BUF_SIZE - size,",Lastcpupid %#x" , last_cpupid); + size =strlen (cmp_buf); +#endif
lib/test_printf.c netdev_features(void) · line 607
Quoted 10 lines
lib/test_printf.c +10
-0+ +#if defined(CONFIG_KASAN_SW_TAGS ) || defined(CONFIG_KASAN_HW_TAGS ) + page_flags |= (tag &KASAN_TAG_MASK ) <<KASAN_TAG_PGSHIFT ; +snprintf (cmp_buf + size,BUF_SIZE - size,",Kasantag %#x" , tag); + size =strlen (cmp_buf); +#endif + +test (cmp_buf,"%pGp" , &page_flags); + +if (flags) {
If below will be always for flags set, I would rewrite this condition as
if (!flags) return;
but it's up to you.
Quoted 5 lines
lib/test_printf.c +5
-0+ page_flags |= flags; +snprintf (cmp_buf + size,BUF_SIZE - size,",%s" , name); +test (cmp_buf,"%pGp" , &page_flags); + } +}
...
lib/test_printf.c flags(void) · line 587
Quoted 4 lines
lib/test_printf.c +0
-3- flags =0 ; - flags |=1UL << PG_uptodate |1UL << PG_dirty |1UL << PG_lru - |1UL << PG_active |1UL << PG_swapbacked;
I would leave this untouched and reuse below...
lib/test_printf.c flags(void) · line 623
Quoted 3 lines
lib/test_printf.c +3
-0+ cmp_buffer =kmalloc (BUF_SIZE ,GFP_KERNEL ); +if (!cmp_buffer) +return ;
...as
lib/test_printf.c flags(void) · line 625
Quoted 1 line
lib/test_printf.c +1
-0+page_flags_test (0 ,0 ,0 ,0 ,0 ,0 ,NULL , cmp_buffer);
flags = 0; page_flags_test(0, 0, 0, 0, 0, flags, NULL, cmp_buffer);
lib/test_printf.c flags(void) · line 630
Quoted 5 lines
lib/test_printf.c +5
-0+page_flags_test (1 ,1 ,1 ,0x1ffff ,1 , + (1UL << PG_uptodate |1UL << PG_dirty |1UL << PG_lru + |1UL << PG_active |1UL << PG_swapbacked), +"uptodate|dirty|lru|active|swapbacked" , + cmp_buffer);
flags |= 1UL << PG_uptodate | 1UL << PG_dirty | 1UL << PG_lru | 1UL << PG_active | 1UL << PG_swapbacked; page_flags_test(1, 1, 1, 0x1ffff, 1, flags, "uptodate|dirty|lru|active|swapbacked", cmp_buffer);
...
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1938
Quoted 12 lines
lib/vsprintf.c +12
-0+static const struct page_flags_layout pfl[] = { + {SECTIONS_WIDTH ,SECTIONS_PGSHIFT ,SECTIONS_MASK , + &default_dec_spec,"Section " }, + {NODES_WIDTH ,NODES_PGSHIFT ,NODES_MASK , + &default_dec_spec,"Node " }, + {ZONES_WIDTH ,ZONES_PGSHIFT ,ZONES_MASK , + &default_dec_spec,"Zone " }, + {LAST_CPUPID_WIDTH ,LAST_CPUPID_PGSHIFT ,LAST_CPUPID_MASK , + &default_flag_spec,"Lastcpupid " }, + {KASAN_TAG_WIDTH ,KASAN_TAG_PGSHIFT ,KASAN_TAG_MASK , + &default_flag_spec,"Kasantag " }, +};
Please add trailing space only once where it's needed (below in the code).
...
Quoted 10 lines
lib/vsprintf.c +10
-0+static +char *format_page_flags (char *buf,char *end,unsigned long page_flags) +{ +unsigned long flags = page_flags & ((1UL <<NR_PAGEFLAGS ) -1 ); +int size =ARRAY_SIZE (pfl); +bool separator = false; +int i; + +for (i =0 ; i < size; i++) { +if (pfl[i].width ==0 )
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1958
Quoted 10 lines
lib/vsprintf.c +9
-0+continue ; + +if (separator) { +if (buf < end) + *buf =',' ; + buf++; + } + +
One blank line is enough.
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1970
Quoted 12 lines
lib/vsprintf.c +12
-0+ buf =string (buf, end, pfl[i].name, *pfl[i].spec); + + buf =number (buf, end, (page_flags >> pfl[i].shift) & pfl[i].mask, + *pfl[i].spec); + separator = true; + } + +if (flags) { +if (buf < end) + *buf =',' ; + buf++; + }
I think you may optimize above to avoid using the separator variable.
DECLARE_BITMAP(mask, ARRAY_SIZE(pfl));
unsigned long flags;
unsigned long last;
for (i = 0; i < ARRAY_SIZE(pfl); i++)
__assign_bit(mask, pfl[i].width);
last = find_last_bit(mask, ARRAY_SIZE(pfl));
for_each_set_bit(i, mask, ARRAY_SIZE(pfl)) {
flags = (page_flags >> pfl[i].shift) & pfl[i].mask;
/* Format: Flag Name + ' ' (space) + Number + ',' (separator) */
buf = string(buf, end, pfl[i].name, *pfl[i].spec);
if (buf < end)
*buf = ' ';
buf++;
buf = number(buf, end, flags, *pfl[i].spec);
/* No separator for the last entry */
if ((page_flags & (BIT(NR_PAGEFLAGS) - 1)) || (i != last)) {
if (buf < end)
*buf = ',';
buf++;
}
}Quoted 2 lines
lib/vsprintf.c +2
-0+return buf; +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 17 lines · Andy Shevchenko
Quoted 5 lines · Yafang Shao
Currently the pGp only shows the names of page flags, rather than the full information including section, node, zone, last cpupid and kasan tag. While it is not easy to parse these information manually because there're so many flavors. Let's interpret them in pGp as well.
Quoted 7 lines
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)The Documentation and test cases are also updated.
Thanks for an update, my comments below.
Quoted 9 lines
...
Documentation/core-api/printk-formats.rst Flags bitfields such as page flags, gfp_flags · line 541
Quoted 2 lines
Documentation/core-api/printk-formats.rst +1
-1- %pGp referenced|uptodate|lru|active|private + %pGp Node 0,Zone 2,referenced|uptodate|lru|active|privateSince of the nature of
printf()buffer, I wonder if these should be at the end. I.o.w. the question is is the added material more important to user to see than the existed one?
The existing one should be more important than the added one. But the order of output will not match with the value for page->flags. E.g.
flags=0x17ffffc0010200(slab|head,Node 0,Zone 2,Lastcpupid 0x1fffff)
It may be strange to compare the value with the string.
Quoted 15 lines
...
lib/test_printf.c netdev_features(void) · line 581
Quoted 10 lines
lib/test_printf.c +10
-0+static void __init +page_flags_test (int section,int node,int zone,int last_cpupid, +int kasan_tag,int flags,const char *name,char *cmp_buf) +{ +unsigned long page_flags =0 ; +unsigned long size =0 ; + +#ifdef SECTION_IN_PAGE_FLAGS + page_flags |= (sec &SECTIONS_MASK ) <<SECTIONS_PGSHIFT ; +snprintf (cmp_buf,BUF_SIZE ,"Section %#x," , sec);I would keep it in the same form as latter ones, i.e.
Quoted 4 lines
snprintf(cmp_buf + size, BUF_SIZE - size, "Section %#x,", sec);In this case it will be easier if at some point we might need to reshuffle.
Good suggestion.
Quoted 66 lines
Quoted 16 lines
lib/test_printf.c +16
-0+ size =strlen (cmp_buf); +#endif + + page_flags |= (node &NODES_MASK ) <<NODES_PGSHIFT ; +snprintf (cmp_buf + size,BUF_SIZE - size,"Node %d" , node); + size =strlen (cmp_buf); + + page_flags |= (zone &ZONES_MASK ) <<ZONES_PGSHIFT ; +snprintf (cmp_buf + size,BUF_SIZE - size,",Zone %d" , zone); + size =strlen (cmp_buf); + +#ifndef LAST_CPUPID_NOT_IN_PAGE_FLAGS + page_flags |= (last_cpupid &LAST_CPUPID_MASK ) <<LAST_CPUPID_PGSHIFT ; +snprintf (cmp_buf + size,BUF_SIZE - size,",Lastcpupid %#x" , last_cpupid); + size =strlen (cmp_buf); +#endif lib/test_printf.c netdev_features(void) · line 607
Quoted 10 lines
lib/test_printf.c +10
-0+ +#if defined(CONFIG_KASAN_SW_TAGS ) || defined(CONFIG_KASAN_HW_TAGS ) + page_flags |= (tag &KASAN_TAG_MASK ) <<KASAN_TAG_PGSHIFT ; +snprintf (cmp_buf + size,BUF_SIZE - size,",Kasantag %#x" , tag); + size =strlen (cmp_buf); +#endif + +test (cmp_buf,"%pGp" , &page_flags); + +if (flags) {If below will be always for flags set, I would rewrite this condition as
if (!flags) return;but it's up to you.
Quoted 5 lines
lib/test_printf.c +5
-0+ page_flags |= flags; +snprintf (cmp_buf + size,BUF_SIZE - size,",%s" , name); +test (cmp_buf,"%pGp" , &page_flags); + } +}...
lib/test_printf.c flags(void) · line 587
Quoted 4 lines
lib/test_printf.c +0
-3- flags =0 ; - flags |=1UL << PG_uptodate |1UL << PG_dirty |1UL << PG_lru - |1UL << PG_active |1UL << PG_swapbacked;I would leave this untouched and reuse below...
lib/test_printf.c flags(void) · line 623
Quoted 3 lines
lib/test_printf.c +3
-0+ cmp_buffer =kmalloc (BUF_SIZE ,GFP_KERNEL ); +if (!cmp_buffer) +return ;...as
Quoted 1 line
+
page_flags_test(0, 0, 0, 0, 0, 0, NULL, cmp_buffer);flags = 0; page_flags_test(0, 0, 0, 0, 0, flags, NULL, cmp_buffer);lib/test_printf.c flags(void) · line 630
Quoted 5 lines
lib/test_printf.c +5
-0+page_flags_test (1 ,1 ,1 ,0x1ffff ,1 , + (1UL << PG_uptodate |1UL << PG_dirty |1UL << PG_lru + |1UL << PG_active |1UL << PG_swapbacked), +"uptodate|dirty|lru|active|swapbacked" , + cmp_buffer);
Quoted 6 lines
flags |= 1UL << PG_uptodate | 1UL << PG_dirty | 1UL << PG_lru
| 1UL << PG_active | 1UL << PG_swapbacked;
page_flags_test(1, 1, 1, 0x1ffff, 1, flags,
"uptodate|dirty|lru|active|swapbacked",
cmp_buffer);Sure, I will change them.
Quoted 37 lines
...
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1938
Quoted 12 lines
lib/vsprintf.c +12
-0+static const struct page_flags_layout pfl[] = { + {SECTIONS_WIDTH ,SECTIONS_PGSHIFT ,SECTIONS_MASK , + &default_dec_spec,"Section " }, + {NODES_WIDTH ,NODES_PGSHIFT ,NODES_MASK , + &default_dec_spec,"Node " }, + {ZONES_WIDTH ,ZONES_PGSHIFT ,ZONES_MASK , + &default_dec_spec,"Zone " }, + {LAST_CPUPID_WIDTH ,LAST_CPUPID_PGSHIFT ,LAST_CPUPID_MASK , + &default_flag_spec,"Lastcpupid " }, + {KASAN_TAG_WIDTH ,KASAN_TAG_PGSHIFT ,KASAN_TAG_MASK , + &default_flag_spec,"Kasantag " }, +};Please add trailing space only once where it's needed (below in the code).
...
Quoted 17 lines
lib/vsprintf.c +17
-0+static +char *format_page_flags (char *buf,char *end,unsigned long page_flags) +{ +unsigned long flags = page_flags & ((1UL <<NR_PAGEFLAGS ) -1 ); +int size =ARRAY_SIZE (pfl); +bool separator = false; +int i; + +for (i =0 ; i < size; i++) { +if (pfl[i].width ==0 ) +continue ; + +if (separator) { +if (buf < end) + *buf =',' ; + buf++; + }
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +One blank line is enough.
Thanks for pointing it out.
BTW, it seems we need to improve the check_patch to catch this kind of issue automatically.
Quoted 36 lines
lib/vsprintf.c char *format_flags(char *buf, char *end, unsigned long flags, · line 1970
Quoted 12 lines
lib/vsprintf.c +12
-0+ buf =string (buf, end, pfl[i].name, *pfl[i].spec); + + buf =number (buf, end, (page_flags >> pfl[i].shift) & pfl[i].mask, + *pfl[i].spec); + separator = true; + } + +if (flags) { +if (buf < end) + *buf =',' ; + buf++; + }I think you may optimize above to avoid using the separator variable.
DECLARE_BITMAP(mask, ARRAY_SIZE(pfl)); unsigned long flags; unsigned long last; for (i = 0; i < ARRAY_SIZE(pfl); i++) __assign_bit(mask, pfl[i].width); last = find_last_bit(mask, ARRAY_SIZE(pfl)); for_each_set_bit(i, mask, ARRAY_SIZE(pfl)) { flags = (page_flags >> pfl[i].shift) & pfl[i].mask; /* Format: Flag Name + ' ' (space) + Number + ',' (separator) */ buf = string(buf, end, pfl[i].name, *pfl[i].spec); if (buf < end) *buf = ' '; buf++; buf = number(buf, end, flags, *pfl[i].spec);
Quoted 8 lines
/* No separator for the last entry */
if ((page_flags & (BIT(NR_PAGEFLAGS) - 1)) || (i != last)) {
if (buf < end)
*buf = ',';
buf++;
}
}Good suggestion. I will think about it.
Signature · 2 lines
Thanks Yafang
Andy Shevchenko
reviewerRe: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 3 lines · Yafang Shao
Quoted 1 line · Andy Shevchenko
On Mon, Feb 01, 2021 at 07:56:10PM +0800, Yafang Shao wrote:
...
Quoted 20 lines
Quoted 10 lines
Quoted 7 lines
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)The Documentation and test cases are also updated.
Thanks for an update, my comments below.
Quoted 9 lines
...
Documentation/core-api/printk-formats.rst Flags bitfields such as page flags, gfp_flags · line 541
Quoted 2 lines
Documentation/core-api/printk-formats.rst +1
-1- %pGp referenced|uptodate|lru|active|private + %pGp Node 0,Zone 2,referenced|uptodate|lru|active|privateSince of the nature of
printf()buffer, I wonder if these should be at the end. I.o.w. the question is is the added material more important to user to see than the existed one?
Quoted 5 lines
The existing one should be more important than the added one. But the order of output will not match with the value for
page->flags. E.g.flags=0x17ffffc0010200(slab|head,Node 0,Zone 2,Lastcpupid 0x1fffff)It may be strange to compare the value with the string.
More I'm looking at it, more I'm thinking it should have different specifiers for each group of desired flags to be printed.
So, you leave %pGp as is and then add another letter to add more details, so user will choose what and in which order they want.
For example, let's assume %pGp == %pGpf and P is a new specifier for what you are initially adding here:
%pGpfP => referenced|uptodate|lru|active|private,Node 0,Zone 2 %pGpPf => Node 0,Zone 2,referenced|uptodate|lru|active|private
and so on.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
reviewerRe: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Yafang Shao
Quoted 1 line · Andy Shevchenko
On Mon, Feb 01, 2021 at 07:56:10PM +0800, Yafang Shao wrote:
...
Quoted 12 lines
Quoted 5 lines
The existing one should be more important than the added one. But the order of output will not match with the value for
page->flags. E.g.flags=0x17ffffc0010200(slab|head,Node 0,Zone 2,Lastcpupid 0x1fffff)It may be strange to compare the value with the string.
More I'm looking at it, more I'm thinking it should have different specifiers for each group of desired flags to be printed.
So, you leave %pGp as is and then add another letter to add more details, so user will choose what and in which order they want.
Quoted 7 lines
For example, let's assume %pGp == %pGpf and P is a new specifier for what you are initially adding here:
%pGpfP => referenced|uptodate|lru|active|private,Node 0,Zone 2 %pGpPf => Node 0,Zone 2,referenced|uptodate|lru|active|private
and so on.
And I agree with Matthew about format, but it doesn't oppose my suggestion above.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
In reply to Andy ShevchenkoQuoted 40 lines · Andy Shevchenko
Quoted 3 lines · Yafang Shao
Quoted 1 line · Andy Shevchenko
On Mon, Feb 01, 2021 at 07:56:10PM +0800, Yafang Shao wrote:
...
Quoted 20 lines
Quoted 10 lines
Quoted 7 lines
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)The Documentation and test cases are also updated.
Thanks for an update, my comments below.
Quoted 9 lines
...
Documentation/core-api/printk-formats.rst Flags bitfields such as page flags, gfp_flags · line 541
Quoted 2 lines
Documentation/core-api/printk-formats.rst +1
-1- %pGp referenced|uptodate|lru|active|private + %pGp Node 0,Zone 2,referenced|uptodate|lru|active|privateSince of the nature of
printf()buffer, I wonder if these should be at the end. I.o.w. the question is is the added material more important to user to see than the existed one?Quoted 5 lines
The existing one should be more important than the added one. But the order of output will not match with the value for
page->flags. E.g.flags=0x17ffffc0010200(slab|head,Node 0,Zone 2,Lastcpupid 0x1fffff)It may be strange to compare the value with the string.
More I'm looking at it, more I'm thinking it should have different specifiers for each group of desired flags to be printed.
So, you leave %pGp as is and then add another letter to add more details, so user will choose what and in which order they want.
Quoted 7 lines
For example, let's assume %pGp == %pGpf and P is a new specifier for what you are initially adding here:
%pGpfP => referenced|uptodate|lru|active|private,Node 0,Zone 2 %pGpPf => Node 0,Zone 2,referenced|uptodate|lru|active|private
and so on.
Thanks for your suggestion. I will think about it.
Signature · 2 lines
Thanks Yafang
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
In reply to Yafang ShaoQuoted 5 lines · Yafang Shao
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)
I would suggest it will be easier to parse as:
flags=0x17ffffc0010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff)
That should alleviate the concerns about debugfs format change -- we've never guaranteed that flag names won't change, and they now look enough like flags that parsers shouldn't fall over them.
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 8 lines · Matthew Wilcox
Quoted 5 lines · Yafang Shao
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)
Quoted 7 lines
I would suggest it will be easier to parse as:
flags=0x17ffffc0010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff)
That should alleviate the concerns about debugfs format change -- we've never guaranteed that flag names won't change, and they now look enough like flags that parsers shouldn't fall over them.
Good suggestion!
I will do it as you suggested in the next version.
Signature · 2 lines
Thanks Yafang
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
In reply to Matthew WilcoxQuoted 7 lines · Matthew Wilcox
Quoted 5 lines · Yafang Shao
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)
Quoted 7 lines
I would suggest it will be easier to parse as:
flags=0x17ffffc0010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff)
That should alleviate the concerns about debugfs format change -- we've never guaranteed that flag names won't change, and they now look enough like flags that parsers shouldn't fall over them.
Seems sensible and would make the generating code simpler too.
But is it worth the vsprintf code expansion for the 5 current uses?
mm/debug.c: pr_warn("%sflags: %#lx(%pGp)%s\n", type, head->flags, &head->flags,
mm/memory-failure.c: pr_info("soft offline: %#lx: %s migration failed %d, type %lx (%pGp)\n",
mm/memory-failure.c: pr_info("soft offline: %#lx: %s isolation failed, page count %d, type %lx (%pGp)\n",
mm/memory-failure.c: pr_info("%s: %#lx: unknown page type: %lx (%pGp)\n",
mm/page_owner.c: "PFN %lu type %s Block %lu type %s Flags %#lx(%pGp)\n",Wouldn't it be more sensible just to put this code in a new function call in mm?
Re: [PATCH v2 3/3] vsprintf: dump full information of page flags in pGp
Quoted 20 lines · Joe Perches
Quoted 7 lines · Matthew Wilcox
Quoted 5 lines · Yafang Shao
- Before the patch,
[ 6343.396602] Slab 0x000000004382e02b objects=33 used=3 fp=0x000000009ae06ffc flags=0x17ffffc0010200(slab|head)- After the patch,
[ 6871.296131] Slab 0x00000000c0e19a37 objects=33 used=3 fp=0x00000000c4902159 flags=0x17ffffc0010200(Node 0,Zone 2,Lastcpupid 0x1fffff,slab|head)Quoted 7 lines
I would suggest it will be easier to parse as:
flags=0x17ffffc0010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff)
That should alleviate the concerns about debugfs format change -- we've never guaranteed that flag names won't change, and they now look enough like flags that parsers shouldn't fall over them.
Seems sensible and would make the generating code simpler too.
But is it worth the vsprintf code expansion for the 5 current uses?
Quoted 8 lines
mm/debug.c: pr_warn("%sflags: %#lx(%pGp)%s\n", type, head->flags, &head->flags, mm/memory-failure.c: pr_info("soft offline: %#lx: %s migration failed %d, type %lx (%pGp)\n", mm/memory-failure.c: pr_info("soft offline: %#lx: %s isolation failed, page count %d, type %lx (%pGp)\n", mm/memory-failure.c: pr_info("%s: %#lx: unknown page type: %lx (%pGp)\n", mm/page_owner.c: "PFN %lu type %s Block %lu type %s Flags %#lx(%pGp)\n",Wouldn't it be more sensible just to put this code in a new function call in mm?
Does it matter whether the code lives in vsprintf.c or mm/debug.c? It's built into the kernel core either way. I'm not a huge fan of the current way %pFoo is handled, but unless/until it's drastically revised, I don't think this proposed patch makes anything worse.