diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-12-14 12:22:31 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-14 20:30:50 +0100 |
commit | 8cb391e8786c8072367f0aeb90551903fef074ba (patch) | |
tree | b72c8532b26f7a23780d336b2b4506b4bb9180c4 | |
parent | 9b51f66dcb09ac5eb6bc68fc111d5c7a1e0131d6 (diff) |
perfcounters: fix task clock counter
Impact: bugfix
Update the task clock counter to the new math.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/perf_counter.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index f5e81dd193d1..1f81cde0dc43 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c @@ -850,17 +850,36 @@ static const struct hw_perf_counter_ops perf_ops_cpu_clock = { .hw_perf_counter_read = cpu_clock_perf_counter_read, }; -static void task_clock_perf_counter_enable(struct perf_counter *counter) +static void task_clock_perf_counter_update(struct perf_counter *counter) { + u64 prev, now; + s64 delta; + + prev = atomic64_read(&counter->hw.prev_count); + now = current->se.sum_exec_runtime; + + atomic64_set(&counter->hw.prev_count, now); + + delta = now - prev; + if (WARN_ON_ONCE(delta < 0)) + delta = 0; + + atomic64_add(delta, &counter->count); } -static void task_clock_perf_counter_disable(struct perf_counter *counter) +static void task_clock_perf_counter_read(struct perf_counter *counter) { + task_clock_perf_counter_update(counter); } -static void task_clock_perf_counter_read(struct perf_counter *counter) +static void task_clock_perf_counter_enable(struct perf_counter *counter) +{ + atomic64_set(&counter->hw.prev_count, current->se.sum_exec_runtime); +} + +static void task_clock_perf_counter_disable(struct perf_counter *counter) { - atomic64_set(&counter->count, current->se.sum_exec_runtime); + task_clock_perf_counter_update(counter); } static const struct hw_perf_counter_ops perf_ops_task_clock = { |