Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <mathieu.desnoyers@efficios.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lore.kernel.org/87y14t6ofi.wl-me@linux.beauty
Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Li Chen and committed by
Steven Rostedt (Google)
e32540b1 8cf0b939

+3 -7
+3 -7
kernel/trace/trace_functions.c
··· 184 184 struct trace_array_cpu *data; 185 185 unsigned int trace_ctx; 186 186 int bit; 187 - int cpu; 188 187 189 188 if (unlikely(!tr->function_enabled)) 190 189 return; ··· 194 195 195 196 trace_ctx = tracing_gen_ctx(); 196 197 197 - cpu = smp_processor_id(); 198 - data = per_cpu_ptr(tr->array_buffer.data, cpu); 198 + data = this_cpu_ptr(tr->array_buffer.data); 199 199 if (!atomic_read(&data->disabled)) 200 200 trace_function(tr, ip, parent_ip, trace_ctx); 201 201 ··· 298 300 unsigned int trace_ctx; 299 301 unsigned long flags; 300 302 int bit; 301 - int cpu; 302 303 303 304 if (unlikely(!tr->function_enabled)) 304 305 return; ··· 306 309 if (bit < 0) 307 310 return; 308 311 309 - cpu = smp_processor_id(); 310 - data = per_cpu_ptr(tr->array_buffer.data, cpu); 312 + data = this_cpu_ptr(tr->array_buffer.data); 311 313 if (atomic_read(&data->disabled)) 312 314 goto out; 313 315 ··· 317 321 * TODO: think about a solution that is better than just hoping to be 318 322 * lucky. 319 323 */ 320 - last_info = per_cpu_ptr(tr->last_func_repeats, cpu); 324 + last_info = this_cpu_ptr(tr->last_func_repeats); 321 325 if (is_repeat_check(tr, last_info, ip, parent_ip)) 322 326 goto out; 323 327