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

From: Yafang Shao
Date: Mon Feb 08 2021 - 05:29:37 EST


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(-)

--
2.17.1