From: Masami Hiramatsu <mhiramat@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
Randy Dunlap <rdunlap@infradead.org>,
Ingo Molnar <mingo@kernel.org>, Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH v2 4/6] tracing/kprobes: Support perf-style return probe
Date: Thu, 10 Sep 2020 09:49:23 +0900 [thread overview]
Message-ID: <20200910094923.42a09f8f75f84cdbeac743c8@kernel.org> (raw)
In-Reply-To: <159894703070.1478826.15755889933157654537.stgit@devnote2>
On Tue, 1 Sep 2020 16:57:10 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:
> Support perf-style return probe ("SYMBOL%return") in kprobe events.
> This will allow boot-time tracing user to define a return probe event.
>
Hmm, I think I should add this for uprobe event too.
I'll update the series.
Thank you,
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> ---
> kernel/trace/trace_kprobe.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index aefb6065b508..391361b67c8f 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -709,6 +709,18 @@ static inline void sanitize_event_name(char *name)
> *name = '_';
> }
>
> +static inline bool split_return_suffix(char *symbol)
> +{
> + char *p = strchr(symbol, '%');
> +
> + if (p && !strcmp(p, "%return")) {
> + *p = '\0';
> + return true;
> + }
> +
> + return false;
> +}
> +
> static int trace_kprobe_create(int argc, const char *argv[])
> {
> /*
> @@ -717,6 +729,9 @@ static int trace_kprobe_create(int argc, const char *argv[])
> * p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS]
> * - Add kretprobe:
> * r[MAXACTIVE][:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS]
> + * Or
> + * p:[GRP/]EVENT] [MOD:]KSYM[+0]%return [FETCHARGS]
> + *
> * Fetch args:
> * $retval : fetch return value
> * $stack : fetch stack address
> @@ -746,7 +761,6 @@ static int trace_kprobe_create(int argc, const char *argv[])
> switch (argv[0][0]) {
> case 'r':
> is_return = true;
> - flags |= TPARG_FL_RETURN;
> break;
> case 'p':
> break;
> @@ -804,12 +818,17 @@ static int trace_kprobe_create(int argc, const char *argv[])
> symbol = kstrdup(argv[1], GFP_KERNEL);
> if (!symbol)
> return -ENOMEM;
> +
> + is_return = split_return_suffix(symbol) || is_return;
> +
> /* TODO: support .init module functions */
> ret = traceprobe_split_symbol_offset(symbol, &offset);
> if (ret || offset < 0 || offset > UINT_MAX) {
> trace_probe_log_err(0, BAD_PROBE_ADDR);
> goto parse_error;
> }
> + if (is_return)
> + flags |= TPARG_FL_RETURN;
> if (kprobe_on_func_entry(NULL, symbol, offset))
> flags |= TPARG_FL_FENTRY;
> if (offset && is_return && !(flags & TPARG_FL_FENTRY)) {
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2020-09-10 2:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-01 7:56 [PATCH v2 0/6] tracing/boot: Add new options for tracing specific period Masami Hiramatsu
2020-09-01 7:56 ` [PATCH v2 1/6] kprobes: tracing/kprobes: Fix to kill kprobes on initmem after boot Masami Hiramatsu
2020-09-01 7:56 ` [PATCH v2 2/6] tracing/boot: Add per-instance tracing_on option support Masami Hiramatsu
2020-09-01 7:57 ` [PATCH v2 3/6] Documentation: tracing: Add tracing_on option to boot-time tracer Masami Hiramatsu
2020-09-01 7:57 ` [PATCH v2 4/6] tracing/kprobes: Support perf-style return probe Masami Hiramatsu
2020-09-10 0:49 ` Masami Hiramatsu [this message]
2020-09-01 7:57 ` [PATCH v2 5/6] Documentation: tracing: Add %return suffix description Masami Hiramatsu
2020-09-01 7:57 ` [PATCH v2 6/6] Documentation: tracing: boot: Add an example of tracing function-calls Masami Hiramatsu
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=20200910094923.42a09f8f75f84cdbeac743c8@kernel.org \
--to=mhiramat@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
/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