Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350000
b: refs/heads/master
c: c7a79c4
h: refs/heads/master
v: v3
  • Loading branch information
Stephane Eranian authored and Arnaldo Carvalho de Melo committed Jan 30, 2013
1 parent 8452e30 commit 7df269b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 79d824e31692d165f6c7d92bf4d1af0b9d969d76
refs/heads/master: c7a79c47c683de6979a3e1a96dc723b0606c07ca
26 changes: 26 additions & 0 deletions trunk/tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,28 @@ void perf_evsel__delete(struct perf_evsel *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 cpu, int thread, bool scale)
{
Expand All @@ -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)
return -errno;

compute_deltas(evsel, cpu, &count);

if (scale) {
if (count.run == 0)
count.val = 0;
Expand Down Expand Up @@ -712,6 +736,8 @@ int __perf_evsel__read(struct perf_evsel *evsel,
}
}

compute_deltas(evsel, -1, aggr);

evsel->counts->scaled = 0;
if (scale) {
if (aggr->run == 0) {
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct perf_evsel {
struct xyarray *sample_id;
u64 *id;
struct perf_counts *counts;
struct perf_counts *prev_raw_counts;
int idx;
u32 ids;
struct hists hists;
Expand Down

0 comments on commit 7df269b

Please sign in to comment.