diff mbox series

[mm-unstable,v4,1/3] mmflags.h: use less error prone method to define pageflag_names

Message ID 20230130042514.2418-2-42.hyeyoo@gmail.com (mailing list archive)
State New
Headers show
Series mm, printk: introduce new format for page_type | expand

Commit Message

Hyeonggon Yoo Jan. 30, 2023, 4:25 a.m. UTC
As suggested by Andy Shevchenko, use helper macro to decrease chances
of typo when defining pageflag_names.

Link: https://lore.kernel.org/lkml/Y6AycLbpjVzXM5I9@smile.fi.intel.com
Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
---
 include/trace/events/mmflags.h | 85 ++++++++++++++++++----------------
 1 file changed, 44 insertions(+), 41 deletions(-)

Comments

Andy Shevchenko Jan. 30, 2023, 12:35 p.m. UTC | #1
On Mon, Jan 30, 2023 at 01:25:12PM +0900, Hyeonggon Yoo wrote:
> As suggested by Andy Shevchenko, use helper macro to decrease chances
> of typo when defining pageflag_names.

Suggested-by: ? :-)

> Link: https://lore.kernel.org/lkml/Y6AycLbpjVzXM5I9@smile.fi.intel.com
> Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>

LGTM, thank you!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Hyeonggon Yoo Jan. 31, 2023, 8:38 a.m. UTC | #2
On Mon, Jan 30, 2023 at 02:35:52PM +0200, Andy Shevchenko wrote:
> On Mon, Jan 30, 2023 at 01:25:12PM +0900, Hyeonggon Yoo wrote:
> > As suggested by Andy Shevchenko, use helper macro to decrease chances
> > of typo when defining pageflag_names.
> 
> Suggested-by: ? :-)

oh, yeah I only wrote in changelog forgot to add the tag.
I think Andrew will kindly add that when picking this series up?

> > Link: https://lore.kernel.org/lkml/Y6AycLbpjVzXM5I9@smile.fi.intel.com
> > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> 
> LGTM, thank you!
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thank you a lot!

> -- 
> With Best Regards,
> Andy Shevchenko

Best Regards,
Hyeonggon
Andrew Morton Jan. 31, 2023, 9:09 p.m. UTC | #3
On Tue, 31 Jan 2023 17:38:02 +0900 Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote:

> On Mon, Jan 30, 2023 at 02:35:52PM +0200, Andy Shevchenko wrote:
> > On Mon, Jan 30, 2023 at 01:25:12PM +0900, Hyeonggon Yoo wrote:
> > > As suggested by Andy Shevchenko, use helper macro to decrease chances
> > > of typo when defining pageflag_names.
> > 
> > Suggested-by: ? :-)
> 
> oh, yeah I only wrote in changelog forgot to add the tag.
> I think Andrew will kindly add that when picking this series up?

Sure.

We're at -rc6 so I'm slowing down on the features and cleanups.  I'll
probably park this series for the next -rc cycle.
Hyeonggon Yoo Feb. 1, 2023, 12:14 p.m. UTC | #4
On Tue, Jan 31, 2023 at 01:09:40PM -0800, Andrew Morton wrote:
> On Tue, 31 Jan 2023 17:38:02 +0900 Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote:
> 
> > On Mon, Jan 30, 2023 at 02:35:52PM +0200, Andy Shevchenko wrote:
> > > On Mon, Jan 30, 2023 at 01:25:12PM +0900, Hyeonggon Yoo wrote:
> > > > As suggested by Andy Shevchenko, use helper macro to decrease chances
> > > > of typo when defining pageflag_names.
> > > 
> > > Suggested-by: ? :-)
> > 
> > oh, yeah I only wrote in changelog forgot to add the tag.
> > I think Andrew will kindly add that when picking this series up?
> 
> Sure.

Thanks ;)

> We're at -rc6 so I'm slowing down on the features and cleanups.  I'll
> probably park this series for the next -rc cycle.

No problem!
diff mbox series

Patch

diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index 9db52bc4ce19..f453babe29b3 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -67,71 +67,74 @@ 
 	) : "none"
 
 #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
-#define IF_HAVE_PG_MLOCK(flag,string)
+#define IF_HAVE_PG_MLOCK(_name)
 #endif
 
 #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
-#define IF_HAVE_PG_UNCACHED(flag,string)
+#define IF_HAVE_PG_UNCACHED(_name)
 #endif
 
 #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
-#define IF_HAVE_PG_HWPOISON(flag,string)
+#define IF_HAVE_PG_HWPOISON(_name)
 #endif
 
 #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
-#define IF_HAVE_PG_IDLE(flag,string)
+#define IF_HAVE_PG_IDLE(_name)
 #endif
 
 #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
