diff options
author | Stephane Eranian <eranian@google.com> | 2013-01-29 06:47:43 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-30 08:36:38 -0500 |
commit | c7a79c47c683de6979a3e1a96dc723b0606c07ca (patch) | |
tree | ad9a8b84c07b1c97253157dbcfd2ab53a7098375 /tools | |
parent | 79d824e31692d165f6c7d92bf4d1af0b9d969d76 (diff) |
perf evsel: Add prev_raw_count field
This field will be used by commands which print counter deltas on
regular timer intervals, such as perf stat -I.
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1359460064-3060-2-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-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; |