Skip to content

Commit

Permalink
ftrace: Use this_cpu_ptr() instead of per_cpu_ptr(smp_processor_id())
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Li Chen authored and rostedt committed Oct 8, 2024
1 parent 8cf0b93 commit e32540b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions kernel/trace/trace_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
struct trace_array_cpu *data;
unsigned int trace_ctx;
int bit;
int cpu;

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

trace_ctx = tracing_gen_ctx();

cpu = smp_processor_id();
data = per_cpu_ptr(tr->array_buffer.data, cpu);
data = this_cpu_ptr(tr->array_buffer.data);
if (!atomic_read(&data->disabled))
trace_function(tr, ip, parent_ip, trace_ctx);

Expand Down Expand Up @@ -300,7 +298,6 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
unsigned int trace_ctx;
unsigned long flags;
int bit;
int cpu;

if (unlikely(!tr->function_enabled))
return;
Expand All @@ -309,8 +306,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip,
if (bit < 0)
return;

cpu = smp_processor_id();
data = per_cpu_ptr(tr->array_buffer.data, cpu);
data = this_cpu_ptr(tr->array_buffer.data);
if (atomic_read(&data->disabled))
goto out;

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

Expand Down

0 comments on commit e32540b

Please sign in to comment.