Commit Graph

23 Commits

Author SHA1 Message Date
Karel Zak 05abf5944e lscpu: add function to count caches size
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 6fbb53286d lscpu: use cache ID, keep caches independent on CPU type
The cache is identified by Type, Level and ID, the ID is unique cache
instance identifier (of the type).

This changes forces lscpu allocate more lscpu_cache instances (than
old version), but now we're ready for arbitrary scenario where
different CPU types share caches and the same cache type uses
different size in different instances, etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 30b912d335 lscpu: add LSCPU_OUTPUT_ enum
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 27c349f9d1 lscpu: move to main function to init context
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 095be2c20e lscpu: merge new API to lscpu.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak f9ac021032 lscpu: remove obsolete code
This is the first step in conversion from old lscpu to the new code.
The patch removes obsolete code from lscpu.c and lscpu.h. The old
output code in lscpu.c is temporary disabled by #ifdef due to
incompatibility between old and new internal APIs -- this will be
changed later by small steps to make all all the changes review-able.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 504de58512 lscpu: convert ARM decoding to new API
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak b76b4788be lscpu: don't use smbios when read snapshots
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-30 14:57:08 +02:00
Jeffrey Bastian 367c85c472 lscpu: use SMBIOS tables on ARM for lscpu
ARM SBBR (Sever Base Boot Requirements) require SMBIOS tables, and
SMBIOS Type 4 describes the CPU manufacturer and model name (among other
details).  If SMBIOS Type 4 is present, use it to extract these strings.

Example output (before and after the patch) on an HP m400, Lenovo HR330A,
and HPE Apollo 70:

[root@hp-m400 ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           APM
Model:               1
Model name:          X-Gene
Stepping:            0x0
[root@hp-m400 ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       AppliedMicro
Model:                           1
Model name:                      X-Gene
Stepping:                        0x0

[root@lenovo-hr330a ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           APM
Model:               2
Model name:          X-Gene
Stepping:            0x3
[root@lenovo-hr330a ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       Ampere(TM)
Model:                           2
Model name:                      eMAG
Stepping:                        0x3

[root@hpe-apollo-70 ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           Cavium
Model:               1
Model name:          ThunderX2 99xx
Stepping:            0x1
[root@hpe-apollo-70 ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       Cavium Inc.
Model:                           1
Model name:                      Cavium ThunderX2(R) CPU CN9980 v2.1 @ 2.20GHz
Stepping:                        0x1

[kzak@redhat.com: - move dmi_header to lscpu.h
                  - make arm_cpu_smbios() more robust for failed
		    open() and read()
                  - use original arm_cpu_decode() also on failed
		    arm_cpu_smbios()]

Signed-off-by: Jeffrey Bastian <jbastian@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-29 13:28:16 +02:00
Yuri Chornoivan 311e33afef Fix minor typos 2020-07-09 20:14:32 +03:00
Karel Zak cf3b6b71eb lscpu: add a new columns to --cache
References: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:46:10 +02:00
Karel Zak 639eeb28dd lscpu: report CPU vulnerabilities
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-11 13:45:29 +02:00
Karel Zak 0e86bc8406 lscpu: add --caches
$ lscpu -C
NAME ONE-SIZE ALL-SIZE WAYS TYPE        LEVEL
L3         8M       8M   16 Unified         3
L2       256K       1M    8 Unified         2
L1i       32K     128K    8 Instruction     1
L1d       32K     128K    8 Data            1

The patch also updates extra caches (s390) output in lsblk summary to
be compatible with output about normal caches.

Addresses: https://github.com/karelzak/util-linux/issues/663
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-19 14:11:20 +01:00
Karel Zak 16ca05511b lscpu: add 'Frequency boost'
Show turbo boost status on platforms where is available a file
/sys/devices/system/cpu/cpufreq/boost.

Addresses: https://github.com/karelzak/util-linux/issues/755
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-15 13:37:51 +01:00
Karel Zak 3e48ef72c1 lscpu: add 'Address sizes'
Addresses: https://github.com/karelzak/util-linux/issues/674
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-01 08:33:32 +02:00
Karel Zak 6e509042b8 lscpu: use new ul_path_* API
* use ul_path_* API for /sys/devices/system/cpu paths
* use ul_path_* API for /proc
* rename is_compatible() to is_devtree_compatible() as it works
  with the devices tree only

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 8229df2093 lscpu: move ARM decoding to lscpu-arm.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-22 13:08:11 +01:00
Karel Zak 7106169441 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>
2018-01-22 13:04:12 +01:00
Stanislav Brabec 7572fb2b8c lscpu: Detect Windows Subsystem for Linux
Windows 10 implements Windows Subsystem for Linux (WSL).

WSL does not implement support for SIGSEGV handler, which is used inside
is_vmware_platform(). As a result, lscpu crashes there.

Implement WSL detection, and as a side effect, work around the crash.
Note that none of existing virtualization types exactly matches.
But the the closest would be "container".

References:

Provide a way to positively detect WSL from an app compiled on Linux.
https://github.com/Microsoft/BashOnWindows/issues/423

missing support for SIGSEGV handler
https://github.com/Microsoft/BashOnWindows/issues/1637

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2017-01-31 12:28:32 +01:00
Benjamin Romer 4597b69249 lscpu: add s-Par support
Adds support for the s-Par firmware's hypervisor leaf.

Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
2015-02-11 11:46:19 +01:00
Ruediger Meier 5bd31c6d6e lscpu: detect OS/400 and pHyp hypervisors
This patch comes originally from openSUSE / SLE. Author was probably
Petr Uzel.
Internal SUSE references: fate310255, sr226509

In comparison to the original patch we have slightly corrected iSeries
and pSeries detection according to Alexander Graf's comments on
util-linux@vger.kernel.org. Maybe we would need to add some more code
to detect pSeries emulated by Qemu/KVM.

CC: Stanislav Brabec <sbrabec@suse.cz>
CC: Petr Uzel <petr.uzel@suse.cz>
CC: Alexander Graf <agraf@suse.de>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-29 13:16:32 +02:00
Ruediger Meier 96ce475f96 lscpu: minor cleanup and improve hypervisor detection
- add HYPER_VBOX
- improve HYPER_VMWARE

This patch comes from openSUSE / SLE. Original author was probably
Petr Uzel.
Internal SUSE references: fate310255, sr226509

CC: Stanislav Brabec <sbrabec@suse.cz>
CC: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-29 01:27:25 +02:00
Ondrej Oprala fb2627cec4 lscpu: detect more hypervisor vendors
[kzak@redhat.com: - cleanup coding style,
                  - use path_exist()]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-20 16:30:23 +02:00