if (!evsel->snapshot)
perf_evsel__compute_deltas(evsel, cpu, count);
perf_counts_values__scale(count, scale, NULL);
- evsel->counts->cpu[cpu] = *count;
+ *perf_counts(evsel->counts, cpu) = *count;
if (aggr_mode == AGGR_NONE)
perf_stat__update_shadow_stats(evsel, count->values, cpu);
break;
s2 = aggr_get_id(evsel_list->cpus, cpu2);
if (s2 != id)
continue;
- val += counter->counts->cpu[cpu].val;
- ena += counter->counts->cpu[cpu].ena;
- run += counter->counts->cpu[cpu].run;
+ val += perf_counts(counter->counts, cpu)->val;
+ ena += perf_counts(counter->counts, cpu)->ena;
+ run += perf_counts(counter->counts, cpu)->run;
nr++;
}
if (prefix)
int cpu;
for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) {
- val = counter->counts->cpu[cpu].val;
- ena = counter->counts->cpu[cpu].ena;
- run = counter->counts->cpu[cpu].run;
+ val = perf_counts(counter->counts, cpu)->val;
+ ena = perf_counts(counter->counts, cpu)->ena;
+ run = perf_counts(counter->counts, cpu)->run;
if (prefix)
fprintf(output, "%s", prefix);
}
expected = nr_openat_calls + cpu;
- if (evsel->counts->cpu[cpu].val != expected) {
+ if (perf_counts(evsel->counts, cpu)->val != expected) {
pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n",
- expected, cpus->map[cpu], evsel->counts->cpu[cpu].val);
+ expected, cpus->map[cpu], perf_counts(evsel->counts, cpu)->val);
err = -1;
}
}
goto out_close_fd;
}
- if (evsel->counts->cpu[0].val != nr_openat_calls) {
+ if (perf_counts(evsel->counts, 0)->val != nr_openat_calls) {
pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n",
nr_openat_calls, evsel->counts->cpu[0].val);
goto out_close_fd;
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;
+ tmp = *perf_counts(evsel->prev_raw_counts, cpu);
+ *perf_counts(evsel->prev_raw_counts, cpu) = *count;
}
count->val = count->val - tmp.val;
perf_evsel__compute_deltas(evsel, cpu, &count);
perf_counts_values__scale(&count, scale, NULL);
- evsel->counts->cpu[cpu] = count;
+ *perf_counts(evsel->counts, cpu) = count;
return 0;
}
#include "xyarray.h"
#include "symbol.h"
#include "cpumap.h"
-
-struct perf_counts_values {
- union {
- struct {
- u64 val;
- u64 ena;
- u64 run;
- };
- u64 values[3];
- };
-};
-
-struct perf_counts {
- s8 scaled;
- struct perf_counts_values aggr;
- struct perf_counts_values cpu[];
-};
+#include "stat.h"
struct perf_evsel;
AGGR_CORE,
};
+struct perf_counts_values {
+ union {
+ struct {
+ u64 val;
+ u64 ena;
+ u64 run;
+ };
+ u64 values[3];
+ };
+};
+
+struct perf_counts {
+ s8 scaled;
+ struct perf_counts_values aggr;
+ struct perf_counts_values cpu[];
+};
+
+static inline struct perf_counts_values*
+perf_counts(struct perf_counts *counts, int cpu)
+{
+ return &counts->cpu[cpu];
+}
+
void update_stats(struct stats *stats, u64 val);
double avg_stats(struct stats *stats);
double stddev_stats(struct stats *stats);