Commit c7a79c47 authored by Stephane Eranian's avatar Stephane Eranian Committed by Arnaldo Carvalho de Melo

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: default avatarStephane 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 79d824e3
...@@ -659,6 +659,28 @@ void perf_evsel__delete(struct perf_evsel *evsel) ...@@ -659,6 +659,28 @@ void perf_evsel__delete(struct perf_evsel *evsel)
free(evsel); free(evsel);
} }
static inline void compute_deltas(struct perf_evsel *evsel,
int cpu,
struct perf_counts_values *count)
{
struct perf_counts_values tmp;
if (!evsel->prev_raw_counts)
return;
if (cpu == -1) {
tmp = evsel->prev_raw_counts->aggr;
evsel->prev_raw_counts->aggr = *count;
} else {
tmp = evsel->prev_raw_counts->cpu[cpu];
evsel->prev_raw_counts->cpu[cpu] = *count;
}
count->val = count->val - tmp.val;
count->ena = count->ena - tmp.ena;
count->run = count->run - tmp.run;
}
int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
int cpu, int thread, bool scale) int cpu, int thread, bool scale)
{ {
...@@ -674,6 +696,8 @@ int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, ...@@ -674,6 +696,8 @@ int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
if (readn(FD(evsel, cpu, thread), &count, nv * sizeof(u64)) < 0) if (readn(FD(evsel, cpu, thread), &count, nv * sizeof(u64)) < 0)
return -errno; return -errno;
compute_deltas(evsel, cpu, &count);
if (scale) { if (scale) {
if (count.run == 0) if (count.run == 0)
count.val = 0; count.val = 0;
...@@ -712,6 +736,8 @@ int __perf_evsel__read(struct perf_evsel *evsel, ...@@ -712,6 +736,8 @@ int __perf_evsel__read(struct perf_evsel *evsel,
} }
} }
compute_deltas(evsel, -1, aggr);
evsel->counts->scaled = 0; evsel->counts->scaled = 0;
if (scale) { if (scale) {
if (aggr->run == 0) { if (aggr->run == 0) {
......
...@@ -53,6 +53,7 @@ struct perf_evsel { ...@@ -53,6 +53,7 @@ struct perf_evsel {
struct xyarray *sample_id; struct xyarray *sample_id;
u64 *id; u64 *id;
struct perf_counts *counts; struct perf_counts *counts;
struct perf_counts *prev_raw_counts;
int idx; int idx;
u32 ids; u32 ids;
struct hists hists; struct hists hists;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment