Messages in this thread | | | Date | Mon, 19 Dec 2022 11:44:16 +0200 | From | Andy Shevchenko <> | Subject | Re: [RFC v3 3/4] mm, printk: introduce new format %pGt for page_type |
| |
On Sun, Dec 18, 2022 at 07:19:00PM +0900, 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.
...
> +#define __def_pagetype_names \ > + {PG_slab, "slab" }, \ > + {PG_offline, "offline" }, \ > + {PG_guard, "guard" }, \ > + {PG_table, "table" }, \ > + {PG_buddy, "buddy" }
Wondering if it will be more robust to define a helper macro
#define DEF_PAGETYPE_NAME(_name) { PG_##_name, __stringify(_name) } ... #undef DEF_PAGETYPE_MASK
In this case it decreases the chances of typo in the strings and flags.
-- With Best Regards, Andy Shevchenko
| |