Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jiri Olsa | d809560 | 2015-08-07 12:51:03 +0200 | [diff] [blame] | 2 | #ifndef __PERF_COUNTS_H |
| 3 | #define __PERF_COUNTS_H |
| 4 | |
Arnaldo Carvalho de Melo | 2d64ae9 | 2019-08-21 11:56:13 -0300 | [diff] [blame] | 5 | #include <linux/types.h> |
Jiri Olsa | 4b247fa | 2019-07-21 13:24:44 +0200 | [diff] [blame] | 6 | #include <internal/xyarray.h> |
Jiri Olsa | 5c30af9 | 2019-07-21 13:24:51 +0200 | [diff] [blame] | 7 | #include <perf/evsel.h> |
Arnaldo Carvalho de Melo | 2d64ae9 | 2019-08-21 11:56:13 -0300 | [diff] [blame] | 8 | #include <stdbool.h> |
| 9 | |
| 10 | struct evsel; |
Jiri Olsa | d809560 | 2015-08-07 12:51:03 +0200 | [diff] [blame] | 11 | |
| 12 | struct perf_counts { |
| 13 | s8 scaled; |
| 14 | struct perf_counts_values aggr; |
| 15 | struct xyarray *values; |
Jiri Olsa | df1d685 | 2019-07-21 13:23:48 +0200 | [diff] [blame] | 16 | struct xyarray *loaded; |
Jiri Olsa | d809560 | 2015-08-07 12:51:03 +0200 | [diff] [blame] | 17 | }; |
| 18 | |
| 19 | |
| 20 | static inline struct perf_counts_values* |
Ian Rogers | 7316268 | 2022-01-04 22:13:32 -0800 | [diff] [blame] | 21 | perf_counts(struct perf_counts *counts, int cpu_map_idx, int thread) |
Jiri Olsa | d809560 | 2015-08-07 12:51:03 +0200 | [diff] [blame] | 22 | { |
Ian Rogers | 7316268 | 2022-01-04 22:13:32 -0800 | [diff] [blame] | 23 | return xyarray__entry(counts->values, cpu_map_idx, thread); |
Jiri Olsa | d809560 | 2015-08-07 12:51:03 +0200 | [diff] [blame] | 24 | } |
| 25 | |
Jiri Olsa | df1d685 | 2019-07-21 13:23:48 +0200 | [diff] [blame] | 26 | static inline bool |
Ian Rogers | 7316268 | 2022-01-04 22:13:32 -0800 | [diff] [blame] | 27 | perf_counts__is_loaded(struct perf_counts *counts, int cpu_map_idx, int thread) |
Jiri Olsa | df1d685 | 2019-07-21 13:23:48 +0200 | [diff] [blame] | 28 | { |
Ian Rogers | 7316268 | 2022-01-04 22:13:32 -0800 | [diff] [blame] | 29 | return *((bool *) xyarray__entry(counts->loaded, cpu_map_idx, thread)); |
Jiri Olsa | df1d685 | 2019-07-21 13:23:48 +0200 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | static inline void |
Ian Rogers | 7316268 | 2022-01-04 22:13:32 -0800 | [diff] [blame] | 33 | perf_counts__set_loaded(struct perf_counts *counts, int cpu_map_idx, int thread, bool loaded) |
Jiri Olsa | df1d685 | 2019-07-21 13:23:48 +0200 | [diff] [blame] | 34 | { |
Ian Rogers | 7316268 | 2022-01-04 22:13:32 -0800 | [diff] [blame] | 35 | *((bool *) xyarray__entry(counts->loaded, cpu_map_idx, thread)) = loaded; |
Jiri Olsa | df1d685 | 2019-07-21 13:23:48 +0200 | [diff] [blame] | 36 | } |
| 37 | |
Jiri Olsa | d809560 | 2015-08-07 12:51:03 +0200 | [diff] [blame] | 38 | struct perf_counts *perf_counts__new(int ncpus, int nthreads); |
| 39 | void perf_counts__delete(struct perf_counts *counts); |
Jin Yao | cf4d9bd | 2020-05-20 12:27:34 +0800 | [diff] [blame] | 40 | void perf_counts__reset(struct perf_counts *counts); |
Jiri Olsa | d809560 | 2015-08-07 12:51:03 +0200 | [diff] [blame] | 41 | |
Arnaldo Carvalho de Melo | 7d1e239 | 2020-05-06 13:38:26 -0300 | [diff] [blame] | 42 | void evsel__reset_counts(struct evsel *evsel); |
Ian Rogers | 2ca0a37 | 2022-01-04 22:13:29 -0800 | [diff] [blame] | 43 | int evsel__alloc_counts(struct evsel *evsel); |
Arnaldo Carvalho de Melo | 7d1e239 | 2020-05-06 13:38:26 -0300 | [diff] [blame] | 44 | void evsel__free_counts(struct evsel *evsel); |
Jiri Olsa | d809560 | 2015-08-07 12:51:03 +0200 | [diff] [blame] | 45 | |
| 46 | #endif /* __PERF_COUNTS_H */ |