diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-06-22 10:35:24 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-25 15:39:06 -0400 |
commit | 194002b274e9169a04beb1b23dcc132159bb566c (patch) | |
tree | 6977e48df4a1429dae999d4afe23e5e28febc99e /kernel/perf_counter.c | |
parent | 7f8b4e4e0988dadfd22330fd147ad2453e19f510 (diff) |
perf_counter, x86: Add mmap counter read support
Update the mmap control page with the needed information to
use the userspace RDPMC instruction for self monitoring.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r-- | kernel/perf_counter.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 23614adab475..02994a719e27 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -1753,6 +1753,14 @@ int perf_counter_task_disable(void) | |||
1753 | return 0; | 1753 | return 0; |
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | static int perf_counter_index(struct perf_counter *counter) | ||
1757 | { | ||
1758 | if (counter->state != PERF_COUNTER_STATE_ACTIVE) | ||
1759 | return 0; | ||
1760 | |||
1761 | return counter->hw.idx + 1 - PERF_COUNTER_INDEX_OFFSET; | ||
1762 | } | ||
1763 | |||
1756 | /* | 1764 | /* |
1757 | * Callers need to ensure there can be no nesting of this function, otherwise | 1765 | * Callers need to ensure there can be no nesting of this function, otherwise |
1758 | * the seqlock logic goes bad. We can not serialize this because the arch | 1766 | * the seqlock logic goes bad. We can not serialize this because the arch |
@@ -1777,7 +1785,7 @@ void perf_counter_update_userpage(struct perf_counter *counter) | |||
1777 | preempt_disable(); | 1785 | preempt_disable(); |
1778 | ++userpg->lock; | 1786 | ++userpg->lock; |
1779 | barrier(); | 1787 | barrier(); |
1780 | userpg->index = counter->hw.idx; | 1788 | userpg->index = perf_counter_index(counter); |
1781 | userpg->offset = atomic64_read(&counter->count); | 1789 | userpg->offset = atomic64_read(&counter->count); |
1782 | if (counter->state == PERF_COUNTER_STATE_ACTIVE) | 1790 | if (counter->state == PERF_COUNTER_STATE_ACTIVE) |
1783 | userpg->offset -= atomic64_read(&counter->hw.prev_count); | 1791 | userpg->offset -= atomic64_read(&counter->hw.prev_count); |