-#define IF_HAVE_PG_ARCH_X(flag,string)
+#define IF_HAVE_PG_ARCH_X(_name)
 #endif
 
 #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
-#define IF_HAVE_PG_SKIP_KASAN_POISON(flag,string)
+#define IF_HAVE_PG_SKIP_KASAN_POISON(_name)
 #endif
 
+#define DEF_PAGEFLAG_NAME(_name) { 1UL <<  PG_##_name, __stringify(_name) }
+
 #define __def_pageflag_names						\
-	{1UL << PG_locked,		"locked"	},		\
-	{1UL << PG_waiters,		"waiters"	},		\
-	{1UL << PG_error,		"error"		},		\
-	{1UL << PG_referenced,		"referenced"	},		\
-	{1UL << PG_uptodate,		"uptodate"	},		\
-	{1UL << PG_dirty,		"dirty"		},		\
-	{1UL << PG_lru,			"lru"		},		\
-	{1UL << PG_active,		"active"	},		\
-	{1UL << PG_workingset,		"workingset"	},		\
-	{1UL << PG_slab,		"slab"		},		\
-	{1UL << PG_owner_priv_1,	"owner_priv_1"	},		\
-	{1UL << PG_arch_1,		"arch_1"	},		\
-	{1UL << PG_reserved,		"reserved"	},		\
-	{1UL << PG_private,		"private"	},		\
-	{1UL << PG_private_2,		"private_2"	},		\
-	{1UL << PG_writeback,		"writeback"	},		\
-	{1UL << PG_head,		"head"		},		\
-	{1UL << PG_mappedtodisk,	"mappedtodisk"	},		\
-	{1UL << PG_reclaim,		"reclaim"	},		\
-	{1UL << PG_swapbacked,		"swapbacked"	},		\
-	{1UL << PG_unevictable,		"unevictable"	}		\
-IF_HAVE_PG_MLOCK(PG_mlocked,		"mlocked"	)		\
-IF_HAVE_PG_UNCACHED(PG_uncached,	"uncached"	)		\
-IF_HAVE_PG_HWPOISON(PG_hwpoison,	"hwpoison"	)		\
-IF_HAVE_PG_IDLE(PG_young,		"young"		)		\
-IF_HAVE_PG_IDLE(PG_idle,		"idle"		)		\
-IF_HAVE_PG_ARCH_X(PG_arch_2,		"arch_2"	)		\
-IF_HAVE_PG_ARCH_X(PG_arch_3,		"arch_3"	)		\
-IF_HAVE_PG_SKIP_KASAN_POISON(PG_skip_kasan_poison, "skip_kasan_poison")
+	DEF_PAGEFLAG_NAME(locked),					\
+	DEF_PAGEFLAG_NAME(waiters),					\
+	DEF_PAGEFLAG_NAME(error),					\
+	DEF_PAGEFLAG_NAME(referenced),					\
+	DEF_PAGEFLAG_NAME(uptodate),					\
+	DEF_PAGEFLAG_NAME(dirty),					\
+	DEF_PAGEFLAG_NAME(lru),						\
+	DEF_PAGEFLAG_NAME(active),					\
+	DEF_PAGEFLAG_NAME(workingset),					\
+	DEF_PAGEFLAG_NAME(slab),					\
+	DEF_PAGEFLAG_NAME(owner_priv_1),				\
+	DEF_PAGEFLAG_NAME(arch_1),					\
+	DEF_PAGEFLAG_NAME(reserved),					\
+	DEF_PAGEFLAG_NAME(private),					\
+	DEF_PAGEFLAG_NAME(private_2),					\
+	DEF_PAGEFLAG_NAME(writeback),					\
+	DEF_PAGEFLAG_NAME(head),					\
+	DEF_PAGEFLAG_NAME(mappedtodisk),				\
+	DEF_PAGEFLAG_NAME(reclaim),					\
+	DEF_PAGEFLAG_NAME(swapbacked),					\
+	DEF_PAGEFLAG_NAME(unevictable)					\
+IF_HAVE_PG_MLOCK(mlocked)						\
+IF_HAVE_PG_UNCACHED(uncached)						\
+IF_HAVE_PG_HWPOISON(hwpoison)						\
+IF_HAVE_PG_IDLE(idle)							\
+IF_HAVE_PG_IDLE(young)							\
+IF_HAVE_PG_ARCH_X(arch_2)						\
+IF_HAVE_PG_ARCH_X(arch_3)						\
+IF_HAVE_PG_SKIP_KASAN_POISON(skip_kasan_poison)
 
 #define show_page_flags(flags)						\
 	(flags) ? __print_flags(flags, "|",				\