Skip to contentSkip to conversation

ftrace: use this_cpu_ptr per-cpu helper

PATCH In review Shan Wei 2 participants 2 messages Oct 31, 2012

Subsystems (2)
lore
Share & tools
lore

Shan Wei

author
#0 lore raw

PATCH 5/9 ftrace: use this_cpu_ptr per-cpu helper

From: Shan Wei <[email protected]>

---
 include/trace/ftrace.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
include/trace/ftrace.h +1 -3
index a763888..7c9fde7 100644
@@ -638,7 +638,6 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
  *	struct trace_entry *ent;
  *	int __entry_size;
  *	int __data_size;
- *	int __cpu
  *	int pc;
  *
  *	pc = preempt_count();
@@ -654,7 +653,6 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
  *	// Protect the non nmi buffer
  *	// This also protects the rcu read side
  *	local_irq_save(irq_flags);
- *	__cpu = smp_processor_id();
  *
  *	if (in_nmi())
  *		trace_buf = rcu_dereference_sched(perf_trace_buf_nmi);
@@ -664,7 +662,7 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
  *	if (!trace_buf)
  *		goto end;
  *
- *	trace_buf = per_cpu_ptr(trace_buf, __cpu);
+ *	trace_buf = this_cpu_ptr(trace_buf);
  *
  * 	// Avoid recursion from perf that could mess up the buffer
  * 	if (trace_buf->recursion++)
Signature · 1 line
1.7.1
Reviewed-by on v1 5/9
#1 lore raw
Quoted 21 lines · Shan Wei
include/trace/ftrace.h +0 -2
index a763888..7c9fde7 100644
@@ -638,7 +638,6 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
  *	struct trace_entry *ent;
  *	int __entry_size;
  *	int __data_size;
- *	int __cpu
  *	int pc;
  *
  *	pc = preempt_count();
@@ -654,7 +653,6 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
  *	// Protect the non nmi buffer
  *	// This also protects the rcu read side
  *	local_irq_save(irq_flags);
- *	__cpu = smp_processor_id();
  *
  *	if (in_nmi())
  *		trace_buf = rcu_dereference_sched(perf_trace_buf_nmi);

include/trace/ftrace.h __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call · line 668

Quoted 8 lines
include/trace/ftrace.h +1 -1
@@ -664,7 +662,7 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
  *	if (!trace_buf)
  *		goto end;
  *
- *	trace_buf = per_cpu_ptr(trace_buf, __cpu);
+ *	trace_buf = this_cpu_ptr(trace_buf);
  *
  * 	// Avoid recursion from perf that could mess up the buffer
  * 	if (trace_buf->recursion++)

Code could be further reduced by not doing the this_cpu_ptr op but using this_cpu_read later instead.