1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2d809560bSJiri Olsa #ifndef __PERF_COUNTS_H 3d809560bSJiri Olsa #define __PERF_COUNTS_H 4d809560bSJiri Olsa 5*2d64ae9bSArnaldo Carvalho de Melo #include <linux/types.h> 64b247fa7SJiri Olsa #include <internal/xyarray.h> 75c30af92SJiri Olsa #include <perf/evsel.h> 8*2d64ae9bSArnaldo Carvalho de Melo #include <stdbool.h> 9*2d64ae9bSArnaldo Carvalho de Melo 10*2d64ae9bSArnaldo Carvalho de Melo struct evsel; 11d809560bSJiri Olsa 12d809560bSJiri Olsa struct perf_counts { 13d809560bSJiri Olsa s8 scaled; 14d809560bSJiri Olsa struct perf_counts_values aggr; 15d809560bSJiri Olsa struct xyarray *values; 16df1d6856SJiri Olsa struct xyarray *loaded; 17d809560bSJiri Olsa }; 18d809560bSJiri Olsa 19d809560bSJiri Olsa 20d809560bSJiri Olsa static inline struct perf_counts_values* 21d809560bSJiri Olsa perf_counts(struct perf_counts *counts, int cpu, int thread) 22d809560bSJiri Olsa { 23d809560bSJiri Olsa return xyarray__entry(counts->values, cpu, thread); 24d809560bSJiri Olsa } 25d809560bSJiri Olsa 26df1d6856SJiri Olsa static inline bool 27df1d6856SJiri Olsa perf_counts__is_loaded(struct perf_counts *counts, int cpu, int thread) 28df1d6856SJiri Olsa { 29df1d6856SJiri Olsa return *((bool *) xyarray__entry(counts->loaded, cpu, thread)); 30df1d6856SJiri Olsa } 31df1d6856SJiri Olsa 32df1d6856SJiri Olsa static inline void 33df1d6856SJiri Olsa perf_counts__set_loaded(struct perf_counts *counts, int cpu, int thread, bool loaded) 34df1d6856SJiri Olsa { 35df1d6856SJiri Olsa *((bool *) xyarray__entry(counts->loaded, cpu, thread)) = loaded; 36df1d6856SJiri Olsa } 37df1d6856SJiri Olsa 38d809560bSJiri Olsa struct perf_counts *perf_counts__new(int ncpus, int nthreads); 39d809560bSJiri Olsa void perf_counts__delete(struct perf_counts *counts); 40d809560bSJiri Olsa 4132dcd021SJiri Olsa void perf_evsel__reset_counts(struct evsel *evsel); 4232dcd021SJiri Olsa int perf_evsel__alloc_counts(struct evsel *evsel, int ncpus, int nthreads); 4332dcd021SJiri Olsa void perf_evsel__free_counts(struct evsel *evsel); 44d809560bSJiri Olsa 45d809560bSJiri Olsa #endif /* __PERF_COUNTS_H */ 46