1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __PERF_COUNTS_H 3 #define __PERF_COUNTS_H 4 5 #include <internal/xyarray.h> 6 #include <perf/evsel.h> 7 8 struct perf_counts { 9 s8 scaled; 10 struct perf_counts_values aggr; 11 struct xyarray *values; 12 struct xyarray *loaded; 13 }; 14 15 16 static inline struct perf_counts_values* 17 perf_counts(struct perf_counts *counts, int cpu, int thread) 18 { 19 return xyarray__entry(counts->values, cpu, thread); 20 } 21 22 static inline bool 23 perf_counts__is_loaded(struct perf_counts *counts, int cpu, int thread) 24 { 25 return *((bool *) xyarray__entry(counts->loaded, cpu, thread)); 26 } 27 28 static inline void 29 perf_counts__set_loaded(struct perf_counts *counts, int cpu, int thread, bool loaded) 30 { 31 *((bool *) xyarray__entry(counts->loaded, cpu, thread)) = loaded; 32 } 33 34 struct perf_counts *perf_counts__new(int ncpus, int nthreads); 35 void perf_counts__delete(struct perf_counts *counts); 36 37 void perf_evsel__reset_counts(struct evsel *evsel); 38 int perf_evsel__alloc_counts(struct evsel *evsel, int ncpus, int nthreads); 39 void perf_evsel__free_counts(struct evsel *evsel); 40 41 #endif /* __PERF_COUNTS_H */ 42