Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Use explicit array size instead of sentinel elements in symbol printing

The sentinel value added by the wrapper macros __print_symbolic() et al
prevents the callers from adding their own trailing comma. This makes
constructing symbol list dynamically based on kconfig values tedious.

Drop the sentinel elements, so callers can either specify the trailing
comma or not, just like in regular array initializers.

Signed-off-by: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260311-hrtimer-cleanups-v1-2-095357392669@linutronix.de

authored by

Thomas Weißschuh (Schneider Electric) and committed by
Thomas Gleixner
754e38d2 5aa93838

+43 -37
+8 -5
include/linux/trace_events.h
··· 22 22 23 23 const char *trace_print_flags_seq(struct trace_seq *p, const char *delim, 24 24 unsigned long flags, 25 - const struct trace_print_flags *flag_array); 25 + const struct trace_print_flags *flag_array, 26 + size_t flag_array_size); 26 27 27 28 const char *trace_print_symbols_seq(struct trace_seq *p, unsigned long val, 28 - const struct trace_print_flags *symbol_array); 29 + const struct trace_print_flags *symbol_array, 30 + size_t symbol_array_size); 29 31 30 32 #if BITS_PER_LONG == 32 31 33 const char *trace_print_flags_seq_u64(struct trace_seq *p, const char *delim, 32 34 unsigned long long flags, 33 - const struct trace_print_flags_u64 *flag_array); 35 + const struct trace_print_flags_u64 *flag_array, 36 + size_t flag_array_size); 34 37 35 38 const char *trace_print_symbols_seq_u64(struct trace_seq *p, 36 39 unsigned long long val, 37 - const struct trace_print_flags_u64 38 - *symbol_array); 40 + const struct trace_print_flags_u64 *symbol_array, 41 + size_t symbol_array_size); 39 42 #endif 40 43 41 44 struct trace_iterator;
+20 -20
include/trace/stages/stage3_trace_output.h
··· 64 64 #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) 65 65 66 66 #undef __print_flags 67 - #define __print_flags(flag, delim, flag_array...) \ 68 - ({ \ 69 - static const struct trace_print_flags __flags[] = \ 70 - { flag_array, { -1, NULL }}; \ 71 - trace_print_flags_seq(p, delim, flag, __flags); \ 67 + #define __print_flags(flag, delim, flag_array...) \ 68 + ({ \ 69 + static const struct trace_print_flags __flags[] = \ 70 + { flag_array }; \ 71 + trace_print_flags_seq(p, delim, flag, __flags, ARRAY_SIZE(__flags)); \ 72 72 }) 73 73 74 74 #undef __print_symbolic 75 - #define __print_symbolic(value, symbol_array...) \ 76 - ({ \ 77 - static const struct trace_print_flags symbols[] = \ 78 - { symbol_array, { -1, NULL }}; \ 79 - trace_print_symbols_seq(p, value, symbols); \ 75 + #define __print_symbolic(value, symbol_array...) \ 76 + ({ \ 77 + static const struct trace_print_flags symbols[] = \ 78 + { symbol_array }; \ 79 + trace_print_symbols_seq(p, value, symbols, ARRAY_SIZE(symbols)); \ 80 80 }) 81 81 82 82 #undef __print_flags_u64 83 83 #undef __print_symbolic_u64 84 84 #if BITS_PER_LONG == 32 85 - #define __print_flags_u64(flag, delim, flag_array...) \ 86 - ({ \ 87 - static const struct trace_print_flags_u64 __flags[] = \ 88 - { flag_array, { -1, NULL } }; \ 89 - trace_print_flags_seq_u64(p, delim, flag, __flags); \ 85 + #define __print_flags_u64(flag, delim, flag_array...) \ 86 + ({ \ 87 + static const struct trace_print_flags_u64 __flags[] = \ 88 + { flag_array }; \ 89 + trace_print_flags_seq_u64(p, delim, flag, __flags, ARRAY_SIZE(__flags)); \ 90 90 }) 91 91 92 - #define __print_symbolic_u64(value, symbol_array...) \ 93 - ({ \ 94 - static const struct trace_print_flags_u64 symbols[] = \ 95 - { symbol_array, { -1, NULL } }; \ 96 - trace_print_symbols_seq_u64(p, value, symbols); \ 92 + #define __print_symbolic_u64(value, symbol_array...) \ 93 + ({ \ 94 + static const struct trace_print_flags_u64 symbols[] = \ 95 + { symbol_array }; \ 96 + trace_print_symbols_seq_u64(p, value, symbols, ARRAY_SIZE(symbols)); \ 97 97 }) 98 98 #else 99 99 #define __print_flags_u64(flag, delim, flag_array...) \
+2 -2
kernel/trace/trace_events_synth.c
··· 395 395 n_u64++; 396 396 } else { 397 397 struct trace_print_flags __flags[] = { 398 - __def_gfpflag_names, {-1, NULL} }; 398 + __def_gfpflag_names }; 399 399 char *space = (i == se->n_fields - 1 ? "" : " "); 400 400 401 401 print_synth_event_num_val(s, print_fmt, ··· 408 408 trace_seq_puts(s, " ("); 409 409 trace_print_flags_seq(s, "|", 410 410 entry->fields[n_u64].as_u64, 411 - __flags); 411 + __flags, ARRAY_SIZE(__flags)); 412 412 trace_seq_putc(s, ')'); 413 413 } 414 414 n_u64++;
+12 -8
kernel/trace/trace_output.c
··· 69 69 const char * 70 70 trace_print_flags_seq(struct trace_seq *p, const char *delim, 71 71 unsigned long flags, 72 - const struct trace_print_flags *flag_array) 72 + const struct trace_print_flags *flag_array, 73 + size_t flag_array_size) 73 74 { 74 75 unsigned long mask; 75 76 const char *str; 76 77 const char *ret = trace_seq_buffer_ptr(p); 77 78 int i, first = 1; 78 79 79 - for (i = 0; flag_array[i].name && flags; i++) { 80 + for (i = 0; i < flag_array_size && flags; i++) { 80 81 81 82 mask = flag_array[i].mask; 82 83 if ((flags & mask) != mask) ··· 107 106 108 107 const char * 109 108 trace_print_symbols_seq(struct trace_seq *p, unsigned long val, 110 - const struct trace_print_flags *symbol_array) 109 + const struct trace_print_flags *symbol_array, 110 + size_t symbol_array_size) 111 111 { 112 112 int i; 113 113 const char *ret = trace_seq_buffer_ptr(p); 114 114 115 - for (i = 0; symbol_array[i].name; i++) { 115 + for (i = 0; i < symbol_array_size; i++) { 116 116 117 117 if (val != symbol_array[i].mask) 118 118 continue; ··· 135 133 const char * 136 134 trace_print_flags_seq_u64(struct trace_seq *p, const char *delim, 137 135 unsigned long long flags, 138 - const struct trace_print_flags_u64 *flag_array) 136 + const struct trace_print_flags_u64 *flag_array, 137 + size_t flag_array_size) 139 138 { 140 139 unsigned long long mask; 141 140 const char *str; 142 141 const char *ret = trace_seq_buffer_ptr(p); 143 142 int i, first = 1; 144 143 145 - for (i = 0; flag_array[i].name && flags; i++) { 144 + for (i = 0; i < flag_array_size && flags; i++) { 146 145 147 146 mask = flag_array[i].mask; 148 147 if ((flags & mask) != mask) ··· 173 170 174 171 const char * 175 172 trace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val, 176 - const struct trace_print_flags_u64 *symbol_array) 173 + const struct trace_print_flags_u64 *symbol_array, 174 + size_t symbol_array_size) 177 175 { 178 176 int i; 179 177 const char *ret = trace_seq_buffer_ptr(p); 180 178 181 - for (i = 0; symbol_array[i].name; i++) { 179 + for (i = 0; i < symbol_array_size; i++) { 182 180 183 181 if (val != symbol_array[i].mask) 184 182 continue;
+1 -2
kernel/trace/trace_syscalls.c
··· 174 174 { O_NOFOLLOW, "O_NOFOLLOW" }, 175 175 { O_NOATIME, "O_NOATIME" }, 176 176 { O_CLOEXEC, "O_CLOEXEC" }, 177 - { -1, NULL } 178 177 }; 179 178 180 179 trace_seq_printf(s, "%s(", entry->name); ··· 204 205 trace_seq_puts(s, "O_RDONLY|"); 205 206 } 206 207 207 - trace_print_flags_seq(s, "|", bits, __flags); 208 + trace_print_flags_seq(s, "|", bits, __flags, ARRAY_SIZE(__flags)); 208 209 /* 209 210 * trace_print_flags_seq() adds a '\0' to the 210 211 * buffer, but this needs to append more to the seq.