diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2010-05-21 08:43:12 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-06-09 05:12:36 -0400 |
commit | b5e58793c7a8ec35e72ea6ec6c353499dd189809 (patch) | |
tree | b416db400eb1f67c0b078bd15d60aa9a561d7edf /kernel/perf_event.c | |
parent | 1996bda2a42480c275656233e631ee0966574be4 (diff) |
perf: Add perf_event_count()
Create a helper function for those sites that want to read the event count.
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>
Diffstat (limited to 'kernel/perf_event.c')
-rw-r--r-- | kernel/perf_event.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index f75c9c9c8177..ab4c0ffc271c 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -1736,6 +1736,11 @@ static void __perf_event_read(void *info) | |||
1736 | event->pmu->read(event); | 1736 | event->pmu->read(event); |
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | static inline u64 perf_event_count(struct perf_event *event) | ||
1740 | { | ||
1741 | return atomic64_read(&event->count); | ||
1742 | } | ||
1743 | |||
1739 | static u64 perf_event_read(struct perf_event *event) | 1744 | static u64 perf_event_read(struct perf_event *event) |
1740 | { | 1745 | { |
1741 | /* | 1746 | /* |
@@ -1755,7 +1760,7 @@ static u64 perf_event_read(struct perf_event *event) | |||
1755 | raw_spin_unlock_irqrestore(&ctx->lock, flags); | 1760 | raw_spin_unlock_irqrestore(&ctx->lock, flags); |
1756 | } | 1761 | } |
1757 | 1762 | ||
1758 | return atomic64_read(&event->count); | 1763 | return perf_event_count(event); |
1759 | } | 1764 | } |
1760 | 1765 | ||
1761 | /* | 1766 | /* |
@@ -2352,7 +2357,7 @@ void perf_event_update_userpage(struct perf_event *event) | |||
2352 | ++userpg->lock; | 2357 | ++userpg->lock; |
2353 | barrier(); | 2358 | barrier(); |
2354 | userpg->index = perf_event_index(event); | 2359 | userpg->index = perf_event_index(event); |
2355 | userpg->offset = atomic64_read(&event->count); | 2360 | userpg->offset = perf_event_count(event); |
2356 | if (event->state == PERF_EVENT_STATE_ACTIVE) | 2361 | if (event->state == PERF_EVENT_STATE_ACTIVE) |
2357 | userpg->offset -= atomic64_read(&event->hw.prev_count); | 2362 | userpg->offset -= atomic64_read(&event->hw.prev_count); |
2358 | 2363 | ||
@@ -3211,7 +3216,7 @@ static void perf_output_read_one(struct perf_output_handle *handle, | |||
3211 | u64 values[4]; | 3216 | u64 values[4]; |
3212 | int n = 0; | 3217 | int n = 0; |
3213 | 3218 | ||
3214 | values[n++] = atomic64_read(&event->count); | 3219 | values[n++] = perf_event_count(event); |
3215 | if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) { | 3220 | if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) { |
3216 | values[n++] = event->total_time_enabled + | 3221 | values[n++] = event->total_time_enabled + |
3217 | atomic64_read(&event->child_total_time_enabled); | 3222 | atomic64_read(&event->child_total_time_enabled); |
@@ -3248,7 +3253,7 @@ static void perf_output_read_group(struct perf_output_handle *handle, | |||
3248 | if (leader != event) | 3253 | if (leader != event) |
3249 | leader->pmu->read(leader); | 3254 | leader->pmu->read(leader); |
3250 | 3255 | ||
3251 | values[n++] = atomic64_read(&leader->count); | 3256 | values[n++] = perf_event_count(leader); |
3252 | if (read_format & PERF_FORMAT_ID) | 3257 | if (read_format & PERF_FORMAT_ID) |
3253 | values[n++] = primary_event_id(leader); | 3258 | values[n++] = primary_event_id(leader); |
3254 | 3259 | ||
@@ -3260,7 +3265,7 @@ static void perf_output_read_group(struct perf_output_handle *handle, | |||
3260 | if (sub != event) | 3265 | if (sub != event) |
3261 | sub->pmu->read(sub); | 3266 | sub->pmu->read(sub); |
3262 | 3267 | ||
3263 | values[n++] = atomic64_read(&sub->count); | 3268 | values[n++] = perf_event_count(sub); |
3264 | if (read_format & PERF_FORMAT_ID) | 3269 | if (read_format & PERF_FORMAT_ID) |
3265 | values[n++] = primary_event_id(sub); | 3270 | values[n++] = primary_event_id(sub); |
3266 | 3271 | ||
@@ -5369,7 +5374,7 @@ static void sync_child_event(struct perf_event *child_event, | |||
5369 | if (child_event->attr.inherit_stat) | 5374 | if (child_event->attr.inherit_stat) |
5370 | perf_event_read_event(child_event, child); | 5375 | perf_event_read_event(child_event, child); |
5371 | 5376 | ||
5372 | child_val = atomic64_read(&child_event->count); | 5377 | child_val = perf_event_count(child_event); |
5373 | 5378 | ||
5374 | /* | 5379 | /* |
5375 | * Add back the child's count to the parent's count: | 5380 | * Add back the child's count to the parent's count: |