Skip to contentSkip to conversation

tracing: Have synthetic event test use raw_smp_processor_id()

PATCH In review Steven Rostedt 3 participants 5 messages Feb 20, 2020 – Feb 21, 2020 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 tracing: Have synthetic event test use raw_smp_processor_id()

From: "Steven Rostedt (VMware)" <[email protected]>

The test code that tests synthetic event creation pushes in as one of its test fields the current CPU using "smp_processor_id()". As this is just something to see if the value is correctly passed in, and the actual CPU used does not matter, use raw_smp_processor_id(), otherwise with debug preemption enabled, a warning happens as the smp_processor_id() is called without preemption enabled.

---
 kernel/trace/synth_event_gen_test.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/trace/synth_event_gen_test.c +6 -6
index 6866280a9b10..7d56d621ffea 100644
@@ -114,7 +114,7 @@ static int __init test_gen_synth_cmd(void)
 	vals[1] = (u64)(long)"hula hoops";	/* next_comm_field */
 	vals[2] = 1000000;		/* ts_ns */
 	vals[3] = 1000;			/* ts_ms */
-	vals[4] = smp_processor_id();	/* cpu */
+	vals[4] = raw_smp_processor_id(); /* cpu */
 	vals[5] = (u64)(long)"thneed";	/* my_string_field */
 	vals[6] = 598;			/* my_int_field */
 
@@ -221,7 +221,7 @@ static int __init test_empty_synth_event(void)
 	vals[1] = (u64)(long)"tiddlywinks";	/* next_comm_field */
 	vals[2] = 1000000;		/* ts_ns */
 	vals[3] = 1000;			/* ts_ms */
-	vals[4] = smp_processor_id();	/* cpu */
+	vals[4] = raw_smp_processor_id(); /* cpu */
 	vals[5] = (u64)(long)"thneed_2.0";	/* my_string_field */
 	vals[6] = 399;			/* my_int_field */
 
@@ -293,7 +293,7 @@ static int __init test_create_synth_event(void)
 	vals[1] = (u64)(long)"tiddlywinks";	/* next_comm_field */
 	vals[2] = 1000000;		/* ts_ns */
 	vals[3] = 1000;			/* ts_ms */
-	vals[4] = smp_processor_id();	/* cpu */
+	vals[4] = raw_smp_processor_id(); /* cpu */
 	vals[5] = (u64)(long)"thneed";	/* my_string_field */
 	vals[6] = 398;			/* my_int_field */
 
@@ -345,7 +345,7 @@ static int __init test_add_next_synth_val(void)
 		goto out;
 
 	/* cpu */
-	ret = synth_event_add_next_val(smp_processor_id(), &trace_state);
+	ret = synth_event_add_next_val(raw_smp_processor_id(), &trace_state);
 	if (ret)
 		goto out;
 
@@ -388,7 +388,7 @@ static int __init test_add_synth_val(void)
 	if (ret)
 		goto out;
 
-	ret = synth_event_add_val("cpu", smp_processor_id(), &trace_state);
+	ret = synth_event_add_val("cpu", raw_smp_processor_id(), &trace_state);
 	if (ret)
 		goto out;
 
@@ -427,7 +427,7 @@ static int __init test_trace_synth_event(void)
 				(u64)(long)"clackers",	/* next_comm_field */
 				(u64)1000000,		/* ts_ns */
 				(u64)1000,		/* ts_ms */
-				(u64)smp_processor_id(),/* cpu */
+				(u64)raw_smp_processor_id(), /* cpu */
 				(u64)(long)"Thneed",	/* my_string_field */
 				(u64)999);		/* my_int_field */
 	return ret;
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Steve,

Quoted 14 lines · Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

The test code that tests synthetic event creation pushes in as one of its
test fields the current CPU using "smp_processor_id()". As this is just
something to see if the value is correctly passed in, and the actual CPU
used does not matter, use raw_smp_processor_id(), otherwise with debug
preemption enabled, a warning happens as the smp_processor_id() is called
without preemption enabled.

Quoted 1 line

Makes sense - I guess it's simpler than Masami's and fine for this purpose.

Thanks,

Tom

Quoted 77 lines
---
 kernel/trace/synth_event_gen_test.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/trace/synth_event_gen_test.c +1 -1
index 6866280a9b10..7d56d621ffea 100644
@@ -114,7 +114,7 @@ static int __init test_gen_synth_cmd(void)
 	vals[1] = (u64)(long)"hula hoops";	/* next_comm_field
 */
 	vals[2] = 1000000;		/* ts_ns */
 	vals[3] = 1000;			/* ts_ms */
-	vals[4] = smp_processor_id();	/* cpu */
+	vals[4] = raw_smp_processor_id(); /* cpu */
 	vals[5] = (u64)(long)"thneed";	/* my_string_field */
 	vals[6] = 598;			/* my_int_field */
@@ -221,7 +221,7 @@ static int __init test_empty_synth_event(void)
 	vals[1] = (u64)(long)"tiddlywinks";	/*

next_comm_field */

kernel/trace/synth_event_gen_test.c +1 -1
 	vals[2] = 1000000;		/* ts_ns */
 	vals[3] = 1000;			/* ts_ms */
