Re: [RFC v3 3/4] mm, printk: introduce new format %pGt for page_type

Hyeonggon Yoo
2022-12-29T13:31:09Z

On Tue, Dec 20, 2022 at 04:20:26PM +0100, Petr Mladek wrote:
> On Sun 2022-12-18 19:19:00, Hyeonggon Yoo wrote:
> > %pGp format is used to print 'flags' field of struct page.
> > As some page flags (e.g. PG_buddy, see page-flags.h for more details)
> > are set in page_type field, introduce %pGt format which provides
> > human readable output of page_type.
> >
> > Note that the sense of bits are different in page_type. if page_type is
> > 0xffffffff, no flags are set. if PG_slab (0x00100000) flag is set,
> > page_type is 0xffefffff. Clearing a bit means we set the bit.
> >
> > Bits in page_type are inverted when printing page type names.
> >
> > --- a/Documentation/core-api/printk-formats.rst
> > +++ b/Documentation/core-api/printk-formats.rst
> > @@ -575,12 +575,13 @@ The field width is passed by value, the bitmap is passed by reference.
> > Helper macros cpumask_pr_args() and nodemask_pr_args() are available to ease
> > printing cpumask and nodemask.
> >
> > -Flags bitfields such as page flags, gfp_flags
> > +Flags bitfields such as page flags, page_type, gfp_flags
> > ---------------------------------------------
>
> Please, underline the entire title. Otherwise, "make htmldoc"
> complains ;-)
>
> /prace/kernel/linux/Documentation/core-api/printk-formats.rst:579: WARNING: Title underline too short.
> Flags bitfields such as page flags, page_type, gfp_flags

Still not getting used to rst format ;)
Will fix, thanks!

>
>
> >
> > ::
> >
> > %pGp 0x17ffffc0002036(referenced|uptodate|lru|active|private|node=0|zone=2|lastcpupid=0x1fffff)
> > + %pGt 0xffefffff(slab)
> > %pGg GFP_USER|GFP_DMA32|GFP_NOWARN
> > %pGv read|exec|mayread|maywrite|mayexec|denywrite
> >
>
> Please, explain this also in the paragraph below these examples.
> I would personally refactor it to an itemized list, something like:
>
> <proposal>
> For printing flags bitfields as a collection of symbolic constants that
> would construct the value. The type of flags is given by the third
> character. Currently supported are:
>
> - p - [p]age flags, expects value of type (``unsigned long *``)
> - t - page [t]ype, expects value of type (``unsigned int *``)
> - v - [v]ma_flags, expects value of type (``unsigned long *``)
> - g - [g]fp_flags, expects value of type (``gfp_t *``)
>
> The flag names and print order depends on the particular type.
> </proposal>

The proposal sounds reasonable to me,
will adjust in next version.

> Rant:
> Sigh, it looks a bit error prone when similar pointer modifiers
> expects pointers to different types. I wish there was a way how
> to check the passed pointer type at compilation time. But it
> is generic problem with these %p* modifiers.

From my limited knowledge, it seems that there is no way to check
this :/

>
> Otherwise the patch looks fine for the vsprinf side.

Thank you for looking at this!

>
> Best Regards,
> Petr

--
Thanks,
Hyeonggon