diff options
Diffstat (limited to 'kernel/perf_counter.c')
-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 = { | |||
850 | .hw_perf_counter_read = cpu_clock_perf_counter_read, | 850 | .hw_perf_counter_read = cpu_clock_perf_counter_read, |
851 | }; | 851 | }; |
852 | 852 | ||
853 | static void task_clock_perf_counter_enable(struct perf_counter *counter) | 853 | static void task_clock_perf_counter_update(struct perf_counter *counter) |
854 | { | 854 | { |
855 | u64 prev, now; | ||
856 | s64 delta; | ||
857 | |||
858 | prev = atomic64_read(&counter->hw.prev_count); | ||
859 | now = current->se.sum_exec_runtime; | ||
860 | |||
861 | atomic64_set(&counter->hw.prev_count, now); | ||
862 | |||
863 | delta = now - prev; | ||
864 | if (WARN_ON_ONCE(delta < 0)) | ||
865 | delta = 0; | ||
866 | |||
867 | atomic64_add(delta, &counter->count); | ||
855 | } | 868 | } |
856 | 869 | ||
857 | static void task_clock_perf_counter_disable(struct perf_counter *counter) | 870 | static void task_clock_perf_counter_read(struct perf_counter *counter) |
858 | { | 871 | { |
872 | task_clock_perf_counter_update(counter); | ||
859 | } | 873 | } |
860 | 874 | ||
861 | static void task_clock_perf_counter_read(struct perf_counter *counter) | 875 | static void task_clock_perf_counter_enable(struct perf_counter *counter) |
876 | { | ||
877 | atomic64_set(&counter->hw.prev_count, current->se.sum_exec_runtime); | ||
878 | } | ||
879 | |||
880 | static void task_clock_perf_counter_disable(struct perf_counter *counter) | ||
862 | { | 881 | { |
863 | atomic64_set(&counter->count, current->se.sum_exec_runtime); | 882 | task_clock_perf_counter_update(counter); |
864 | } | 883 | } |
865 | 884 | ||
866 | static const struct hw_perf_counter_ops perf_ops_task_clock = { | 885 | static const struct hw_perf_counter_ops perf_ops_task_clock = { |