-	vals[4] = smp_processor_id();	/* cpu */
+	vals[4] = raw_smp_processor_id(); /* cpu */
 	vals[5] = (u64)(long)"thneed_2.0";	/* my_string_field

*/

kernel/trace/synth_event_gen_test.c +0 -0
 	vals[6] = 399;			/* my_int_field */
@@ -293,7 +293,7 @@ static int __init test_create_synth_event(void)
 	vals[1] = (u64)(long)"tiddlywinks";	/*

next_comm_field */

kernel/trace/synth_event_gen_test.c +2 -2
 	vals[2] = 1000000;		/* ts_ns */
 	vals[3] = 1000;			/* ts_ms */
-	vals[4] = smp_processor_id();	/* cpu */
+	vals[4] = raw_smp_processor_id(); /* cpu */
 	vals[5] = (u64)(long)"thneed";	/* my_string_field */
 	vals[6] = 398;			/* my_int_field */
@@ -345,7 +345,7 @@ static int __init test_add_next_synth_val(void)
 		goto out;
 
 	/* cpu */
-	ret = synth_event_add_next_val(smp_processor_id(),
 &trace_state);
+	ret = synth_event_add_next_val(raw_smp_processor_id(),
 &trace_state);
 	if (ret)
kernel/trace/synth_event_gen_test.c +1 -1
 		goto out;
@@ -388,7 +388,7 @@ static int __init test_add_synth_val(void)
 	if (ret)
 		goto out;
 
-	ret = synth_event_add_val("cpu", smp_processor_id(),
 &trace_state);
+	ret = synth_event_add_val("cpu", raw_smp_processor_id(),
 &trace_state);
 	if (ret)
kernel/trace/synth_event_gen_test.c +0 -0
 		goto out;
@@ -427,7 +427,7 @@ static int __init test_trace_synth_event(void)
 				(u64)(long)"clackers",	/*

next_comm_field */
(u64)1000000, /*
ts_ns */
(u64)1000, /* ts_ms
*/

kernel/trace/synth_event_gen_test.c +1 -1
-				(u64)smp_processor_id(),/* cpu */
+				(u64)raw_smp_processor_id(), /* cpu

*/
(u64)(long)"Thneed", /*
my_string_field */
(u64)999); /*
my_int_field */
return ret;

maintainer
#2 lore raw
Quoted 17 lines · On Thu, 20 Feb 2020 16:14:40 -0600 Tom Zanussi <[email protected]> wrote:

Hi Steve,

Quoted 14 lines · Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

The test code that tests synthetic event creation pushes in as one of its
test fields the current CPU using "smp_processor_id()". As this is just
something to see if the value is correctly passed in, and the actual CPU
used does not matter, use raw_smp_processor_id(), otherwise with debug
preemption enabled, a warning happens as the smp_processor_id() is called
without preemption enabled.

Quoted 6 lines
Quoted 1 line

Makes sense - I guess it's simpler than Masami's and fine for this purpose.

Hmm, can we reserve ring buffer on CPU1 and commit it on CPU2? Shouldn't we disable preemption between them?

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
author maintainer
#3 lore raw
Quoted 22 lines · On Fri, 21 Feb 2020 09:22:30 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 19 lines · On Thu, 20 Feb 2020 16:14:40 -0600 Tom Zanussi <[email protected]> wrote:

Hi Steve,

Quoted 15 lines · Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

The test code that tests synthetic event creation pushes in as one of its
test fields the current CPU using "smp_processor_id()". As this is just
something to see if the value is correctly passed in, and the actual CPU
used does not matter, use raw_smp_processor_id(), otherwise with debug
preemption enabled, a warning happens as the smp_processor_id() is called
without preemption enabled.

Quoted 8 lines
Quoted 4 lines

Makes sense - I guess it's simpler than Masami's and fine for this purpose.

Hmm, can we reserve ring buffer on CPU1 and commit it on CPU2? Shouldn't we disable preemption between them?

I don't think it matters. There's nothing that checks it. And if one was concerned about the content of the CPU, one could always enable scheduling events and see the task migrate.

-- Steve

maintainer Reviewed-by
#4 lore raw
Quoted 30 lines · On Thu, 20 Feb 2020 21:52:36 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 27 lines · On Fri, 21 Feb 2020 09:22:30 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 23 lines · On Thu, 20 Feb 2020 16:14:40 -0600 Tom Zanussi <[email protected]> wrote:

Hi Steve,

Quoted 14 lines · Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

The test code that tests synthetic event creation pushes in as one of its
test fields the current CPU using "smp_processor_id()". As this is just
something to see if the value is correctly passed in, and the actual CPU
used does not matter, use raw_smp_processor_id(), otherwise with debug
preemption enabled, a warning happens as the smp_processor_id() is called
without preemption enabled.

Quoted 1 line

Makes sense - I guess it's simpler than Masami's and fine for this purpose.

Quoted 7 lines
Quoted 3 lines

Hmm, can we reserve ring buffer on CPU1 and commit it on CPU2? Shouldn't we disable preemption between them?

I don't think it matters. There's nothing that checks it. And if one was concerned about the content of the CPU, one could always enable scheduling events and see the task migrate.

Ah, OK I confirmed that the preemption is disabled in ring_buffer_nest_start() so it should not happen.

Thank you!

Quoted 3 lines

-- Steve

Signature · 1 line
Masami Hiramatsu <[email protected]>