Skip to content

Commit ca29a0b

Browse files
committed
tracing: gfp: Remove duplication of recording GFP flags
The gfp_flags when recorded in the trace require being converted from their numbers to values. Various macros are used to help facilitate this, but there's two sets of macros that need to keep track of the same GFP flags to stay in sync. Commit 60295b9 ("tracing: gfp: Fix the GFP enum values shown for user space tracing tools") added a TRACE_GFP_FLAGS macro that holds the enum ___GFP_*_BIT defined bits, and creates the TRACE_DEFINE_ENUM() wrapper around them. The __def_gfpflag_names() macro creates the mapping of various flags or multiple flags to give them human readable names via the __print_flags() tracing helper macro. As the TRACE_GFP_FLAGS is a subset of the __def_gfpflags_names(), it can be used to cover the individual bit names, by redefining the internal macro TRACE_GFP_EM(): #undef TRACE_GFP_EM #define TRACE_GFP_EM(a) gfpflag_string(__GFP_##a), This will remove the bits that are duplicate between the two macros. If a new bit is created, only the TRACE_GFP_FLAGS needs to be updated and that will also update the __def_gfpflags_names() macro. Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Veronika Molnarova <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 35b9818 commit ca29a0b

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

include/trace/events/mmflags.h

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ TRACE_DEFINE_ENUM(___GFP_LAST_BIT);
7878

7979
#define gfpflag_string(flag) {(__force unsigned long)flag, #flag}
8080

81+
/*
82+
* For the values that match the bits, use the TRACE_GFP_FLAGS
83+
* which will allow any updates to be included automatically.
84+
*/
85+
#undef TRACE_GFP_EM
86+
#define TRACE_GFP_EM(a) gfpflag_string(__GFP_##a),
87+
8188
#define __def_gfpflag_names \
8289
gfpflag_string(GFP_TRANSHUGE), \
8390
gfpflag_string(GFP_TRANSHUGE_LIGHT), \
@@ -91,41 +98,13 @@ TRACE_DEFINE_ENUM(___GFP_LAST_BIT);
9198
gfpflag_string(GFP_NOIO), \
9299
gfpflag_string(GFP_NOWAIT), \
93100
gfpflag_string(GFP_DMA), \
94-
gfpflag_string(__GFP_HIGHMEM), \
95101
gfpflag_string(GFP_DMA32), \
96-
gfpflag_string(__GFP_HIGH), \
97-
gfpflag_string(__GFP_IO), \
98-
gfpflag_string(__GFP_FS), \
99-
gfpflag_string(__GFP_NOWARN), \
100-
gfpflag_string(__GFP_RETRY_MAYFAIL), \
101-
gfpflag_string(__GFP_NOFAIL), \
102-
gfpflag_string(__GFP_NORETRY), \
103-
gfpflag_string(__GFP_COMP), \
104-
gfpflag_string(__GFP_ZERO), \
105-
gfpflag_string(__GFP_NOMEMALLOC), \
106-
gfpflag_string(__GFP_MEMALLOC), \
107-
gfpflag_string(__GFP_HARDWALL), \
108-
gfpflag_string(__GFP_THISNODE), \
109-
gfpflag_string(__GFP_RECLAIMABLE), \
110-
gfpflag_string(__GFP_MOVABLE), \
111-
gfpflag_string(__GFP_ACCOUNT), \
112-
gfpflag_string(__GFP_WRITE), \
113102
gfpflag_string(__GFP_RECLAIM), \
114-
gfpflag_string(__GFP_DIRECT_RECLAIM), \
115-
gfpflag_string(__GFP_KSWAPD_RECLAIM), \
116-
gfpflag_string(__GFP_ZEROTAGS)
117-
118-
#ifdef CONFIG_KASAN_HW_TAGS
119-
#define __def_gfpflag_names_kasan , \
120-
gfpflag_string(__GFP_SKIP_ZERO), \
121-
gfpflag_string(__GFP_SKIP_KASAN)
122-
#else
123-
#define __def_gfpflag_names_kasan
124-
#endif
103+
TRACE_GFP_FLAGS \
104+
{ 0, "none" }
125105

126106
#define show_gfp_flags(flags) \
127-
(flags) ? __print_flags(flags, "|", \
128-
__def_gfpflag_names __def_gfpflag_names_kasan \
107+
(flags) ? __print_flags(flags, "|", __def_gfpflag_names \
129108
) : "none"
130109

131110
#ifdef CONFIG_MMU

0 commit comments

Comments
 (0)