Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.38-rc1 115 lines 3.1 kB view raw
1#ifndef __PERF_EVSEL_H 2#define __PERF_EVSEL_H 1 3 4#include <linux/list.h> 5#include <stdbool.h> 6#include "../../../include/linux/perf_event.h" 7#include "types.h" 8#include "xyarray.h" 9 10struct perf_counts_values { 11 union { 12 struct { 13 u64 val; 14 u64 ena; 15 u64 run; 16 }; 17 u64 values[3]; 18 }; 19}; 20 21struct perf_counts { 22 s8 scaled; 23 struct perf_counts_values aggr; 24 struct perf_counts_values cpu[]; 25}; 26 27struct perf_evsel { 28 struct list_head node; 29 struct perf_event_attr attr; 30 char *filter; 31 struct xyarray *fd; 32 struct perf_counts *counts; 33 int idx; 34 void *priv; 35}; 36 37struct cpu_map; 38struct thread_map; 39 40struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx); 41void perf_evsel__delete(struct perf_evsel *evsel); 42 43int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 44int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus); 45void perf_evsel__free_fd(struct perf_evsel *evsel); 46void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads); 47 48int perf_evsel__open_per_cpu(struct perf_evsel *evsel, struct cpu_map *cpus); 49int perf_evsel__open_per_thread(struct perf_evsel *evsel, struct thread_map *threads); 50int perf_evsel__open(struct perf_evsel *evsel, 51 struct cpu_map *cpus, struct thread_map *threads); 52 53#define perf_evsel__match(evsel, t, c) \ 54 (evsel->attr.type == PERF_TYPE_##t && \ 55 evsel->attr.config == PERF_COUNT_##c) 56 57int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, 58 int cpu, int thread, bool scale); 59 60/** 61 * perf_evsel__read_on_cpu - Read out the results on a CPU and thread 62 * 63 * @evsel - event selector to read value 64 * @cpu - CPU of interest 65 * @thread - thread of interest 66 */ 67static inline int perf_evsel__read_on_cpu(struct perf_evsel *evsel, 68 int cpu, int thread) 69{ 70 return __perf_evsel__read_on_cpu(evsel, cpu, thread, false); 71} 72 73/** 74 * perf_evsel__read_on_cpu_scaled - Read out the results on a CPU and thread, scaled 75 * 76 * @evsel - event selector to read value 77 * @cpu - CPU of interest 78 * @thread - thread of interest 79 */ 80static inline int perf_evsel__read_on_cpu_scaled(struct perf_evsel *evsel, 81 int cpu, int thread) 82{ 83 return __perf_evsel__read_on_cpu(evsel, cpu, thread, true); 84} 85 86int __perf_evsel__read(struct perf_evsel *evsel, int ncpus, int nthreads, 87 bool scale); 88 89/** 90 * perf_evsel__read - Read the aggregate results on all CPUs 91 * 92 * @evsel - event selector to read value 93 * @ncpus - Number of cpus affected, from zero 94 * @nthreads - Number of threads affected, from zero 95 */ 96static inline int perf_evsel__read(struct perf_evsel *evsel, 97 int ncpus, int nthreads) 98{ 99 return __perf_evsel__read(evsel, ncpus, nthreads, false); 100} 101 102/** 103 * perf_evsel__read_scaled - Read the aggregate results on all CPUs, scaled 104 * 105 * @evsel - event selector to read value 106 * @ncpus - Number of cpus affected, from zero 107 * @nthreads - Number of threads affected, from zero 108 */ 109static inline int perf_evsel__read_scaled(struct perf_evsel *evsel, 110 int ncpus, int nthreads) 111{ 112 return __perf_evsel__read(evsel, ncpus, nthreads, true); 113} 114 115#endif /* __PERF_EVSEL_H */