Commit 6107742d authored by Axel Rasmussen's avatar Axel Rasmussen Committed by Steven Rostedt (VMware)

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.comAcked-by: default avatarMichel Lespinasse <walken@google.com>
Acked-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarAxel Rasmussen <axelrasmussen@google.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 81ff92a9
...@@ -229,6 +229,8 @@ static int synth_field_size(char *type) ...@@ -229,6 +229,8 @@ static int synth_field_size(char *type)
size = sizeof(long); size = sizeof(long);
else if (strcmp(type, "unsigned long") == 0) else if (strcmp(type, "unsigned long") == 0)
size = sizeof(unsigned long); size = sizeof(unsigned long);
else if (strcmp(type, "bool") == 0)
size = sizeof(bool);
else if (strcmp(type, "pid_t") == 0) else if (strcmp(type, "pid_t") == 0)
size = sizeof(pid_t); size = sizeof(pid_t);
else if (strcmp(type, "gfp_t") == 0) else if (strcmp(type, "gfp_t") == 0)
...@@ -271,6 +273,8 @@ static const char *synth_field_fmt(char *type) ...@@ -271,6 +273,8 @@ static const char *synth_field_fmt(char *type)
fmt = "%ld"; fmt = "%ld";
else if (strcmp(type, "unsigned long") == 0) else if (strcmp(type, "unsigned long") == 0)
fmt = "%lu"; fmt = "%lu";
else if (strcmp(type, "bool") == 0)
fmt = "%d";
else if (strcmp(type, "pid_t") == 0) else if (strcmp(type, "pid_t") == 0)
fmt = "%d"; fmt = "%d";
else if (strcmp(type, "gfp_t") == 0) else if (strcmp(type, "gfp_t") == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment