Skip to content

Commit 6107742

Browse files
CmdrMoozyrostedt
authored andcommitted
tracing: support "bool" type in synthetic trace events
It's common [1] to define tracepoint fields as "bool" when they contain a true / false value. Currently, defining a synthetic event with a "bool" field yields EINVAL. It's possible to work around this by using e.g. u8 (assuming sizeof(bool) is 1, and bool is unsigned; if either of these properties don't match, you get EINVAL [2]). Supporting "bool" explicitly makes hooking this up easier and more portable for userspace. [1]: grep -r "bool" include/trace/events/ [2]: check_synth_field() in kernel/trace/trace_events_hist.c Link: https://lkml.kernel.org/r/20201009220524.485102-2-axelrasmussen@google.com Acked-by: Michel Lespinasse <walken@google.com> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 81ff92a commit 6107742

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

kernel/trace/trace_events_synth.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ static int synth_field_size(char *type)
229229
size = sizeof(long);
230230
else if (strcmp(type, "unsigned long") == 0)
231231
size = sizeof(unsigned long);
232+
else if (strcmp(type, "bool") == 0)
233+
size = sizeof(bool);
232234
else if (strcmp(type, "pid_t") == 0)
233235
size = sizeof(pid_t);
234236
else if (strcmp(type, "gfp_t") == 0)
@@ -271,6 +273,8 @@ static const char *synth_field_fmt(char *type)
271273
fmt = "%ld";
272274
else if (strcmp(type, "unsigned long") == 0)
273275
fmt = "%lu";
276+
else if (strcmp(type, "bool") == 0)
277+
fmt = "%d";
274278
else if (strcmp(type, "pid_t") == 0)
275279
fmt = "%d";
276280
else if (strcmp(type, "gfp_t") == 0)

0 commit comments

Comments
 (0)