]> git.ipfire.org Git - thirdparty/kernel/linux.git/blob - tools/perf/util/env.h
perf bpf: Save bpf_prog_info in a rbtree in perf_env
[thirdparty/kernel/linux.git] / tools / perf / util / env.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_ENV_H
3 #define __PERF_ENV_H
4
5 #include <linux/types.h>
6 #include <linux/rbtree.h>
7 #include "cpumap.h"
8 #include "rwsem.h"
9
10 struct cpu_topology_map {
11 int socket_id;
12 int core_id;
13 };
14
15 struct cpu_cache_level {
16 u32 level;
17 u32 line_size;
18 u32 sets;
19 u32 ways;
20 char *type;
21 char *size;
22 char *map;
23 };
24
25 struct numa_node {
26 u32 node;
27 u64 mem_total;
28 u64 mem_free;
29 struct cpu_map *map;
30 };
31
32 struct memory_node {
33 u64 node;
34 u64 size;
35 unsigned long *set;
36 };
37
38 struct perf_env {
39 char *hostname;
40 char *os_release;
41 char *version;
42 char *arch;
43 int nr_cpus_online;
44 int nr_cpus_avail;
45 char *cpu_desc;
46 char *cpuid;
47 unsigned long long total_mem;
48 unsigned int msr_pmu_type;
49
50 int nr_cmdline;
51 int nr_sibling_cores;
52 int nr_sibling_threads;
53 int nr_numa_nodes;
54 int nr_memory_nodes;
55 int nr_pmu_mappings;
56 int nr_groups;
57 char *cmdline;
58 const char **cmdline_argv;
59 char *sibling_cores;
60 char *sibling_threads;
61 char *pmu_mappings;
62 struct cpu_topology_map *cpu;
63 struct cpu_cache_level *caches;
64 int caches_cnt;
65 struct numa_node *numa_nodes;
66 struct memory_node *memory_nodes;
67 unsigned long long memory_bsize;
68 u64 clockid_res_ns;
69
70 /*
71 * bpf_info_lock protects bpf rbtrees. This is needed because the
72 * trees are accessed by different threads in perf-top
73 */
74 struct {
75 struct rw_semaphore lock;
76 struct rb_root infos;
77 u32 infos_cnt;
78 } bpf_progs;
79 };
80
81 struct bpf_prog_info_node;
82
83 extern struct perf_env perf_env;
84
85 void perf_env__exit(struct perf_env *env);
86
87 int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]);
88
89 int perf_env__read_cpu_topology_map(struct perf_env *env);
90
91 void cpu_cache_level__free(struct cpu_cache_level *cache);
92
93 const char *perf_env__arch(struct perf_env *env);
94 const char *perf_env__raw_arch(struct perf_env *env);
95 int perf_env__nr_cpus_avail(struct perf_env *env);
96
97 void perf_env__init(struct perf_env *env);
98 void perf_env__insert_bpf_prog_info(struct perf_env *env,
99 struct bpf_prog_info_node *info_node);
100 struct bpf_prog_info_node *perf_env__find_bpf_prog_info(struct perf_env *env,
101 __u32 prog_id);
102 #endif /* __PERF_ENV_H */