1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/zalloc.h>
9 struct perf_counts *perf_counts__new(int ncpus, int nthreads)
11 struct perf_counts *counts = zalloc(sizeof(*counts));
14 struct xyarray *values;
16 values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
22 counts->values = values;
24 values = xyarray__new(ncpus, nthreads, sizeof(bool));
26 xyarray__delete(counts->values);
31 counts->loaded = values;
37 void perf_counts__delete(struct perf_counts *counts)
40 xyarray__delete(counts->loaded);
41 xyarray__delete(counts->values);
46 void perf_counts__reset(struct perf_counts *counts)
48 xyarray__reset(counts->loaded);
49 xyarray__reset(counts->values);
50 memset(&counts->aggr, 0, sizeof(struct perf_counts_values));
53 void evsel__reset_counts(struct evsel *evsel)
55 perf_counts__reset(evsel->counts);
58 int evsel__alloc_counts(struct evsel *evsel, int ncpus, int nthreads)
60 evsel->counts = perf_counts__new(ncpus, nthreads);
61 return evsel->counts != NULL ? 0 : -ENOMEM;
64 void evsel__free_counts(struct evsel *evsel)
66 perf_counts__delete(evsel->counts);