xref: /openbmc/linux/tools/perf/util/cputopo.h (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
15135d5efSJiri Olsa /* SPDX-License-Identifier: GPL-2.0 */
25135d5efSJiri Olsa #ifndef __PERF_CPUTOPO_H
35135d5efSJiri Olsa #define __PERF_CPUTOPO_H
45135d5efSJiri Olsa 
55135d5efSJiri Olsa #include <linux/types.h>
65135d5efSJiri Olsa 
75135d5efSJiri Olsa struct cpu_topology {
848f07b0bSIan Rogers 	/* The number of unique package_cpus_lists below. */
948f07b0bSIan Rogers 	u32	  package_cpus_lists;
10406018dcSIan Rogers 	/* The number of unique die_cpu_lists below. */
11406018dcSIan Rogers 	u32	  die_cpus_lists;
120b6b84ccSIan Rogers 	/* The number of unique core_cpu_lists below. */
130b6b84ccSIan Rogers 	u32	  core_cpus_lists;
1448f07b0bSIan Rogers 	/*
1548f07b0bSIan Rogers 	 * An array of strings where each string is unique and read from
1648f07b0bSIan Rogers 	 * /sys/devices/system/cpu/cpuX/topology/package_cpus_list. From the ABI
1748f07b0bSIan Rogers 	 * each of these is a human-readable list of CPUs sharing the same
1848f07b0bSIan Rogers 	 * physical_package_id. The format is like 0-3, 8-11, 14,17.
1948f07b0bSIan Rogers 	 */
2048f07b0bSIan Rogers 	const char **package_cpus_list;
21406018dcSIan Rogers 	/*
22406018dcSIan Rogers 	 * An array of string where each string is unique and from
23406018dcSIan Rogers 	 * /sys/devices/system/cpu/cpuX/topology/die_cpus_list. From the ABI
24406018dcSIan Rogers 	 * each of these is a human-readable list of CPUs within the same die.
25406018dcSIan Rogers 	 * The format is like 0-3, 8-11, 14,17.
26406018dcSIan Rogers 	 */
27406018dcSIan Rogers 	const char **die_cpus_list;
280b6b84ccSIan Rogers 	/*
290b6b84ccSIan Rogers 	 * An array of string where each string is unique and from
300b6b84ccSIan Rogers 	 * /sys/devices/system/cpu/cpuX/topology/core_cpus_list. From the ABI
310b6b84ccSIan Rogers 	 * each of these is a human-readable list of CPUs within the same
320b6b84ccSIan Rogers 	 * core. The format is like 0-3, 8-11, 14,17.
330b6b84ccSIan Rogers 	 */
340b6b84ccSIan Rogers 	const char **core_cpus_list;
355135d5efSJiri Olsa };
365135d5efSJiri Olsa 
3748e6c5acSJiri Olsa struct numa_topology_node {
3848e6c5acSJiri Olsa 	char		*cpus;
3948e6c5acSJiri Olsa 	u32		 node;
4048e6c5acSJiri Olsa 	u64		 mem_total;
4148e6c5acSJiri Olsa 	u64		 mem_free;
4248e6c5acSJiri Olsa };
4348e6c5acSJiri Olsa 
4448e6c5acSJiri Olsa struct numa_topology {
4548e6c5acSJiri Olsa 	u32				nr;
466549a8c0SGustavo A. R. Silva 	struct numa_topology_node	nodes[];
4748e6c5acSJiri Olsa };
4848e6c5acSJiri Olsa 
49f7d74ce3SJin Yao struct hybrid_topology_node {
50f7d74ce3SJin Yao 	char		*pmu_name;
51f7d74ce3SJin Yao 	char		*cpus;
52f7d74ce3SJin Yao };
53f7d74ce3SJin Yao 
54f7d74ce3SJin Yao struct hybrid_topology {
55f7d74ce3SJin Yao 	u32				nr;
56f7d74ce3SJin Yao 	struct hybrid_topology_node	nodes[];
57f7d74ce3SJin Yao };
58f7d74ce3SJin Yao 
59*207f7df7SIan Rogers /*
60*207f7df7SIan Rogers  * The topology for online CPUs, lazily created.
61*207f7df7SIan Rogers  */
62*207f7df7SIan Rogers const struct cpu_topology *online_topology(void);
63*207f7df7SIan Rogers 
645135d5efSJiri Olsa struct cpu_topology *cpu_topology__new(void);
655135d5efSJiri Olsa void cpu_topology__delete(struct cpu_topology *tp);
6609b73fe9SIan Rogers /* Determine from the core list whether SMT was enabled. */
6709b73fe9SIan Rogers bool cpu_topology__smt_on(const struct cpu_topology *topology);
68cc2c4e26SIan Rogers /* Are the sets of SMT siblings all enabled or all disabled in user_requested_cpus. */
69cc2c4e26SIan Rogers bool cpu_topology__core_wide(const struct cpu_topology *topology,
70cc2c4e26SIan Rogers 			     const char *user_requested_cpu_list);
715135d5efSJiri Olsa 
7248e6c5acSJiri Olsa struct numa_topology *numa_topology__new(void);
7348e6c5acSJiri Olsa void numa_topology__delete(struct numa_topology *tp);
7448e6c5acSJiri Olsa 
75f7d74ce3SJin Yao struct hybrid_topology *hybrid_topology__new(void);
76f7d74ce3SJin Yao void hybrid_topology__delete(struct hybrid_topology *tp);
77f7d74ce3SJin Yao 
785135d5efSJiri Olsa #endif /* __PERF_CPUTOPO_H */
79