diff options
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/evsel.c | 26 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e45332d08a58..dbdcca43cac6 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -659,6 +659,28 @@ void perf_evsel__delete(struct perf_evsel *evsel) | |||
659 | free(evsel); | 659 | free(evsel); |
660 | } | 660 | } |
661 | 661 | ||
662 | static inline void compute_deltas(struct perf_evsel *evsel, | ||
663 | int cpu, | ||
664 | struct perf_counts_values *count) | ||
665 | { | ||
666 | struct perf_counts_values tmp; | ||
667 | |||
668 | if (!evsel->prev_raw_counts) | ||
669 | return; | ||
670 | |||
671 | if (cpu == -1) { | ||
672 | tmp = evsel->prev_raw_counts->aggr; | ||
673 | evsel->prev_raw_counts->aggr = *count; | ||
674 | } else { | ||
675 | tmp = evsel->prev_raw_counts->cpu[cpu]; | ||
676 | evsel->prev_raw_counts->cpu[cpu] = *count; | ||
677 | } | ||
678 | |||
679 | count->val = count->val - tmp.val; | ||
680 | count->ena = count->ena - tmp.ena; | ||
681 | count->run = count->run - tmp.run; | ||
682 | } | ||
683 | |||
662 | int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, | 684 | int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, |
663 | int cpu, int thread, bool scale) | 685 | int cpu, int thread, bool scale) |
664 | { | 686 | { |
@@ -674,6 +696,8 @@ int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, | |||
674 | if (readn(FD(evsel, cpu, thread), &count, nv * sizeof(u64)) < 0) | 696 | if (readn(FD(evsel, cpu, thread), &count, nv * sizeof(u64)) < 0) |
675 | return -errno; | 697 | return -errno; |
676 | 698 | ||
699 | compute_deltas(evsel, cpu, &count); | ||
700 | |||
677 | if (scale) { | 701 | if (scale) { |
678 | if (count.run == 0) | 702 | if (count.run == 0) |
679 | count.val = 0; | 703 | count.val = 0; |
@@ -712,6 +736,8 @@ int __perf_evsel__read(struct perf_evsel *evsel, | |||
712 | } | 736 | } |
713 | } | 737 | } |
714 | 738 | ||
739 | compute_deltas(evsel, -1, aggr); | ||
740 | |||
715 | evsel->counts->scaled = 0; | 741 | evsel->counts->scaled = 0; |
716 | if (scale) { | 742 | if (scale) { |
717 | if (aggr->run == 0) { | 743 | if (aggr->run == 0) { |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index c68d1b82e843..3a4cd60044ea 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -53,6 +53,7 @@ struct perf_evsel { | |||
53 | struct xyarray *sample_id; | 53 | struct xyarray *sample_id; |
54 | u64 *id; | 54 | u64 *id; |
55 | struct perf_counts *counts; | 55 | struct perf_counts *counts; |
56 | struct perf_counts *prev_raw_counts; | ||
56 | int idx; | 57 | int idx; |
57 | u32 ids; | 58 | u32 ids; |
58 | struct hists hists; | 59 | struct hists hists; |