* [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument
@ 2023-06-12 11:58 Masami Hiramatsu (Google)
2023-06-14 19:50 ` Kui-Feng Lee
2023-06-21 23:03 ` Steven Rostedt
0 siblings, 2 replies; 5+ messages in thread
From: Masami Hiramatsu (Google) @ 2023-06-12 11:58 UTC (permalink / raw)
To: linux-trace-kernel
Cc: linux-kernel, Steven Rostedt, mhiramat, Florent Revest,
Mark Rutland, Will Deacon, Mathieu Desnoyers, Martin KaFai Lau,
bpf, Bagas Sanjaya, kernel test robot
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To hide the first dummy 'data' argument on the tracepoint probe events,
the BTF argument array was modified (skip the first argument for tracepoint),
but the '$arg*' meta argument parser missed that.
Fix to increment the argument index if it is tracepoint probe. And decrement
the index when searching the type of the argument.
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
kernel/trace/trace_probe.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 473e1c43bc57..643aa3a51d5a 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code,
if (name && !strcmp(name, varname)) {
code->op = FETCH_OP_ARG;
- code->param = i;
+ if (ctx->flags & TPARG_FL_TPOINT)
+ code->param = i + 1;
+ else
+ code->param = i;
return 0;
}
}
@@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx,
struct btf *btf = traceprobe_get_btf();
const char *typestr = NULL;
- if (btf && ctx->params)
+ if (btf && ctx->params) {
+ if (ctx->flags & TPARG_FL_TPOINT)
+ arg_idx--;
typestr = type_from_btf_id(btf, ctx->params[arg_idx].type);
+ }
return find_fetch_type(typestr, ctx->flags);
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument
2023-06-12 11:58 [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument Masami Hiramatsu (Google)
@ 2023-06-14 19:50 ` Kui-Feng Lee
2023-06-22 0:39 ` Masami Hiramatsu
2023-06-21 23:03 ` Steven Rostedt
1 sibling, 1 reply; 5+ messages in thread
From: Kui-Feng Lee @ 2023-06-14 19:50 UTC (permalink / raw)
To: Masami Hiramatsu (Google), linux-trace-kernel
Cc: linux-kernel, Steven Rostedt, Florent Revest, Mark Rutland,
Will Deacon, Mathieu Desnoyers, Martin KaFai Lau, bpf,
Bagas Sanjaya, kernel test robot
On 6/12/23 04:58, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> To hide the first dummy 'data' argument on the tracepoint probe events,
> the BTF argument array was modified (skip the first argument for tracepoint),
> but the '$arg*' meta argument parser missed that.
>
> Fix to increment the argument index if it is tracepoint probe. And decrement
> the index when searching the type of the argument.
>
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
> kernel/trace/trace_probe.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 473e1c43bc57..643aa3a51d5a 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code,
>
> if (name && !strcmp(name, varname)) {
> code->op = FETCH_OP_ARG;
> - code->param = i;
> + if (ctx->flags & TPARG_FL_TPOINT)
> + code->param = i + 1;
> + else
> + code->param = i;
> return 0;
> }
> }
> @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx,
> struct btf *btf = traceprobe_get_btf();
> const char *typestr = NULL;
>
> - if (btf && ctx->params)
> + if (btf && ctx->params) {
> + if (ctx->flags & TPARG_FL_TPOINT)
> + arg_idx--;
> typestr = type_from_btf_id(btf, ctx->params[arg_idx].type);
> + }
>
> return find_fetch_type(typestr, ctx->flags);
> }
>
>
I failed to apply this patch.
Would you mind to rebase this patch?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument
2023-06-12 11:58 [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument Masami Hiramatsu (Google)
2023-06-14 19:50 ` Kui-Feng Lee
@ 2023-06-21 23:03 ` Steven Rostedt
2023-06-22 0:56 ` Masami Hiramatsu
1 sibling, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2023-06-21 23:03 UTC (permalink / raw)
To: Masami Hiramatsu (Google)
Cc: linux-trace-kernel, linux-kernel, Florent Revest, Mark Rutland,
Will Deacon, Mathieu Desnoyers, Martin KaFai Lau, bpf,
Bagas Sanjaya, kernel test robot
On Mon, 12 Jun 2023 20:58:57 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> To hide the first dummy 'data' argument on the tracepoint probe events,
> the BTF argument array was modified (skip the first argument for tracepoint),
> but the '$arg*' meta argument parser missed that.
>
> Fix to increment the argument index if it is tracepoint probe. And decrement
> the index when searching the type of the argument.
I'm curious. What if we want a variable that points to that data argument? ;-)
Probably just add a new type I guess.
Anyway,
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-- Steve
>
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
> kernel/trace/trace_probe.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 473e1c43bc57..643aa3a51d5a 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code,
>
> if (name && !strcmp(name, varname)) {
> code->op = FETCH_OP_ARG;
> - code->param = i;
> + if (ctx->flags & TPARG_FL_TPOINT)
> + code->param = i + 1;
> + else
> + code->param = i;
> return 0;
> }
> }
> @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx,
> struct btf *btf = traceprobe_get_btf();
> const char *typestr = NULL;
>
> - if (btf && ctx->params)
> + if (btf && ctx->params) {
> + if (ctx->flags & TPARG_FL_TPOINT)
> + arg_idx--;
> typestr = type_from_btf_id(btf, ctx->params[arg_idx].type);
> + }
>
> return find_fetch_type(typestr, ctx->flags);
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument
2023-06-14 19:50 ` Kui-Feng Lee
@ 2023-06-22 0:39 ` Masami Hiramatsu
0 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2023-06-22 0:39 UTC (permalink / raw)
To: Kui-Feng Lee
Cc: linux-trace-kernel, linux-kernel, Steven Rostedt, Florent Revest,
Mark Rutland, Will Deacon, Mathieu Desnoyers, Martin KaFai Lau,
bpf, Bagas Sanjaya, kernel test robot
On Wed, 14 Jun 2023 12:50:34 -0700
Kui-Feng Lee <sinquersw@gmail.com> wrote:
>
>
> On 6/12/23 04:58, Masami Hiramatsu (Google) wrote:
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> >
> > To hide the first dummy 'data' argument on the tracepoint probe events,
> > the BTF argument array was modified (skip the first argument for tracepoint),
> > but the '$arg*' meta argument parser missed that.
> >
> > Fix to increment the argument index if it is tracepoint probe. And decrement
> > the index when searching the type of the argument.
> >
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > ---
> > kernel/trace/trace_probe.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> > index 473e1c43bc57..643aa3a51d5a 100644
> > --- a/kernel/trace/trace_probe.c
> > +++ b/kernel/trace/trace_probe.c
> > @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code,
> >
> > if (name && !strcmp(name, varname)) {
> > code->op = FETCH_OP_ARG;
> > - code->param = i;
> > + if (ctx->flags & TPARG_FL_TPOINT)
> > + code->param = i + 1;
> > + else
> > + code->param = i;
> > return 0;
> > }
> > }
> > @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx,
> > struct btf *btf = traceprobe_get_btf();
> > const char *typestr = NULL;
> >
> > - if (btf && ctx->params)
> > + if (btf && ctx->params) {
> > + if (ctx->flags & TPARG_FL_TPOINT)
> > + arg_idx--;
> > typestr = type_from_btf_id(btf, ctx->params[arg_idx].type);
> > + }
> >
> > return find_fetch_type(typestr, ctx->flags);
> > }
> >
> >
>
> I failed to apply this patch.
> Would you mind to rebase this patch?
Ah, this is against for the probes/for-next branch on
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
Thanks,
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument
2023-06-21 23:03 ` Steven Rostedt
@ 2023-06-22 0:56 ` Masami Hiramatsu
0 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2023-06-22 0:56 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-trace-kernel, linux-kernel, Florent Revest, Mark Rutland,
Will Deacon, Mathieu Desnoyers, Martin KaFai Lau, bpf,
Bagas Sanjaya, kernel test robot
On Wed, 21 Jun 2023 19:03:37 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 12 Jun 2023 20:58:57 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
>
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> >
> > To hide the first dummy 'data' argument on the tracepoint probe events,
> > the BTF argument array was modified (skip the first argument for tracepoint),
> > but the '$arg*' meta argument parser missed that.
> >
> > Fix to increment the argument index if it is tracepoint probe. And decrement
> > the index when searching the type of the argument.
>
> I'm curious. What if we want a variable that points to that data argument? ;-)
That is a dummy parameter which is passed when registering the callback, so
it is passed from trace_fprobe.c. Currently trace_fprobe.c passed NULL to
the data argument.
>
> Probably just add a new type I guess.
Yeah, if we get any idea to use it, it will be accessed by a new $-variable.
>
> Anyway,
>
> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Thank you!
>
> -- Steve
>
> >
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > ---
> > kernel/trace/trace_probe.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> > index 473e1c43bc57..643aa3a51d5a 100644
> > --- a/kernel/trace/trace_probe.c
> > +++ b/kernel/trace/trace_probe.c
> > @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code,
> >
> > if (name && !strcmp(name, varname)) {
> > code->op = FETCH_OP_ARG;
> > - code->param = i;
> > + if (ctx->flags & TPARG_FL_TPOINT)
> > + code->param = i + 1;
> > + else
> > + code->param = i;
> > return 0;
> > }
> > }
> > @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx,
> > struct btf *btf = traceprobe_get_btf();
> > const char *typestr = NULL;
> >
> > - if (btf && ctx->params)
> > + if (btf && ctx->params) {
> > + if (ctx->flags & TPARG_FL_TPOINT)
> > + arg_idx--;
> > typestr = type_from_btf_id(btf, ctx->params[arg_idx].type);
> > + }
> >
> > return find_fetch_type(typestr, ctx->flags);
> > }
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-22 0:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-12 11:58 [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument Masami Hiramatsu (Google)
2023-06-14 19:50 ` Kui-Feng Lee
2023-06-22 0:39 ` Masami Hiramatsu
2023-06-21 23:03 ` Steven Rostedt
2023-06-22 0:56 ` Masami Hiramatsu
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).