[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <158193314931.8868.11386672578933699881.stgit@devnote2>
Date: Mon, 17 Feb 2020 18:52:29 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
Tom Zanussi <zanussi@...nel.org>,
artem.bityutskiy@...ux.intel.com, linux-kernel@...r.kernel.org,
linux-rt-users@...r.kernel.org
Subject: [PATCH 1/2] tracing: Fix synth event test to avoid using smp_processor_id()
Since smp_processor_id() requires irq-disabled or preempt-disabled,
synth event generation test module made some warnings. To prevent
that, use get_cpu()/put_cpu() instead of smp_processor_id().
Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
---
kernel/trace/synth_event_gen_test.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/kernel/trace/synth_event_gen_test.c b/kernel/trace/synth_event_gen_test.c
index 4aefe003cb7c..b7775fd6baf5 100644
--- a/kernel/trace/synth_event_gen_test.c
+++ b/kernel/trace/synth_event_gen_test.c
@@ -114,12 +114,13 @@ static int __init test_gen_synth_cmd(void)
vals[1] = (u64)"hula hoops"; /* next_comm_field */
vals[2] = 1000000; /* ts_ns */
vals[3] = 1000; /* ts_ms */
- vals[4] = smp_processor_id(); /* cpu */
+ vals[4] = get_cpu(); /* cpu */
vals[5] = (u64)"thneed"; /* my_string_field */
vals[6] = 598; /* my_int_field */
/* Now generate a gen_synth_test event */
ret = synth_event_trace_array(gen_synth_test, vals, ARRAY_SIZE(vals));
+ put_cpu();
out:
return ret;
delete:
@@ -221,12 +222,13 @@ static int __init test_empty_synth_event(void)
vals[1] = (u64)"tiddlywinks"; /* next_comm_field */
vals[2] = 1000000; /* ts_ns */
vals[3] = 1000; /* ts_ms */
- vals[4] = smp_processor_id(); /* cpu */
+ vals[4] = get_cpu(); /* cpu */
vals[5] = (u64)"thneed_2.0"; /* my_string_field */
vals[6] = 399; /* my_int_field */
/* Now trace an empty_synth_test event */
ret = synth_event_trace_array(empty_synth_test, vals, ARRAY_SIZE(vals));
+ put_cpu();
out:
return ret;
delete:
@@ -293,12 +295,13 @@ static int __init test_create_synth_event(void)
vals[1] = (u64)"tiddlywinks"; /* next_comm_field */
vals[2] = 1000000; /* ts_ns */
vals[3] = 1000; /* ts_ms */
- vals[4] = smp_processor_id(); /* cpu */
+ vals[4] = get_cpu(); /* cpu */
vals[5] = (u64)"thneed"; /* my_string_field */
vals[6] = 398; /* my_int_field */
/* Now generate a create_synth_test event */
ret = synth_event_trace_array(create_synth_test, vals, ARRAY_SIZE(vals));
+ put_cpu();
out:
return ret;
delete:
@@ -315,6 +318,7 @@ static int __init test_create_synth_event(void)
static int __init test_add_next_synth_val(void)
{
struct synth_event_trace_state trace_state;
+ unsigned int cpu;
int ret;
/* Start by reserving space in the trace buffer */
@@ -322,6 +326,8 @@ static int __init test_add_next_synth_val(void)
if (ret)
return ret;
+ cpu = get_cpu();
+
/* Write some bogus values into the trace buffer, one after another */
/* next_pid_field */
@@ -345,7 +351,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(cpu, &trace_state);
if (ret)
goto out;
@@ -357,6 +363,7 @@ static int __init test_add_next_synth_val(void)
/* my_int_field */
ret = synth_event_add_next_val(395, &trace_state);
out:
+ put_cpu();
/* Finally, commit the event */
ret = synth_event_trace_end(&trace_state);
@@ -371,6 +378,7 @@ static int __init test_add_next_synth_val(void)
static int __init test_add_synth_val(void)
{
struct synth_event_trace_state trace_state;
+ unsigned int cpu;
int ret;
/* Start by reserving space in the trace buffer */
@@ -378,6 +386,7 @@ static int __init test_add_synth_val(void)
if (ret)
return ret;
+ cpu = get_cpu();
/* Write some bogus values into the trace buffer, using field names */
ret = synth_event_add_val("ts_ns", 1000000, &trace_state);
@@ -388,7 +397,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", cpu, &trace_state);
if (ret)
goto out;
@@ -408,6 +417,7 @@ static int __init test_add_synth_val(void)
ret = synth_event_add_val("my_int_field", 3999, &trace_state);
out:
+ put_cpu();
/* Finally, commit the event */
ret = synth_event_trace_end(&trace_state);
@@ -427,9 +437,10 @@ static int __init test_trace_synth_event(void)
(u64)"clackers", /* next_comm_field */
1000000, /* ts_ns */
1000, /* ts_ms */
- smp_processor_id(), /* cpu */
+ get_cpu(), /* cpu */
(u64)"Thneed", /* my_string_field */
999); /* my_int_field */
+ put_cpu();
return ret;
}
Powered by blists - more mailing lists