blob: 7ff36bf6d64485c04ae2a77c070b50cbbbba2709 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Jiri Olsad8095602015-08-07 12:51:03 +02002#ifndef __PERF_COUNTS_H
3#define __PERF_COUNTS_H
4
Arnaldo Carvalho de Melo2d64ae92019-08-21 11:56:13 -03005#include <linux/types.h>
Jiri Olsa4b247fa2019-07-21 13:24:44 +02006#include <internal/xyarray.h>
Jiri Olsa5c30af92019-07-21 13:24:51 +02007#include <perf/evsel.h>
Arnaldo Carvalho de Melo2d64ae92019-08-21 11:56:13 -03008#include <stdbool.h>
9
10struct evsel;
Jiri Olsad8095602015-08-07 12:51:03 +020011
12struct perf_counts {
13 s8 scaled;
14 struct perf_counts_values aggr;
15 struct xyarray *values;
Jiri Olsadf1d6852019-07-21 13:23:48 +020016 struct xyarray *loaded;
Jiri Olsad8095602015-08-07 12:51:03 +020017};
18
19
20static inline struct perf_counts_values*
21perf_counts(struct perf_counts *counts, int cpu, int thread)
22{
23 return xyarray__entry(counts->values, cpu, thread);
24}
25
Jiri Olsadf1d6852019-07-21 13:23:48 +020026static inline bool
27perf_counts__is_loaded(struct perf_counts *counts, int cpu, int thread)
28{
29 return *((bool *) xyarray__entry(counts->loaded, cpu, thread));
30}
31
32static inline void
33perf_counts__set_loaded(struct perf_counts *counts, int cpu, int thread, bool loaded)
34{
35 *((bool *) xyarray__entry(counts->loaded, cpu, thread)) = loaded;
36}
37
Jiri Olsad8095602015-08-07 12:51:03 +020038struct perf_counts *perf_counts__new(int ncpus, int nthreads);
39void perf_counts__delete(struct perf_counts *counts);
Jin Yaocf4d9bd2020-05-20 12:27:34 +080040void perf_counts__reset(struct perf_counts *counts);
Jiri Olsad8095602015-08-07 12:51:03 +020041
Arnaldo Carvalho de Melo7d1e2392020-05-06 13:38:26 -030042void evsel__reset_counts(struct evsel *evsel);
43int evsel__alloc_counts(struct evsel *evsel, int ncpus, int nthreads);
44void evsel__free_counts(struct evsel *evsel);
Jiri Olsad8095602015-08-07 12:51:03 +020045
46#endif /* __PERF_COUNTS_H */