Messages in this thread |  | | | Date | Tue, 7 Oct 2008 06:39:41 -0400 (EDT) | | From | Steven Rostedt <> | | Subject | Re: PATCH] ftrace: Add a C/P state tracer to help power optimization |
| |
On Mon, 6 Oct 2008, Andi Kleen wrote: > > > +void trace_power_end(struct power_trace *it) > > +{ > > + struct ring_buffer_event *event; > > + struct trace_power *entry; > > + struct trace_array_cpu *data; > > + unsigned long irq_flags; > > + struct trace_array *tr = power_trace; > > + > > + if (!trace_power_enabled) > > + return; > > + > > + preempt_disable(); > > + it->end = ktime_get(); > > + data = tr->data[smp_processor_id()]; > > + > > + event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), > > + &irq_flags); > > + if (!event) > > + goto out; > > + entry = ring_buffer_event_data(event); > > + tracing_generic_entry_update(&entry->ent, 0, 0); > > + entry->ent.type = TRACE_POWER; > > + entry->state_data = *it; > > + ring_buffer_unlock_commit(tr->buffer, event, irq_flags); > > When ring_buffer_lock_reserve really disables interrupts (I haven't > checked since it's not in 2.6.27rc8) you could avoid the > preempt_disable by moving the data = tr->data ... one below.
The ring_buffer_lock_reserve use to disable interrupts (I'll be removing the flags argument soon). Now it just does a minimum of preempt_disable. So your suggestion about moving the smp_processor_id() calls below that is still valid. The reserve will always disable preemption.
-- Steve
> > Similar comments to trace_power_mark. Also it would be probably good > to use a common function instead of duplicating so much code. > >
|  |