diff options
author | Karel Zak | 2018-01-22 12:59:11 +0100 |
---|---|---|
committer | Karel Zak | 2018-01-22 13:04:12 +0100 |
commit | 7106169441b8b6cb0922f5f6deb588bd91e44a73 (patch) | |
tree | 061b3d6fcdbaa9c4b8ec4a6aeb8487624d0663e5 | |
parent | Merge branch 'arm-cpus' of https://github.com/suihkulokki/util-linux (diff) | |
download | kernel-qcow2-util-linux-7106169441b8b6cb0922f5f6deb588bd91e44a73.tar.gz kernel-qcow2-util-linux-7106169441b8b6cb0922f5f6deb588bd91e44a73.tar.xz kernel-qcow2-util-linux-7106169441b8b6cb0922f5f6deb588bd91e44a73.zip |
lscpu: move struct lscpu_desc header file
The lscpu code is growing and it seems better to allow to make code
more structured.
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | sys-utils/lscpu-dmi.c | 3 | ||||
-rw-r--r-- | sys-utils/lscpu.c | 155 | ||||
-rw-r--r-- | sys-utils/lscpu.h | 161 |
3 files changed, 162 insertions, 157 deletions
diff --git a/sys-utils/lscpu-dmi.c b/sys-utils/lscpu-dmi.c index 4b845b97c..29bd2e4fc 100644 --- a/sys-utils/lscpu-dmi.c +++ b/sys-utils/lscpu-dmi.c @@ -27,9 +27,6 @@ #include <string.h> #include <stdio.h> -#include "c.h" -#include "pathnames.h" -#include "all-io.h" #include "lscpu.h" #define _PATH_SYS_DMI "/sys/firmware/dmi/tables/DMI" diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 93e699cde..08e5df5bc 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -58,15 +58,9 @@ #include <libsmartcols.h> -#include "cpuset.h" -#include "nls.h" -#include "xalloc.h" -#include "c.h" -#include "strutils.h" -#include "bitops.h" -#include "path.h" #include "closestream.h" #include "optutils.h" + #include "lscpu.h" #include "lscpu-arm.h" @@ -98,13 +92,6 @@ #define XEN_FEATURES_PVH_MASK ( (1U << XENFEAT_supervisor_mode_kernel) \ | (1U << XENFEAT_hvm_callback_vector) ) -/* virtualization types */ -enum { - VIRT_NONE = 0, - VIRT_PARA, - VIRT_FULL, - VIRT_CONT -}; static const char *virt_types[] = { [VIRT_NONE] = N_("none"), [VIRT_PARA] = N_("para"), @@ -149,46 +136,13 @@ static const int hv_graphics_pci[] = { [HYPER_VBOX] = 0xbeef, }; -/* CPU modes */ -enum { - MODE_32BIT = (1 << 1), - MODE_64BIT = (1 << 2) -}; - -/* cache(s) description */ -struct cpu_cache { - char *name; - char *size; - - int nsharedmaps; - cpu_set_t **sharedmaps; -}; /* dispatching modes */ -enum { - DISP_HORIZONTAL = 0, - DISP_VERTICAL = 1 -}; - static const char *disp_modes[] = { [DISP_HORIZONTAL] = N_("horizontal"), [DISP_VERTICAL] = N_("vertical") }; -/* cpu polarization */ -enum { - POLAR_UNKNOWN = 0, - POLAR_VLOW, - POLAR_VMEDIUM, - POLAR_VHIGH, - POLAR_HORIZONTAL -}; - -struct polarization_modes { - char *parsable; - char *readable; -}; - static struct polarization_modes polar_modes[] = { [POLAR_UNKNOWN] = {"U", "-"}, [POLAR_VLOW] = {"VL", "vert-low"}, @@ -197,113 +151,6 @@ static struct polarization_modes polar_modes[] = { [POLAR_HORIZONTAL] = {"H", "horizontal"}, }; -/* global description */ -struct lscpu_desc { - char *arch; - char *vendor; - char *machinetype; /* s390 */ - char *family; - char *model; - char *modelname; - char *revision; /* alternative for model (ppc) */ - char *cpu; /* alternative for modelname (ppc, sparc) */ - char *virtflag; /* virtualization flag (vmx, svm) */ - char *hypervisor; /* hypervisor software */ - int hyper; /* hypervisor vendor ID */ - int virtype; /* VIRT_PARA|FULL|NONE ? */ - char *mhz; - char *dynamic_mhz; /* dynamic mega hertz (s390) */ - char *static_mhz; /* static mega hertz (s390) */ - char **maxmhz; /* maximum mega hertz */ - char **minmhz; /* minimum mega hertz */ - char *stepping; - char *bogomips; - char *flags; - char *mtid; /* maximum thread id (s390) */ - int dispatching; /* none, horizontal or vertical */ - int mode; /* rm, lm or/and tm */ - - int ncpuspos; /* maximal possible CPUs */ - int ncpus; /* number of present CPUs */ - cpu_set_t *present; /* mask with present CPUs */ - cpu_set_t *online; /* mask with online CPUs */ - - int nthreads; /* number of online threads */ - - int ncaches; - struct cpu_cache *caches; - - int necaches; /* extra caches (s390) */ - struct cpu_cache *ecaches; - - /* - * All maps are sequentially indexed (0..ncpuspos), the array index - * does not have match with cpuX number as presented by kernel. You - * have to use real_cpu_num() to get the real cpuX number. - * - * For example, the possible system CPUs are: 1,3,5, it means that - * ncpuspos=3, so all arrays are in range 0..3. - */ - int *idx2cpunum; /* mapping index to CPU num */ - - int nnodes; /* number of NUMA modes */ - int *idx2nodenum; /* Support for discontinuous nodes */ - cpu_set_t **nodemaps; /* array with NUMA nodes */ - - /* drawers -- based on drawer_siblings (internal kernel map of cpuX's - * hardware threads within the same drawer */ - int ndrawers; /* number of all online drawers */ - cpu_set_t **drawermaps; /* unique drawer_siblings */ - int *drawerids; /* physical drawer ids */ - - /* books -- based on book_siblings (internal kernel map of cpuX's - * hardware threads within the same book */ - int nbooks; /* number of all online books */ - cpu_set_t **bookmaps; /* unique book_siblings */ - int *bookids; /* physical book ids */ - - /* sockets -- based on core_siblings (internal kernel map of cpuX's - * hardware threads within the same physical_package_id (socket)) */ - int nsockets; /* number of all online sockets */ - cpu_set_t **socketmaps; /* unique core_siblings */ - int *socketids; /* physical socket ids */ - - /* cores -- based on thread_siblings (internal kernel map of cpuX's - * hardware threads within the same core as cpuX) */ - int ncores; /* number of all online cores */ - cpu_set_t **coremaps; /* unique thread_siblings */ - int *coreids; /* physical core ids */ - - int *polarization; /* cpu polarization */ - int *addresses; /* physical cpu addresses */ - int *configured; /* cpu configured */ - int physsockets; /* Physical sockets (modules) */ - int physchips; /* Physical chips */ - int physcoresperchip; /* Physical cores per chip */ -}; - -enum { - OUTPUT_SUMMARY = 0, /* default */ - OUTPUT_PARSABLE, /* -p */ - OUTPUT_READABLE, /* -e */ -}; - -enum { - SYSTEM_LIVE = 0, /* analyzing a live system */ - SYSTEM_SNAPSHOT, /* analyzing a snapshot of a different system */ -}; - -struct lscpu_modifier { - int mode; /* OUTPUT_* */ - int system; /* SYSTEM_* */ - unsigned int hex:1, /* print CPU masks rather than CPU lists */ - compat:1, /* use backwardly compatible format */ - online:1, /* print online CPUs */ - offline:1, /* print offline CPUs */ - json:1, /* JSON output format */ - physical:1; /* use physical numbers */ -}; - static int maxcpus; /* size in bits of kernel cpu mask */ #define is_cpu_online(_d, _cpu) \ diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h index 4906c2636..1aa546138 100644 --- a/sys-utils/lscpu.h +++ b/sys-utils/lscpu.h @@ -1,6 +1,24 @@ #ifndef LSCPU_H #define LSCPU_H +#include "c.h" +#include "nls.h" +#include "cpuset.h" +#include "xalloc.h" +#include "strutils.h" +#include "bitops.h" +#include "path.h" +#include "pathnames.h" +#include "all-io.h" + +/* virtualization types */ +enum { + VIRT_NONE = 0, + VIRT_PARA, + VIRT_FULL, + VIRT_CONT +}; + /* hypervisor vendors */ enum { HYPER_NONE = 0, @@ -21,6 +39,149 @@ enum { HYPER_WSL, }; +/* CPU modes */ +enum { + MODE_32BIT = (1 << 1), + MODE_64BIT = (1 << 2) +}; + +/* cache(s) description */ +struct cpu_cache { + char *name; + char *size; + + int nsharedmaps; + cpu_set_t **sharedmaps; +}; + +/* dispatching modes */ +enum { + DISP_HORIZONTAL = 0, + DISP_VERTICAL = 1 +}; + +/* cpu polarization */ +enum { + POLAR_UNKNOWN = 0, + POLAR_VLOW, + POLAR_VMEDIUM, + POLAR_VHIGH, + POLAR_HORIZONTAL +}; + +struct polarization_modes { + char *parsable; + char *readable; +}; + + +/* global description */ +struct lscpu_desc { + char *arch; + char *vendor; + char *machinetype; /* s390 */ + char *family; + char *model; + char *modelname; + char *revision; /* alternative for model (ppc) */ + char *cpu; /* alternative for modelname (ppc, sparc) */ + char *virtflag; /* virtualization flag (vmx, svm) */ + char *hypervisor; /* hypervisor software */ + int hyper; /* hypervisor vendor ID */ + int virtype; /* VIRT_PARA|FULL|NONE ? */ + char *mhz; + char *dynamic_mhz; /* dynamic mega hertz (s390) */ + char *static_mhz; /* static mega hertz (s390) */ + char **maxmhz; /* maximum mega hertz */ + char **minmhz; /* minimum mega hertz */ + char *stepping; + char *bogomips; + char *flags; + char *mtid; /* maximum thread id (s390) */ + int dispatching; /* none, horizontal or vertical */ + int mode; /* rm, lm or/and tm */ + + int ncpuspos; /* maximal possible CPUs */ + int ncpus; /* number of present CPUs */ + cpu_set_t *present; /* mask with present CPUs */ + cpu_set_t *online; /* mask with online CPUs */ + + int nthreads; /* number of online threads */ + + int ncaches; + struct cpu_cache *caches; + + int necaches; /* extra caches (s390) */ + struct cpu_cache *ecaches; + + /* + * All maps are sequentially indexed (0..ncpuspos), the array index + * does not have match with cpuX number as presented by kernel. You + * have to use real_cpu_num() to get the real cpuX number. + * + * For example, the possible system CPUs are: 1,3,5, it means that + * ncpuspos=3, so all arrays are in range 0..3. + */ + int *idx2cpunum; /* mapping index to CPU num */ + + int nnodes; /* number of NUMA modes */ + int *idx2nodenum; /* Support for discontinuous nodes */ + cpu_set_t **nodemaps; /* array with NUMA nodes */ + + /* drawers -- based on drawer_siblings (internal kernel map of cpuX's + * hardware threads within the same drawer */ + int ndrawers; /* number of all online drawers */ + cpu_set_t **drawermaps; /* unique drawer_siblings */ + int *drawerids; /* physical drawer ids */ + + /* books -- based on book_siblings (internal kernel map of cpuX's + * hardware threads within the same book */ + int nbooks; /* number of all online books */ + cpu_set_t **bookmaps; /* unique book_siblings */ + int *bookids; /* physical book ids */ + + /* sockets -- based on core_siblings (internal kernel map of cpuX's + * hardware threads within the same physical_package_id (socket)) */ + int nsockets; /* number of all online sockets */ + cpu_set_t **socketmaps; /* unique core_siblings */ + int *socketids; /* physical socket ids */ + + /* cores -- based on thread_siblings (internal kernel map of cpuX's + * hardware threads within the same core as cpuX) */ + int ncores; /* number of all online cores */ + cpu_set_t **coremaps; /* unique thread_siblings */ + int *coreids; /* physical core ids */ + + int *polarization; /* cpu polarization */ + int *addresses; /* physical cpu addresses */ + int *configured; /* cpu configured */ + int physsockets; /* Physical sockets (modules) */ + int physchips; /* Physical chips */ + int physcoresperchip; /* Physical cores per chip */ +}; + +enum { + OUTPUT_SUMMARY = 0, /* default */ + OUTPUT_PARSABLE, /* -p */ + OUTPUT_READABLE, /* -e */ +}; + +enum { + SYSTEM_LIVE = 0, /* analyzing a live system */ + SYSTEM_SNAPSHOT, /* analyzing a snapshot of a different system */ +}; + +struct lscpu_modifier { + int mode; /* OUTPUT_* */ + int system; /* SYSTEM_* */ + unsigned int hex:1, /* print CPU masks rather than CPU lists */ + compat:1, /* use backwardly compatible format */ + online:1, /* print online CPUs */ + offline:1, /* print offline CPUs */ + json:1, /* JSON output format */ + physical:1; /* use physical numbers */ +}; + extern int read_hypervisor_dmi(void); #endif /* LSCPU_H */ |