mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 02:01:18 -04:00
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
This commit is contained in:
committed by
Thomas Gleixner
parent
5aa9383813
commit
754e38d2d1
@@ -22,20 +22,23 @@ union bpf_attr;
|
||||
|
||||
const char *trace_print_flags_seq(struct trace_seq *p, const char *delim,
|
||||
unsigned long flags,
|
||||
const struct trace_print_flags *flag_array);
|
||||
const struct trace_print_flags *flag_array,
|
||||
size_t flag_array_size);
|
||||
|
||||
const char *trace_print_symbols_seq(struct trace_seq *p, unsigned long val,
|
||||
const struct trace_print_flags *symbol_array);
|
||||
const struct trace_print_flags *symbol_array,
|
||||
size_t symbol_array_size);
|
||||
|
||||
#if BITS_PER_LONG == 32
|
||||
const char *trace_print_flags_seq_u64(struct trace_seq *p, const char *delim,
|
||||
unsigned long long flags,
|
||||
const struct trace_print_flags_u64 *flag_array);
|
||||
const struct trace_print_flags_u64 *flag_array,
|
||||
size_t flag_array_size);
|
||||
|
||||
const char *trace_print_symbols_seq_u64(struct trace_seq *p,
|
||||
unsigned long long val,
|
||||
const struct trace_print_flags_u64
|
||||
*symbol_array);
|
||||
const struct trace_print_flags_u64 *symbol_array,
|
||||
size_t symbol_array_size);
|
||||
#endif
|
||||
|
||||
struct trace_iterator;
|
||||
|
||||
@@ -64,36 +64,36 @@
|
||||
#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
|
||||
|
||||
#undef __print_flags
|
||||
#define __print_flags(flag, delim, flag_array...) \
|
||||
({ \
|
||||
static const struct trace_print_flags __flags[] = \
|
||||
{ flag_array, { -1, NULL }}; \
|
||||
trace_print_flags_seq(p, delim, flag, __flags); \
|
||||
#define __print_flags(flag, delim, flag_array...) \
|
||||
({ \
|
||||
static const struct trace_print_flags __flags[] = \
|
||||
{ flag_array }; \
|
||||
trace_print_flags_seq(p, delim, flag, __flags, ARRAY_SIZE(__flags)); \
|
||||
})
|
||||
|
||||
#undef __print_symbolic
|
||||
#define __print_symbolic(value, symbol_array...) \
|
||||
({ \
|
||||
static const struct trace_print_flags symbols[] = \
|
||||
{ symbol_array, { -1, NULL }}; \
|
||||
trace_print_symbols_seq(p, value, symbols); \
|
||||
#define __print_symbolic(value, symbol_array...) \
|
||||
({ \
|
||||
static const struct trace_print_flags symbols[] = \
|
||||
{ symbol_array }; \
|
||||
trace_print_symbols_seq(p, value, symbols, ARRAY_SIZE(symbols)); \
|
||||
})
|
||||
|
||||
#undef __print_flags_u64
|
||||
#undef __print_symbolic_u64
|
||||
#if BITS_PER_LONG == 32
|
||||
#define __print_flags_u64(flag, delim, flag_array...) \
|
||||
({ \
|
||||
static const struct trace_print_flags_u64 __flags[] = \
|
||||
{ flag_array, { -1, NULL } }; \
|
||||
trace_print_flags_seq_u64(p, delim, flag, __flags); \
|
||||
#define __print_flags_u64(flag, delim, flag_array...) \
|
||||
({ \
|
||||
static const struct trace_print_flags_u64 __flags[] = \
|
||||
{ flag_array }; \
|
||||
trace_print_flags_seq_u64(p, delim, flag, __flags, ARRAY_SIZE(__flags)); \
|
||||
})
|
||||
|
||||
#define __print_symbolic_u64(value, symbol_array...) \
|
||||
({ \
|
||||
static const struct trace_print_flags_u64 symbols[] = \
|
||||
{ symbol_array, { -1, NULL } }; \
|
||||
trace_print_symbols_seq_u64(p, value, symbols); \
|
||||
#define __print_symbolic_u64(value, symbol_array...) \
|
||||
({ \
|
||||
static const struct trace_print_flags_u64 symbols[] = \
|
||||
{ symbol_array }; \
|
||||
trace_print_symbols_seq_u64(p, value, symbols, ARRAY_SIZE(symbols)); \
|
||||
})
|
||||
#else
|
||||
#define __print_flags_u64(flag, delim, flag_array...) \
|
||||
|
||||
@@ -395,7 +395,7 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter,
|
||||
n_u64++;
|
||||
} else {
|
||||
struct trace_print_flags __flags[] = {
|
||||
__def_gfpflag_names, {-1, NULL} };
|
||||
__def_gfpflag_names };
|
||||
char *space = (i == se->n_fields - 1 ? "" : " ");
|
||||
|
||||
print_synth_event_num_val(s, print_fmt,
|
||||
@@ -408,7 +408,7 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter,
|
||||
trace_seq_puts(s, " (");
|
||||
trace_print_flags_seq(s, "|",
|
||||
entry->fields[n_u64].as_u64,
|
||||
__flags);
|
||||
__flags, ARRAY_SIZE(__flags));
|
||||
trace_seq_putc(s, ')');
|
||||
}
|
||||
n_u64++;
|
||||
|
||||
@@ -69,14 +69,15 @@ enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter)
|
||||
const char *
|
||||
trace_print_flags_seq(struct trace_seq *p, const char *delim,
|
||||
unsigned long flags,
|
||||
const struct trace_print_flags *flag_array)
|
||||
const struct trace_print_flags *flag_array,
|
||||
size_t flag_array_size)
|
||||
{
|
||||
unsigned long mask;
|
||||
const char *str;
|
||||
const char *ret = trace_seq_buffer_ptr(p);
|
||||
int i, first = 1;
|
||||
|
||||
for (i = 0; flag_array[i].name && flags; i++) {
|
||||
for (i = 0; i < flag_array_size && flags; i++) {
|
||||
|
||||
mask = flag_array[i].mask;
|
||||
if ((flags & mask) != mask)
|
||||
@@ -106,12 +107,13 @@ EXPORT_SYMBOL(trace_print_flags_seq);
|
||||
|
||||
const char *
|
||||
trace_print_symbols_seq(struct trace_seq *p, unsigned long val,
|
||||
const struct trace_print_flags *symbol_array)
|
||||
const struct trace_print_flags *symbol_array,
|
||||
size_t symbol_array_size)
|
||||
{
|
||||
int i;
|
||||
const char *ret = trace_seq_buffer_ptr(p);
|
||||
|
||||
for (i = 0; symbol_array[i].name; i++) {
|
||||
for (i = 0; i < symbol_array_size; i++) {
|
||||
|
||||
if (val != symbol_array[i].mask)
|
||||
continue;
|
||||
@@ -133,14 +135,15 @@ EXPORT_SYMBOL(trace_print_symbols_seq);
|
||||
const char *
|
||||
trace_print_flags_seq_u64(struct trace_seq *p, const char *delim,
|
||||
unsigned long long flags,
|
||||
const struct trace_print_flags_u64 *flag_array)
|
||||
const struct trace_print_flags_u64 *flag_array,
|
||||
size_t flag_array_size)
|
||||
{
|
||||
unsigned long long mask;
|
||||
const char *str;
|
||||
const char *ret = trace_seq_buffer_ptr(p);
|
||||
int i, first = 1;
|
||||
|
||||
for (i = 0; flag_array[i].name && flags; i++) {
|
||||
for (i = 0; i < flag_array_size && flags; i++) {
|
||||
|
||||
mask = flag_array[i].mask;
|
||||
if ((flags & mask) != mask)
|
||||
@@ -170,12 +173,13 @@ EXPORT_SYMBOL(trace_print_flags_seq_u64);
|
||||
|
||||
const char *
|
||||
trace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val,
|
||||
const struct trace_print_flags_u64 *symbol_array)
|
||||
const struct trace_print_flags_u64 *symbol_array,
|
||||
size_t symbol_array_size)
|
||||
{
|
||||
int i;
|
||||
const char *ret = trace_seq_buffer_ptr(p);
|
||||
|
||||
for (i = 0; symbol_array[i].name; i++) {
|
||||
for (i = 0; i < symbol_array_size; i++) {
|
||||
|
||||
if (val != symbol_array[i].mask)
|
||||
continue;
|
||||
|
||||
@@ -174,7 +174,6 @@ sys_enter_openat_print(struct syscall_trace_enter *trace, struct syscall_metadat
|
||||
{ O_NOFOLLOW, "O_NOFOLLOW" },
|
||||
{ O_NOATIME, "O_NOATIME" },
|
||||
{ O_CLOEXEC, "O_CLOEXEC" },
|
||||
{ -1, NULL }
|
||||
};
|
||||
|
||||
trace_seq_printf(s, "%s(", entry->name);
|
||||
@@ -205,7 +204,7 @@ sys_enter_openat_print(struct syscall_trace_enter *trace, struct syscall_metadat
|
||||
trace_seq_puts(s, "O_RDONLY|");
|
||||
}
|
||||
|
||||
trace_print_flags_seq(s, "|", bits, __flags);
|
||||
trace_print_flags_seq(s, "|", bits, __flags, ARRAY_SIZE(__flags));
|
||||
/*
|
||||
* trace_print_flags_seq() adds a '\0' to the
|
||||
* buffer, but this needs to append more to the seq.
|
||||
|
||||
Reference in New Issue
Block a user