mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
mm, printk: introduce new format %pGt for page_type
%pGp format is used to display 'flags' field of a struct page. However, some page flags (i.e. PG_buddy, see page-flags.h for more details) are stored in page_type field. To display human-readable output of page_type, introduce %pGt format. It is important to note the meaning of bits are different in page_type. if page_type is 0xffffffff, no flags are set. Setting PG_buddy (0x00000080) flag results in a page_type of 0xffffff7f. Clearing a bit actually means setting a flag. Bits in page_type are inverted when displaying type names. Only values for which page_type_has_type() returns true are considered as page_type, to avoid confusion with mapcount values. if it returns false, only raw values are displayed and not page type names. Link: https://lkml.kernel.org/r/20230130042514.2418-3-42.hyeyoo@gmail.com Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Petr Mladek <pmladek@suse.com> [vsprintf part] Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: David Hildenbrand <david@redhat.com> Cc: Joe Perches <joe@perches.com> Cc: John Ogness <john.ogness@linutronix.de> Cc: Matthew Wilcox <willy@infradead.org> Cc: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Steven Rostedt (Google) <rostedt@goodmis.org> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
e26fcc02c7
commit
4c85c0be3d
@@ -642,12 +642,26 @@ page_flags_test(int section, int node, int zone, int last_cpupid,
|
||||
test(cmp_buf, "%pGp", &flags);
|
||||
}
|
||||
|
||||
static void __init page_type_test(unsigned int page_type, const char *name,
|
||||
char *cmp_buf)
|
||||
{
|
||||
unsigned long size;
|
||||
|
||||
size = scnprintf(cmp_buf, BUF_SIZE, "%#x(", page_type);
|
||||
if (page_type_has_type(page_type))
|
||||
size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s", name);
|
||||
|
||||
snprintf(cmp_buf + size, BUF_SIZE - size, ")");
|
||||
test(cmp_buf, "%pGt", &page_type);
|
||||
}
|
||||
|
||||
static void __init
|
||||
flags(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
char *cmp_buffer;
|
||||
gfp_t gfp;
|
||||
unsigned int page_type;
|
||||
|
||||
cmp_buffer = kmalloc(BUF_SIZE, GFP_KERNEL);
|
||||
if (!cmp_buffer)
|
||||
@@ -687,6 +701,18 @@ flags(void)
|
||||
gfp |= __GFP_HIGH;
|
||||
test(cmp_buffer, "%pGg", &gfp);
|
||||
|
||||
page_type = ~0;
|
||||
page_type_test(page_type, "", cmp_buffer);
|
||||
|
||||
page_type = 10;
|
||||
page_type_test(page_type, "", cmp_buffer);
|
||||
|
||||
page_type = ~PG_buddy;
|
||||
page_type_test(page_type, "buddy", cmp_buffer);
|
||||
|
||||
page_type = ~(PG_table | PG_buddy);
|
||||
page_type_test(page_type, "table|buddy", cmp_buffer);
|
||||
|
||||
kfree(cmp_buffer);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user