0001
0002 #ifndef __PERF_COUNTS_H
0003 #define __PERF_COUNTS_H
0004
0005 #include <linux/types.h>
0006 #include <internal/xyarray.h>
0007 #include <perf/evsel.h>
0008 #include <stdbool.h>
0009
0010 struct evsel;
0011
0012 struct perf_counts {
0013 s8 scaled;
0014 struct perf_counts_values aggr;
0015 struct xyarray *values;
0016 struct xyarray *loaded;
0017 };
0018
0019
0020 static inline struct perf_counts_values*
0021 perf_counts(struct perf_counts *counts, int cpu_map_idx, int thread)
0022 {
0023 return xyarray__entry(counts->values, cpu_map_idx, thread);
0024 }
0025
0026 static inline bool
0027 perf_counts__is_loaded(struct perf_counts *counts, int cpu_map_idx, int thread)
0028 {
0029 return *((bool *) xyarray__entry(counts->loaded, cpu_map_idx, thread));
0030 }
0031
0032 static inline void
0033 perf_counts__set_loaded(struct perf_counts *counts, int cpu_map_idx, int thread, bool loaded)
0034 {
0035 *((bool *) xyarray__entry(counts->loaded, cpu_map_idx, thread)) = loaded;
0036 }
0037
0038 struct perf_counts *perf_counts__new(int ncpus, int nthreads);
0039 void perf_counts__delete(struct perf_counts *counts);
0040 void perf_counts__reset(struct perf_counts *counts);
0041
0042 void evsel__reset_counts(struct evsel *evsel);
0043 int evsel__alloc_counts(struct evsel *evsel);
0044 void evsel__free_counts(struct evsel *evsel);
0045
0046 #endif