1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/zalloc.h>
8 struct perf_counts *perf_counts__new(int ncpus, int nthreads)
10 struct perf_counts *counts = zalloc(sizeof(*counts));
13 struct xyarray *values;
15 values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values));
21 counts->values = values;
23 values = xyarray__new(ncpus, nthreads, sizeof(bool));
25 xyarray__delete(counts->values);
30 counts->loaded = values;
36 void perf_counts__delete(struct perf_counts *counts)
39 xyarray__delete(counts->loaded);
40 xyarray__delete(counts->values);
45 static void perf_counts__reset(struct perf_counts *counts)
47 xyarray__reset(counts->loaded);
48 xyarray__reset(counts->values);
51 void perf_evsel__reset_counts(struct evsel *evsel)
53 perf_counts__reset(evsel->counts);
56 int perf_evsel__alloc_counts(struct evsel *evsel, int ncpus, int nthreads)
58 evsel->counts = perf_counts__new(ncpus, nthreads);
59 return evsel->counts != NULL ? 0 : -ENOMEM;
62 void perf_evsel__free_counts(struct evsel *evsel)
64 perf_counts__delete(evsel->counts);