From: Axel Rasmussen <axelrasmussen@google.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Michel Lespinasse <walken@google.com>,
Vlastimil Babka <vbabka@suse.cz>,
Daniel Jordan <daniel.m.jordan@oracle.com>,
Laurent Dufour <ldufour@linux.ibm.com>,
Axel Rasmussen <axelrasmussen@google.com>,
Jann Horn <jannh@google.com>,
Chinwen Chang <chinwen.chang@mediatek.com>
Cc: Yafang Shao <laoar.shao@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH v3 1/2] tracing: support "bool" type in synthetic trace events
Date: Fri, 9 Oct 2020 15:05:23 -0700 [thread overview]
Message-ID: <20201009220524.485102-2-axelrasmussen@google.com> (raw)
In-Reply-To: <20201009220524.485102-1-axelrasmussen@google.com>
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
Acked-by: Michel Lespinasse <walken@google.com>
Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>
---
kernel/trace/trace_events_synth.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index 8e1974fbad0e..8f94c84349a6 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -234,6 +234,8 @@ static int synth_field_size(char *type)
size = sizeof(long);
else if (strcmp(type, "unsigned long") == 0)
size = sizeof(unsigned long);
+ else if (strcmp(type, "bool") == 0)
+ size = sizeof(bool);
else if (strcmp(type, "pid_t") == 0)
size = sizeof(pid_t);
else if (strcmp(type, "gfp_t") == 0)
@@ -276,6 +278,8 @@ static const char *synth_field_fmt(char *type)
fmt = "%ld";
else if (strcmp(type, "unsigned long") == 0)
fmt = "%lu";
+ else if (strcmp(type, "bool") == 0)
+ fmt = "%d";
else if (strcmp(type, "pid_t") == 0)
fmt = "%d";
else if (strcmp(type, "gfp_t") == 0)
--
2.28.0.1011.ga647a8990f-goog
next prev parent reply other threads:[~2020-10-09 22:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 22:05 [PATCH v3 0/2] Add tracepoints around mmap_lock acquisition Axel Rasmussen
2020-10-09 22:05 ` Axel Rasmussen [this message]
2020-10-12 14:15 ` [PATCH v3 1/2] tracing: support "bool" type in synthetic trace events Steven Rostedt
2020-10-12 14:26 ` Tom Zanussi
2020-10-12 14:46 ` Steven Rostedt
2020-10-12 16:23 ` Axel Rasmussen
2020-10-13 19:41 ` David Rientjes
2020-10-09 22:05 ` [PATCH v3 2/2] mmap_lock: add tracepoints around lock acquisition Axel Rasmussen
2020-10-09 22:35 ` Michel Lespinasse
2020-10-10 5:31 ` Yafang Shao
2020-10-13 19:42 ` David Rientjes
2020-10-20 14:50 ` Vlastimil Babka
2020-10-20 18:17 ` Axel Rasmussen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201009220524.485102-2-axelrasmussen@google.com \
--to=axelrasmussen@google.com \
--cc=akpm@linux-foundation.org \
--cc=chinwen.chang@mediatek.com \
--cc=daniel.m.jordan@oracle.com \
--cc=jannh@google.com \
--cc=laoar.shao@gmail.com \
--cc=ldufour@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=vbabka@suse.cz \
--cc=walken@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).