xref: /linux/tools/perf/util/env.h (revision 856e7c4b619af622d56b3b454f7bec32a170ac99)
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 "cpumap.h"
7 
8 struct cpu_topology_map {
9 	int	socket_id;
10 	int	core_id;
11 };
12 
13 struct cpu_cache_level {
14 	u32	level;
15 	u32	line_size;
16 	u32	sets;
17 	u32	ways;
18 	char	*type;
19 	char	*size;
20 	char	*map;
21 };
22 
23 struct numa_node {
24 	u32		 node;
25 	u64		 mem_total;
26 	u64		 mem_free;
27 	struct cpu_map	*map;
28 };
29 
30 struct memory_node {
31 	u64		 node;
32 	u64		 size;
33 	unsigned long	*set;
34 };
35 
36 struct perf_env {
37 	char			*hostname;
38 	char			*os_release;
39 	char			*version;
40 	char			*arch;
41 	int			nr_cpus_online;
42 	int			nr_cpus_avail;
43 	char			*cpu_desc;
44 	char			*cpuid;
45 	unsigned long long	total_mem;
46 	unsigned int		msr_pmu_type;
47 
48 	int			nr_cmdline;
49 	int			nr_sibling_cores;
50 	int			nr_sibling_threads;
51 	int			nr_numa_nodes;
52 	int			nr_memory_nodes;
53 	int			nr_pmu_mappings;
54 	int			nr_groups;
55 	char			*cmdline;
56 	const char		**cmdline_argv;
57 	char			*sibling_cores;
58 	char			*sibling_threads;
59 	char			*pmu_mappings;
60 	struct cpu_topology_map	*cpu;
61 	struct cpu_cache_level	*caches;
62 	int			 caches_cnt;
63 	struct numa_node	*numa_nodes;
64 	struct memory_node	*memory_nodes;
65 	unsigned long long	 memory_bsize;
66 };
67 
68 extern struct perf_env perf_env;
69 
70 void perf_env__exit(struct perf_env *env);
71 
72 int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]);
73 
74 int perf_env__read_cpu_topology_map(struct perf_env *env);
75 
76 void cpu_cache_level__free(struct cpu_cache_level *cache);
77 
78 const char *perf_env__arch(struct perf_env *env);
79 const char *perf_env__raw_arch(struct perf_env *env);
80 int perf_env__nr_cpus_avail(struct perf_env *env);
81 
82 #endif /* __PERF_ENV_H */
83