lkml.org 
[lkml]   [2022]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2022-12-19 10:45    [W:0.149 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site