Skip to content

Commit e32540b

Browse files
FirstLoveLiferostedt
authored andcommitted
ftrace: Use this_cpu_ptr() instead of per_cpu_ptr(smp_processor_id())
Use this_cpu_ptr() instead of open coding the equivalent in various ftrace functions. Cc: Mathieu Desnoyers <[email protected]> Cc: Masami Hiramatsu <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Li Chen <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 8cf0b93 commit e32540b

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

kernel/trace/trace_functions.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
184184
struct trace_array_cpu *data;
185185
unsigned int trace_ctx;
186186
int bit;
187-
int cpu;
188187

189188
if (unlikely(!tr->function_enabled))
190189
return;
@@ -195,8 +194,7 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
195194

196195
trace_ctx = tracing_gen_ctx();
197196

198-
cpu = smp_processor_id();
199-
data = per_cpu_ptr(tr->array_buffer.data, cpu);
197+
data = this_cpu_ptr(tr->array_buffer.data);
200198
if (!atomic_read(&data->disabled))
201199
trace_function(tr, ip, parent_ip, trace_ctx);
202200

@@ -300,7 +298,6 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
300298
unsigned int trace_ctx;
301299
unsigned long flags;
302300
int bit;
303-
int cpu;
304301

305302
if (unlikely(!tr->function_enabled))
306303
return;
@@ -309,8 +306,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
309306
if (bit < 0)
310307
return;
311308

312-
cpu = smp_processor_id();
313-
data = per_cpu_ptr(tr->array_buffer.data, cpu);
309+
data = this_cpu_ptr(tr->array_buffer.data);
314310
if (atomic_read(&data->disabled))
315311
goto out;
316312

@@ -321,7 +317,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
321317
* TODO: think about a solution that is better than just hoping to be
322318
* lucky.
323319
*/
324-
last_info = per_cpu_ptr(tr->last_func_repeats, cpu);
320+
last_info = this_cpu_ptr(tr->last_func_repeats);
325321
if (is_repeat_check(tr, last_info, ip, parent_ip))
326322
goto out;
327323

0 commit comments

Comments
 (0)