Skip to content

Commit

Permalink
perf: Add perf_event::child_count
Browse files Browse the repository at this point in the history
Only child counters adding back their values into the parent counter
are responsible for cross-cpu updates to event->count.

So if we pull that out into a new child_count variable, we get an
event->count that is only modified locally.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jun 9, 2010
1 parent b5e5879 commit a6e6dea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ struct perf_event {
enum perf_event_active_state state;
unsigned int attach_state;
atomic64_t count;
atomic64_t child_count;

/*
* These are the total time in nanoseconds that the event
Expand Down
4 changes: 2 additions & 2 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ static void __perf_event_read(void *info)

static inline u64 perf_event_count(struct perf_event *event)
{
return atomic64_read(&event->count);
return atomic64_read(&event->count) + atomic64_read(&event->child_count);
}

static u64 perf_event_read(struct perf_event *event)
Expand Down Expand Up @@ -5379,7 +5379,7 @@ static void sync_child_event(struct perf_event *child_event,
/*
* Add back the child's count to the parent's count:
*/
atomic64_add(child_val, &parent_event->count);
atomic64_add(child_val, &parent_event->child_count);
atomic64_add(child_event->total_time_enabled,
&parent_event->child_total_time_enabled);
atomic64_add(child_event->total_time_running,
Expand Down

0 comments on commit a6e6dea

Please sign in to comment.