Commit e26fcc02 authored by Hyeonggon Yoo's avatar Hyeonggon Yoo Committed by Andrew Morton

mmflags.h: use less error prone method to define pageflag_names

Patch series "mm, printk: introduce new format for page_type", v4.

This series moves PG_slab page flag to page_type, freeing one bit in
page->flags and introduces %pGt format that prints human-readable
page_type like %pGp for printing page flags.

See changelog of patch 2 for more implementation details.

Thanks everyone that gave valuable comments.


This patch (of 3):

Use helper macro to decrease chances of typo when defining pageflag_names.

Link: https://lkml.kernel.org/r/20230130042514.2418-1-42.hyeyoo@gmail.com
Link: https://lore.kernel.org/lkml/Y6AycLbpjVzXM5I9@smile.fi.intel.com
Link: https://lkml.kernel.org/r/20230130042514.2418-2-42.hyeyoo@gmail.comSigned-off-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
Suggested-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: John Ogness <john.ogness@linutronix.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 739100c8
...@@ -67,71 +67,74 @@ ...@@ -67,71 +67,74 @@
) : "none" ) : "none"
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
#define IF_HAVE_PG_MLOCK(flag,string) ,{1UL << flag, string} #define IF_HAVE_PG_MLOCK(_name) ,{1UL << PG_##_name, __stringify(_name)}
#else #else
#define IF_HAVE_PG_MLOCK(flag,string) #define IF_HAVE_PG_MLOCK(_name)
#endif #endif
#ifdef CONFIG_ARCH_USES_PG_UNCACHED #ifdef CONFIG_ARCH_USES_PG_UNCACHED
#define IF_HAVE_PG_UNCACHED(flag,string) ,{1UL << flag, string} #define IF_HAVE_PG_UNCACHED(_name) ,{1UL << PG_##_name, __stringify(_name)}
#else #else
#define IF_HAVE_PG_UNCACHED(flag,string) #define IF_HAVE_PG_UNCACHED(_name)
#endif #endif
#ifdef CONFIG_MEMORY_FAILURE #ifdef CONFIG_MEMORY_FAILURE
#define IF_HAVE_PG_HWPOISON(flag,string) ,{1UL << flag, string} #define IF_HAVE_PG_HWPOISON(_name) ,{1UL << PG_##_name, __stringify(_name)}
#else #else
#define IF_HAVE_PG_HWPOISON(flag,string) #define IF_HAVE_PG_HWPOISON(_name)
#endif #endif
#if defined(CONFIG_PAGE_IDLE_FLAG) && defined(CONFIG_64BIT) #if defined(CONFIG_PAGE_IDLE_FLAG) && defined(CONFIG_64BIT)
#define IF_HAVE_PG_IDLE(flag,string) ,{1UL << flag, string} #define IF_HAVE_PG_IDLE(_name) ,{1UL << PG_##_name, __stringify(_name)}
#else #else
#define IF_HAVE_PG_IDLE(flag,string) #define IF_HAVE_PG_IDLE(_name)
#endif #endif
#ifdef CONFIG_ARCH_USES_PG_ARCH_X #ifdef CONFIG_ARCH_USES_PG_ARCH_X
#define IF_HAVE_PG_ARCH_X(flag,string) ,{1UL << flag, string} #define IF_HAVE_PG_ARCH_X(_name) ,{1UL << PG_##_name, __stringify(_name)}
#else #else
#define IF_HAVE_PG_ARCH_X(flag,string) #define IF_HAVE_PG_ARCH_X(_name)
#endif #endif
#ifdef CONFIG_KASAN_HW_TAGS #ifdef CONFIG_KASAN_HW_TAGS
#define IF_HAVE_PG_SKIP_KASAN_POISON(flag,string) ,{1UL << flag, string} #define IF_HAVE_PG_SKIP_KASAN_POISON(_name) \
,{1UL << PG_##_name, __stringify(_name)}
#else #else
#define IF_HAVE_PG_SKIP_KASAN_POISON(flag,string) #define IF_HAVE_PG_SKIP_KASAN_POISON(_name)
#endif #endif
#define DEF_PAGEFLAG_NAME(_name) { 1UL << PG_##_name, __stringify(_name) }
#define __def_pageflag_names \ #define __def_pageflag_names \
{1UL << PG_locked, "locked" }, \ DEF_PAGEFLAG_NAME(locked), \
{1UL << PG_waiters, "waiters" }, \ DEF_PAGEFLAG_NAME(waiters), \
{1UL << PG_error, "error" }, \ DEF_PAGEFLAG_NAME(error), \
{1UL << PG_referenced, "referenced" }, \ DEF_PAGEFLAG_NAME(referenced), \
{1UL << PG_uptodate, "uptodate" }, \ DEF_PAGEFLAG_NAME(uptodate), \
{1UL << PG_dirty, "dirty" }, \ DEF_PAGEFLAG_NAME(dirty), \
{1UL << PG_lru, "lru" }, \ DEF_PAGEFLAG_NAME(lru), \
{1UL << PG_active, "active" }, \ DEF_PAGEFLAG_NAME(active), \
{1UL << PG_workingset, "workingset" }, \ DEF_PAGEFLAG_NAME(workingset), \
{1UL << PG_slab, "slab" }, \ DEF_PAGEFLAG_NAME(slab), \
{1UL << PG_owner_priv_1, "owner_priv_1" }, \ DEF_PAGEFLAG_NAME(owner_priv_1), \
{1UL << PG_arch_1, "arch_1" }, \ DEF_PAGEFLAG_NAME(arch_1), \
{1UL << PG_reserved, "reserved" }, \ DEF_PAGEFLAG_NAME(reserved), \
{1UL << PG_private, "private" }, \ DEF_PAGEFLAG_NAME(private), \
{1UL << PG_private_2, "private_2" }, \ DEF_PAGEFLAG_NAME(private_2), \
{1UL << PG_writeback, "writeback" }, \ DEF_PAGEFLAG_NAME(writeback), \
{1UL << PG_head, "head" }, \ DEF_PAGEFLAG_NAME(head), \
{1UL << PG_mappedtodisk, "mappedtodisk" }, \ DEF_PAGEFLAG_NAME(mappedtodisk), \
{1UL << PG_reclaim, "reclaim" }, \ DEF_PAGEFLAG_NAME(reclaim), \
{1UL << PG_swapbacked, "swapbacked" }, \ DEF_PAGEFLAG_NAME(swapbacked), \
{1UL << PG_unevictable, "unevictable" } \ DEF_PAGEFLAG_NAME(unevictable) \
IF_HAVE_PG_MLOCK(PG_mlocked, "mlocked" ) \ IF_HAVE_PG_MLOCK(mlocked) \
IF_HAVE_PG_UNCACHED(PG_uncached, "uncached" ) \ IF_HAVE_PG_UNCACHED(uncached) \
IF_HAVE_PG_HWPOISON(PG_hwpoison, "hwpoison" ) \ IF_HAVE_PG_HWPOISON(hwpoison) \
IF_HAVE_PG_IDLE(PG_young, "young" ) \ IF_HAVE_PG_IDLE(idle) \
IF_HAVE_PG_IDLE(PG_idle, "idle" ) \ IF_HAVE_PG_IDLE(young) \
IF_HAVE_PG_ARCH_X(PG_arch_2, "arch_2" ) \ IF_HAVE_PG_ARCH_X(arch_2) \
IF_HAVE_PG_ARCH_X(PG_arch_3, "arch_3" ) \ IF_HAVE_PG_ARCH_X(arch_3) \
IF_HAVE_PG_SKIP_KASAN_POISON(PG_skip_kasan_poison, "skip_kasan_poison") IF_HAVE_PG_SKIP_KASAN_POISON(skip_kasan_poison)
#define show_page_flags(flags) \ #define show_page_flags(flags) \
(flags) ? __print_flags(flags, "|", \ (flags) ? __print_flags(flags, "|", \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment