* [PATCH] tracing: Fix trace_event_raw_event_synth() if else statement
@ 2023-01-31 14:52 Steven Rostedt
2023-01-31 15:36 ` Masami Hiramatsu
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2023-01-31 14:52 UTC (permalink / raw)
To: LKML, Linux Trace Kernel; +Cc: Masami Hiramatsu, Tom Zanussi, kernel test robot
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
The test to check if the field is a stack is to be done if it is not a
string. But the code had:
} if (event->fields[i]->is_stack) {
and not
} else if (event->fields[i]->is_stack) {
which would cause it to always be tested. Worse yet, this also included an
"else" statement that was only to be called if the field was not a string
and a stack, but this code allows it to be called if it was a string (and
not a stack).
Also fixed some whitespace issues.
Link: https://lore.kernel.org/all/202301302110.mEtNwkBD-lkp@intel.com/
Fixes: 00cf3d672a9d ("tracing: Allow synthetic events to pass around stacktraces")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/trace_events_synth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index adb630633f31..306c89e0ce55 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -564,8 +564,8 @@ static notrace void trace_event_raw_event_synth(void *__data,
event->fields[i]->is_dynamic,
data_size, &n_u64);
data_size += len; /* only dynamic string increments */
- } if (event->fields[i]->is_stack) {
- long *stack = (long *)(long)var_ref_vals[val_idx];
+ } else if (event->fields[i]->is_stack) {
+ long *stack = (long *)(long)var_ref_vals[val_idx];
len = trace_stack(entry, event, stack,
data_size, &n_u64);
--
2.39.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tracing: Fix trace_event_raw_event_synth() if else statement
2023-01-31 14:52 [PATCH] tracing: Fix trace_event_raw_event_synth() if else statement Steven Rostedt
@ 2023-01-31 15:36 ` Masami Hiramatsu
2023-01-31 15:42 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2023-01-31 15:36 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Tom Zanussi,
kernel test robot
On Tue, 31 Jan 2023 09:52:37 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> The test to check if the field is a stack is to be done if it is not a
> string. But the code had:
>
> } if (event->fields[i]->is_stack) {
>
> and not
>
> } else if (event->fields[i]->is_stack) {
>
> which would cause it to always be tested. Worse yet, this also included an
> "else" statement that was only to be called if the field was not a string
> and a stack, but this code allows it to be called if it was a string (and
> not a stack).
>
> Also fixed some whitespace issues.
>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Hmm, I need to add more tests for syntax events...
Thanks!
> Link: https://lore.kernel.org/all/202301302110.mEtNwkBD-lkp@intel.com/
>
> Fixes: 00cf3d672a9d ("tracing: Allow synthetic events to pass around stacktraces")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> kernel/trace/trace_events_synth.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
> index adb630633f31..306c89e0ce55 100644
> --- a/kernel/trace/trace_events_synth.c
> +++ b/kernel/trace/trace_events_synth.c
> @@ -564,8 +564,8 @@ static notrace void trace_event_raw_event_synth(void *__data,
> event->fields[i]->is_dynamic,
> data_size, &n_u64);
> data_size += len; /* only dynamic string increments */
> - } if (event->fields[i]->is_stack) {
> - long *stack = (long *)(long)var_ref_vals[val_idx];
> + } else if (event->fields[i]->is_stack) {
> + long *stack = (long *)(long)var_ref_vals[val_idx];
>
> len = trace_stack(entry, event, stack,
> data_size, &n_u64);
> --
> 2.39.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tracing: Fix trace_event_raw_event_synth() if else statement
2023-01-31 15:36 ` Masami Hiramatsu
@ 2023-01-31 15:42 ` Steven Rostedt
0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2023-01-31 15:42 UTC (permalink / raw)
To: Masami Hiramatsu (Google)
Cc: LKML, Linux Trace Kernel, Tom Zanussi, kernel test robot
On Wed, 1 Feb 2023 00:36:33 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> Looks good to me.
>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> Hmm, I need to add more tests for syntax events...
I was thinking the same thing, as they should have caught this ;-)
-- Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-31 15:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 14:52 [PATCH] tracing: Fix trace_event_raw_event_synth() if else statement Steven Rostedt
2023-01-31 15:36 ` Masami Hiramatsu
2023-01-31 15:42 ` Steven Rostedt
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).