diff options
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r-- | kernel/perf_counter.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 4be1a8d872b4..b7a027a2ef02 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
@@ -928,18 +928,32 @@ static const struct file_operations perf_fops = { | |||
928 | 928 | ||
929 | static int cpu_clock_perf_counter_enable(struct perf_counter *counter) | 929 | static int cpu_clock_perf_counter_enable(struct perf_counter *counter) |
930 | { | 930 | { |
931 | int cpu = raw_smp_processor_id(); | ||
932 | |||
933 | atomic64_set(&counter->hw.prev_count, cpu_clock(cpu)); | ||
931 | return 0; | 934 | return 0; |
932 | } | 935 | } |
933 | 936 | ||
937 | static void cpu_clock_perf_counter_update(struct perf_counter *counter) | ||
938 | { | ||
939 | int cpu = raw_smp_processor_id(); | ||
940 | s64 prev; | ||
941 | u64 now; | ||
942 | |||
943 | now = cpu_clock(cpu); | ||
944 | prev = atomic64_read(&counter->hw.prev_count); | ||
945 | atomic64_set(&counter->hw.prev_count, now); | ||
946 | atomic64_add(now - prev, &counter->count); | ||
947 | } | ||
948 | |||
934 | static void cpu_clock_perf_counter_disable(struct perf_counter *counter) | 949 | static void cpu_clock_perf_counter_disable(struct perf_counter *counter) |
935 | { | 950 | { |
951 | cpu_clock_perf_counter_update(counter); | ||
936 | } | 952 | } |
937 | 953 | ||
938 | static void cpu_clock_perf_counter_read(struct perf_counter *counter) | 954 | static void cpu_clock_perf_counter_read(struct perf_counter *counter) |
939 | { | 955 | { |
940 | int cpu = raw_smp_processor_id(); | 956 | cpu_clock_perf_counter_update(counter); |
941 | |||
942 | atomic64_set(&counter->count, cpu_clock(cpu)); | ||
943 | } | 957 | } |
944 | 958 | ||
945 | static const struct hw_perf_counter_ops perf_ops_cpu_clock = { | 959 | static const struct hw_perf_counter_ops perf_ops_cpu_clock = { |