mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
bd82631d7c
Currently, sythetic events only support static string fields such as: # echo 'test_latency u64 lat; char somename[32]' > /sys/kernel/debug/tracing/synthetic_events Which is fine, but wastes a lot of space in the event. It also prevents the most commonly-defined strings in the existing trace events e.g. those defined using __string(), from being passed to synthetic events via the trace() action. With this change, synthetic events with dynamic fields can be defined: # echo 'test_latency u64 lat; char somename[]' > /sys/kernel/debug/tracing/synthetic_events And the trace() action can be used to generate events using either dynamic or static strings: # echo 'hist:keys=name:lat=common_timestamp.usecs-$ts0:onmatch(sys.event).test_latency($lat,name)' > /sys/kernel/debug/tracing/events The synthetic event dynamic strings are implemented in the same way as the existing __data_loc strings and appear as such in the format file. [ <rostedt@goodmis.org>: added __set_synth_event_print_fmt() changes: I added the following to make it work with trace-cmd. Dynamic strings must have __get_str() for events in the print_fmt otherwise it can't be parsed correctly. ] Link: https://lore.kernel.org/r/cover.1601588066.git.zanussi@kernel.org Link: https://lkml.kernel.org/r/3ed35b6d0e390f5b94cb4a9ba1cc18f5982ab277.1601848695.git.zanussi@kernel.org Tested-by: Axel Rasmussen <axelrasmussen@google.com> Signed-off-by: Tom Zanussi <zanussi@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
40 lines
868 B
C
40 lines
868 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef __TRACE_SYNTH_H
|
|
#define __TRACE_SYNTH_H
|
|
|
|
#include "trace_dynevent.h"
|
|
|
|
#define SYNTH_SYSTEM "synthetic"
|
|
#define SYNTH_FIELDS_MAX 32
|
|
|
|
#define STR_VAR_LEN_MAX MAX_FILTER_STR_VAL /* must be multiple of sizeof(u64) */
|
|
|
|
struct synth_field {
|
|
char *type;
|
|
char *name;
|
|
size_t size;
|
|
unsigned int offset;
|
|
bool is_signed;
|
|
bool is_string;
|
|
bool is_dynamic;
|
|
bool field_pos;
|
|
};
|
|
|
|
struct synth_event {
|
|
struct dyn_event devent;
|
|
int ref;
|
|
char *name;
|
|
struct synth_field **fields;
|
|
unsigned int n_fields;
|
|
struct synth_field **dynamic_fields;
|
|
unsigned int n_dynamic_fields;
|
|
unsigned int n_u64;
|
|
struct trace_event_class class;
|
|
struct trace_event_call call;
|
|
struct tracepoint *tp;
|
|
struct module *mod;
|
|
};
|
|
|
|
extern struct synth_event *find_synth_event(const char *name);
|
|
|
|
#endif /* __TRACE_SYNTH_H */
|