perf python: Add cgroup.c to setup.py to get it building again
[deliverable/linux.git] / tools / perf / util / evsel.h
CommitLineData
69aad6f1
ACM
1#ifndef __PERF_EVSEL_H
2#define __PERF_EVSEL_H 1
3
4#include <linux/list.h>
c52b12ed 5#include <stdbool.h>
d030260a 6#include "../../../include/linux/perf_event.h"
69aad6f1
ACM
7#include "types.h"
8#include "xyarray.h"
023695d9 9#include "cgroup.h"
c52b12ed
ACM
10
11struct perf_counts_values {
12 union {
13 struct {
14 u64 val;
15 u64 ena;
16 u64 run;
17 };
18 u64 values[3];
19 };
20};
21
22struct perf_counts {
23 s8 scaled;
24 struct perf_counts_values aggr;
25 struct perf_counts_values cpu[];
26};
69aad6f1 27
70db7533
ACM
28struct perf_evsel;
29
30/*
31 * Per fd, to map back from PERF_SAMPLE_ID to evsel, only used when there are
32 * more than one entry in the evlist.
33 */
34struct perf_sample_id {
35 struct hlist_node node;
36 u64 id;
37 struct perf_evsel *evsel;
38};
39
69aad6f1
ACM
40struct perf_evsel {
41 struct list_head node;
42 struct perf_event_attr attr;
43 char *filter;
44 struct xyarray *fd;
70db7533 45 struct xyarray *id;
c52b12ed 46 struct perf_counts *counts;
69aad6f1
ACM
47 int idx;
48 void *priv;
023695d9 49 struct cgroup_sel *cgrp;
69aad6f1
ACM
50};
51
86bd5e86
ACM
52struct cpu_map;
53struct thread_map;
70082dd9 54struct perf_evlist;
86bd5e86 55
23a2f3ab 56struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx);
ef1d1af2
ACM
57void perf_evsel__init(struct perf_evsel *evsel,
58 struct perf_event_attr *attr, int idx);
59void perf_evsel__exit(struct perf_evsel *evsel);
69aad6f1
ACM
60void perf_evsel__delete(struct perf_evsel *evsel);
61
62int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
70db7533 63int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
c52b12ed 64int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus);
69aad6f1 65void perf_evsel__free_fd(struct perf_evsel *evsel);
70db7533 66void perf_evsel__free_id(struct perf_evsel *evsel);
c52b12ed 67void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads);
69aad6f1 68
f08199d3 69int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
9d04f178 70 struct cpu_map *cpus, bool group, bool inherit);
f08199d3 71int perf_evsel__open_per_thread(struct perf_evsel *evsel,
9d04f178 72 struct thread_map *threads, bool group, bool inherit);
f08199d3 73int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
9d04f178 74 struct thread_map *threads, bool group, bool inherit);
48290609 75
daec78a0
ACM
76#define perf_evsel__match(evsel, t, c) \
77 (evsel->attr.type == PERF_TYPE_##t && \
78 evsel->attr.config == PERF_COUNT_##c)
79
c52b12ed
ACM
80int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
81 int cpu, int thread, bool scale);
82
83/**
84 * perf_evsel__read_on_cpu - Read out the results on a CPU and thread
85 *
86 * @evsel - event selector to read value
87 * @cpu - CPU of interest
88 * @thread - thread of interest
89 */
90static inline int perf_evsel__read_on_cpu(struct perf_evsel *evsel,
91 int cpu, int thread)
92{
93 return __perf_evsel__read_on_cpu(evsel, cpu, thread, false);
94}
95
96/**
97 * perf_evsel__read_on_cpu_scaled - Read out the results on a CPU and thread, scaled
98 *
99 * @evsel - event selector to read value
100 * @cpu - CPU of interest
101 * @thread - thread of interest
102 */
103static inline int perf_evsel__read_on_cpu_scaled(struct perf_evsel *evsel,
104 int cpu, int thread)
105{
106 return __perf_evsel__read_on_cpu(evsel, cpu, thread, true);
107}
108
109int __perf_evsel__read(struct perf_evsel *evsel, int ncpus, int nthreads,
110 bool scale);
111
112/**
113 * perf_evsel__read - Read the aggregate results on all CPUs
114 *
115 * @evsel - event selector to read value
116 * @ncpus - Number of cpus affected, from zero
117 * @nthreads - Number of threads affected, from zero
118 */
119static inline int perf_evsel__read(struct perf_evsel *evsel,
120 int ncpus, int nthreads)
121{
122 return __perf_evsel__read(evsel, ncpus, nthreads, false);
123}
124
125/**
126 * perf_evsel__read_scaled - Read the aggregate results on all CPUs, scaled
127 *
128 * @evsel - event selector to read value
129 * @ncpus - Number of cpus affected, from zero
130 * @nthreads - Number of threads affected, from zero
131 */
132static inline int perf_evsel__read_scaled(struct perf_evsel *evsel,
133 int ncpus, int nthreads)
134{
135 return __perf_evsel__read(evsel, ncpus, nthreads, true);
136}
137
69aad6f1 138#endif /* __PERF_EVSEL_H */
This page took 0.0586 seconds and 5 git commands to generate.