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