mbox series

[v3,0/3] mm, vsprintf: introduce new format to dump full information of page flags

Message ID 20210208101439.55474-1-laoar.shao@gmail.com (mailing list archive)
Headers show
Series mm, vsprintf: introduce new format to dump full information of page flags | expand

Message

Yafang Shao Feb. 8, 2021, 10:14 a.m. UTC
The existed pGp shows the names of page flags only, rather than the full
information including section, node, zone, last cpuipid and kasan tag.
While it is not easy to parse these information manually because there
are so many flavors. We'd better interpret them in printf.

To avoid breaking some tools which parsing pGp via debugfs or affecting
the printf buffer, other new formats are introduced, so the user can choose
what and in which order they want, suggested by Andy. These new introduced
format as follows,
    pGpb: print other information first and then the names of page flags
    pGpl: print the names of page flags first and then the other info

The differece between them looks like the difference between big-endian and
little-endian, that's why they are named like that. The examples of the
output as follows,
    %pGpb 0x17ffffc0010200(node=0|zone=2|lastcpupid=0x1fffff|slab|head)
    %pGpl 0x17ffffc0010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff)

To be compitable with the existed format of pGp, the new introduced ones
also use '|' as the separator, then the user tools parsing pGp won't
need to make change, suggested by Matthew.

The doc and test cases are also updated. Below is the output of the
test cases,
[ 4299.847655] test_printf: loaded.
[ 4299.848301] test_printf: all 404 tests passed
[ 4299.850371] test_printf: unloaded.

This patchset also includes some code cleanup in mm/slub.c.

v3:
- coding improvement, per Joe and Andy
- the possible impact on debugfs and the fix of it, per Joe and Matthew
- introduce new format instead of changing pGp, per Andy

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: introduce new format to dump full information of page flags

 Documentation/core-api/printk-formats.rst |   2 +
 lib/test_printf.c                         | 126 +++++++++++++++++++---
 lib/vsprintf.c                            | 115 +++++++++++++++++++-
 mm/slub.c                                 |  13 +--
 4 files changed, 233 insertions(+), 23 deletions(-)

Comments

Matthew Wilcox Feb. 8, 2021, 12:20 p.m. UTC | #1
On Mon, Feb 08, 2021 at 06:14:36PM +0800, Yafang Shao wrote:
> To avoid breaking some tools which parsing pGp via debugfs or affecting
> the printf buffer, other new formats are introduced, so the user can choose
> what and in which order they want, suggested by Andy. These new introduced
> format as follows,
>     pGpb: print other information first and then the names of page flags
>     pGpl: print the names of page flags first and then the other info

This is overengineering things.  We already print in little-endian order,
and the other information should be tacked onto the end.  Just extend
%pGp.  Andy's suggestion to add another flag was a bad one.
Andy Shevchenko Feb. 8, 2021, 1:25 p.m. UTC | #2
On Mon, Feb 8, 2021 at 2:37 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Mon, Feb 08, 2021 at 06:14:36PM +0800, Yafang Shao wrote:
> > To avoid breaking some tools which parsing pGp via debugfs or affecting
> > the printf buffer, other new formats are introduced, so the user can choose
> > what and in which order they want, suggested by Andy. These new introduced
> > format as follows,
> >     pGpb: print other information first and then the names of page flags
> >     pGpl: print the names of page flags first and then the other info
>
> This is overengineering things.  We already print in little-endian order,
> and the other information should be tacked onto the end.  Just extend
> %pGp.  Andy's suggestion to add another flag was a bad one.

Fair enough, I can admit this because I don't know the mm specifics.
However, my initial point was about the long message which might be
cut into pieces during Oops or whatever and the user will get the
first parts only.  Depends on what you consider as a higher priority
to print the order might be different. Initial patch suggested to
print the new fields first.
Yafang Shao Feb. 8, 2021, 2:02 p.m. UTC | #3
On Mon, Feb 8, 2021 at 8:20 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Mon, Feb 08, 2021 at 06:14:36PM +0800, Yafang Shao wrote:
> > To avoid breaking some tools which parsing pGp via debugfs or affecting
> > the printf buffer, other new formats are introduced, so the user can choose
> > what and in which order they want, suggested by Andy. These new introduced
> > format as follows,
> >     pGpb: print other information first and then the names of page flags
> >     pGpl: print the names of page flags first and then the other info
>
> This is overengineering things.  We already print in little-endian order,
> and the other information should be tacked onto the end.  Just extend
> %pGp.  Andy's suggestion to add another flag was a bad one.
>

All right. I will do it in the next version.