On Mon, Feb 1, 2021 at 9:05 PM Joe Perches <joe@xxxxxxxxxxx> wrote: > > On Mon, 2021-02-01 at 19:56 +0800, Yafang Shao wrote: > > 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. > Right, the page_owner will be affected by this change. > 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); > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > [] > > +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. > > > + bool separator = false; > > + int i; > > + > > + for (i = 0; i < size; i++) { > > Use ARRAY_SIZE here instead > Sure > for (i = 0; i < ARRAY_SIZE(pfl); i++) { > > > + if (pfl[i].width == 0) > > + continue; > > + > > + if (separator) { > > + if (buf < end) > > + *buf = ','; > > + 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? Good suggestion! I will change it in the next version. > 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. > > buf = string(buf, end, p->name, *p->spec); > buf = number(buf, end, (page_flags >> p->shift) & p->mask, *p->spec); > } > > > + > > + if (flags) { > > Maybe: > > if (page_flags & (BIT(NR_PAGEFLAGS) - 1)) { > Sure. > > + if (buf < end) > > + *buf = ','; > > + buf++; > > + } > > + > > + return buf; > > +} > > + > > -- Thanks Yafang