]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/lscpu.h
Merge branch 'hardlink' of https://github.com/rudimeier/util-linux into hardlink
[thirdparty/util-linux.git] / sys-utils / lscpu.h
1 #ifndef LSCPU_H
2 #define LSCPU_H
3
4 #include "c.h"
5 #include "nls.h"
6 #include "cpuset.h"
7 #include "xalloc.h"
8 #include "strutils.h"
9 #include "bitops.h"
10 #include "path.h"
11 #include "pathnames.h"
12 #include "all-io.h"
13
14 /* virtualization types */
15 enum {
16 VIRT_NONE = 0,
17 VIRT_PARA,
18 VIRT_FULL,
19 VIRT_CONT
20 };
21
22 /* hypervisor vendors */
23 enum {
24 HYPER_NONE = 0,
25 HYPER_XEN,
26 HYPER_KVM,
27 HYPER_MSHV,
28 HYPER_VMWARE,
29 HYPER_IBM, /* sys-z powervm */
30 HYPER_VSERVER,
31 HYPER_UML,
32 HYPER_INNOTEK, /* VBOX */
33 HYPER_HITACHI,
34 HYPER_PARALLELS, /* OpenVZ/VIrtuozzo */
35 HYPER_VBOX,
36 HYPER_OS400,
37 HYPER_PHYP,
38 HYPER_SPAR,
39 HYPER_WSL,
40 };
41
42 /* CPU modes */
43 enum {
44 MODE_32BIT = (1 << 1),
45 MODE_64BIT = (1 << 2)
46 };
47
48 /* cache(s) description */
49 struct cpu_cache {
50 char *name;
51 char *size;
52
53 int nsharedmaps;
54 cpu_set_t **sharedmaps;
55 };
56
57 /* dispatching modes */
58 enum {
59 DISP_HORIZONTAL = 0,
60 DISP_VERTICAL = 1
61 };
62
63 /* cpu polarization */
64 enum {
65 POLAR_UNKNOWN = 0,
66 POLAR_VLOW,
67 POLAR_VMEDIUM,
68 POLAR_VHIGH,
69 POLAR_HORIZONTAL
70 };
71
72 struct polarization_modes {
73 char *parsable;
74 char *readable;
75 };
76
77
78 /* global description */
79 struct lscpu_desc {
80 const char *prefix; /* path to /sys and /proc snapshot or NULL */
81
82 struct path_cxt *syscpu; /* _PATH_SYS_CPU path handler */
83 struct path_cxt *procfs; /* /proc path handler */
84
85 char *arch;
86 char *vendor;
87 char *machinetype; /* s390 */
88 char *family;
89 char *model;
90 char *modelname;
91 char *revision; /* alternative for model (ppc) */
92 char *cpu; /* alternative for modelname (ppc, sparc) */
93 char *virtflag; /* virtualization flag (vmx, svm) */
94 char *hypervisor; /* hypervisor software */
95 int hyper; /* hypervisor vendor ID */
96 int virtype; /* VIRT_PARA|FULL|NONE ? */
97 char *mhz;
98 char *dynamic_mhz; /* dynamic mega hertz (s390) */
99 char *static_mhz; /* static mega hertz (s390) */
100 char **maxmhz; /* maximum mega hertz */
101 char **minmhz; /* minimum mega hertz */
102 char *stepping;
103 char *bogomips;
104 char *flags;
105 char *mtid; /* maximum thread id (s390) */
106 char *addrsz; /* address sizes */
107 int dispatching; /* none, horizontal or vertical */
108 int mode; /* rm, lm or/and tm */
109
110 int ncpuspos; /* maximal possible CPUs */
111 int ncpus; /* number of present CPUs */
112 cpu_set_t *present; /* mask with present CPUs */
113 cpu_set_t *online; /* mask with online CPUs */
114
115 int nthreads; /* number of online threads */
116
117 int ncaches;
118 struct cpu_cache *caches;
119
120 int necaches; /* extra caches (s390) */
121 struct cpu_cache *ecaches;
122
123 /*
124 * All maps are sequentially indexed (0..ncpuspos), the array index
125 * does not have match with cpuX number as presented by kernel. You
126 * have to use real_cpu_num() to get the real cpuX number.
127 *
128 * For example, the possible system CPUs are: 1,3,5, it means that
129 * ncpuspos=3, so all arrays are in range 0..3.
130 */
131 int *idx2cpunum; /* mapping index to CPU num */
132
133 int nnodes; /* number of NUMA modes */
134 int *idx2nodenum; /* Support for discontinuous nodes */
135 cpu_set_t **nodemaps; /* array with NUMA nodes */
136
137 /* drawers -- based on drawer_siblings (internal kernel map of cpuX's
138 * hardware threads within the same drawer */
139 int ndrawers; /* number of all online drawers */
140 cpu_set_t **drawermaps; /* unique drawer_siblings */
141 int *drawerids; /* physical drawer ids */
142
143 /* books -- based on book_siblings (internal kernel map of cpuX's
144 * hardware threads within the same book */
145 int nbooks; /* number of all online books */
146 cpu_set_t **bookmaps; /* unique book_siblings */
147 int *bookids; /* physical book ids */
148
149 /* sockets -- based on core_siblings (internal kernel map of cpuX's
150 * hardware threads within the same physical_package_id (socket)) */
151 int nsockets; /* number of all online sockets */
152 cpu_set_t **socketmaps; /* unique core_siblings */
153 int *socketids; /* physical socket ids */
154
155 /* cores -- based on thread_siblings (internal kernel map of cpuX's
156 * hardware threads within the same core as cpuX) */
157 int ncores; /* number of all online cores */
158 cpu_set_t **coremaps; /* unique thread_siblings */
159 int *coreids; /* physical core ids */
160
161 int *polarization; /* cpu polarization */
162 int *addresses; /* physical cpu addresses */
163 int *configured; /* cpu configured */
164 int physsockets; /* Physical sockets (modules) */
165 int physchips; /* Physical chips */
166 int physcoresperchip; /* Physical cores per chip */
167 };
168
169 enum {
170 OUTPUT_SUMMARY = 0, /* default */
171 OUTPUT_PARSABLE, /* -p */
172 OUTPUT_READABLE, /* -e */
173 };
174
175 enum {
176 SYSTEM_LIVE = 0, /* analyzing a live system */
177 SYSTEM_SNAPSHOT, /* analyzing a snapshot of a different system */
178 };
179
180 struct lscpu_modifier {
181 int mode; /* OUTPUT_* */
182 int system; /* SYSTEM_* */
183 unsigned int hex:1, /* print CPU masks rather than CPU lists */
184 compat:1, /* use backwardly compatible format */
185 online:1, /* print online CPUs */
186 offline:1, /* print offline CPUs */
187 json:1, /* JSON output format */
188 physical:1; /* use physical numbers */
189 };
190
191 extern int read_hypervisor_dmi(void);
192 extern void arm_cpu_decode(struct lscpu_desc *desc);
193
194 #endif /* LSCPU_H */