Skip to contentSkip to conversation

tracing/synthetic: Print out u64 values properly

PATCH In review Tero Kristo 3 participants 5 messages Sep 11, 2023 – Sep 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing/synthetic: Print out u64 values properly

The synth traces incorrectly print pointer to the synthetic event values instead of the actual value when using u64 type. Fix by addressing the contents of the union properly.

Fixes ddeea494a16f ("tracing/synthetic: Use union instead of casts")
---
 kernel/trace/trace_events_synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
index 7fff8235075f..070365959c0a 100644
@@ -337,7 +337,7 @@ static void print_synth_event_num_val(struct trace_seq *s,
 		break;
 
 	default:
-		trace_seq_printf(s, print_fmt, name, val, space);
+		trace_seq_printf(s, print_fmt, name, val->as_u64, space);
 		break;
 	}
 }
Signature · 1 line
2.40.1
#1 lore raw

Hi Tero,

Quoted 3 lines · On Mon, 11 Sep 2023 17:17:04 +0300 Tero Kristo <[email protected]>…

The synth traces incorrectly print pointer to the synthetic event values instead of the actual value when using u64 type. Fix by addressing the contents of the union properly.

Thanks for pointing it out.
But I would like to see a new "case 8:" print code instead of changing "default". Can you keep the default as it is and add "case 8:" case there?

Thanks,

Quoted 24 lines
Fixes ddeea494a16f ("tracing/synthetic: Use union instead of casts")
---
 kernel/trace/trace_events_synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
index 7fff8235075f..070365959c0a 100644
@@ -337,7 +337,7 @@ static void print_synth_event_num_val(struct trace_seq *s,
 		break;
 
 	default:
-		trace_seq_printf(s, print_fmt, name, val, space);
+		trace_seq_printf(s, print_fmt, name, val->as_u64, space);
 		break;
 	}
 }
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#2 lore raw

Hi Masami,

Quoted 11 lines · Masami Hiramatsu (Google)

Hi Tero,

Quoted 3 lines · On Mon, 11 Sep 2023 17:17:04 +0300 Tero Kristo <[email protected]>…

The synth traces incorrectly print pointer to the synthetic event values instead of the actual value when using u64 type. Fix by addressing the contents of the union properly.

Thanks for pointing it out.
But I would like to see a new "case 8:" print code instead of changing "default". Can you keep the default as it is and add "case 8:" case there?

Are you sure about that? I think keeping the default as is would just print out a useless pointer value to the synth event itself (which is what happened with u64 type.)

Anyways, that requires a new patch to be created on top as this has hit the mainline as a fix already.

-Tero

Quoted 27 lines

Thanks,

Quoted 23 lines
Fixes ddeea494a16f ("tracing/synthetic: Use union instead of casts")
---
  kernel/trace/trace_events_synth.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
index 7fff8235075f..070365959c0a 100644
@@ -337,7 +337,7 @@ static void print_synth_event_num_val(struct trace_seq *s,
  		break;
 
  	default:
-		trace_seq_printf(s, print_fmt, name, val, space);
+		trace_seq_printf(s, print_fmt, name, val->as_u64, space);
  		break;
  	}
  }
Signature · 1 line
2.40.1
#3 lore raw

Hi Tero,

Quoted 11 lines · On Fri, 15 Sep 2023 13:46:45 +0300 Tero Kristo <[email protected]>…

Hi Masami,

Quoted 8 lines · Masami Hiramatsu (Google)

Hi Tero,

Quoted 3 lines · On Mon, 11 Sep 2023 17:17:04 +0300 Tero Kristo <[email protected]>…

The synth traces incorrectly print pointer to the synthetic event values instead of the actual value when using u64 type. Fix by addressing the contents of the union properly.

Quoted 7 lines
Quoted 3 lines

Thanks for pointing it out.
But I would like to see a new "case 8:" print code instead of changing "default". Can you keep the default as it is and add "case 8:" case there?

Are you sure about that? I think keeping the default as is would just print out a useless pointer value to the synth event itself (which is what happened with u64 type.)

Yeah, I think the "default" here means no correct way to show the value in it. So anyway, if we know the size is 8 and there is val->as_u64, there should be "case 8:".

Quoted 3 lines

Anyways, that requires a new patch to be created on top as this has hit the mainline as a fix already.

Oops, I missed that.

Thank you!

Quoted 31 lines

-Tero

Quoted 27 lines

Thanks,

Quoted 23 lines
Fixes ddeea494a16f ("tracing/synthetic: Use union instead of casts")
---
  kernel/trace/trace_events_synth.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
index 7fff8235075f..070365959c0a 100644
@@ -337,7 +337,7 @@ static void print_synth_event_num_val(struct trace_seq *s,
  		break;
 
  	default:
-		trace_seq_printf(s, print_fmt, name, val, space);
+		trace_seq_printf(s, print_fmt, name, val->as_u64, space);
  		break;
  	}
  }
Signature · 1 line
2.40.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
maintainer
#4 lore raw
Quoted 4 lines · On Fri, 15 Sep 2023 23:16:13 +0900 Masami Hiramatsu (Google)…
Quoted 2 lines

Anyways, that requires a new patch to be created on top as this has hit the mainline as a fix already.

Oops, I missed that.

Yeah, I took that because it matched the original case, which was it being u64.

-- Steve