$ 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>
We need to differentiate between output about CPUs and another stuff
(caches in future). Let's make it more obvious in code.
Signed-off-by: Karel Zak <kzak@redhat.com>
The current version reports cache size as reported by /sys, it means
real size of the one piece of the cache. This way provides minimal
overview about all system as the cache is often shared between CPUs.
It seems better to report all size of the caches in the summary
output. It also does not make sense to report sizes per core (or
socket) as CPU topology may be pretty complicated.
The final solution (not implemented yet) will be to have --list-caches
where we can report all details like all-size, item-size, per-core size,
ways, type, etc.
Addresses: https://github.com/karelzak/util-linux/issues/663
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
aarch32 support is an optional feature of ARMv8, as CPUs
which don't support aarch32 become more common, lets make
sure that lscpu can tell a user quickly if they are on a
machine that only supports 64-bit.
Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
* 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>
The old CPU macros are limited to 1024 cores. As a result, lscpu cannot
count sockets on large systems. Use new scalable macros.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Michael Matz <matz@suse.de>
When cpu#0 is offline, atof(NULL) is called which causes
a segfault or endless loop depending on implementation
circumstances. So instead of implicitely assumping that the
first cpu is always available, do the presence checks for
all including the first one.
Since the kernel developers have refused to make /proc/cpuinfo user
understandable, implement mapping in userspace. lscpu is available for
most users via util-linux, so store the information here.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Let read_nodes() work on uninitialized structs to silence these two
warnings:
CC sys-utils/lscpu-lscpu.o
warning: Path diagnostic report is not generated. Current output format does not support diagnostics that cross file boundaries. Refer to --analyzer-output for valid output formats
In file included from sys-utils/lscpu.c:63:
./include/xalloc.h:32:21: warning: Call to 'malloc' has an allocation size of 0 bytes
void *ret = malloc(size);
^~~~~~~~~~~~
sys-utils/lscpu.c:1468:23: warning: Function call argument is an uninitialized value
desc->nodemaps[i] = path_read_cpuset(maxcpus,
^~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Simply avoiding strdup(). Error handling improved.
This was the Clang Analyzer warning:
Memory Error, Use-after-free
sys-utils/lsmem.c:259:3: warning: Use of memory after it is freed
err(EXIT_FAILURE, _("Failed to open %s"), path);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
The array members may be NULL on some architectures (e.g. AMD). Let's
be paranoid and check for the NULL independently on present/online
masks.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1457744
Signed-off-by: Karel Zak <kzak@redhat.com>
Now we use libsmartcols for the default output and all is allocated in
the smartcols table. So, we can reuse the same buffer for all
sprintf/scanf calls.
Signed-off-by: Karel Zak <kzak@redhat.com>
Problem:"lscpu frequency-info" command was always reading CPU0
max and min frequencies. If CPU0 is guarded or offline then it used to
display max and min frequencies as NULL.
This patch will read overall CPU max and min frequencies.
Test Results:
Before Patch:
#lscpu (CPU0 is guarded/offline)
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 120
On-line CPU(s) list: 8-127
Thread(s) per core: 8
Core(s) per socket: 3
Socket(s): 4
NUMA node(s): 4
Model: 2.1 (pvr 004b 0201)
Model name: POWER8E (raw), altivec supported
CPU max MHz: (null)
CPU min MHz: (null)
L1d cache: 64K
L1i cache: 32K
L2 cache: 512K
L3 cache: 8192K
NUMA node0 CPU(s): 8-31
NUMA node1 CPU(s): 32-63
NUMA node16 CPU(s): 64-95
NUMA node17 CPU(s): 96-127
With Patch:
# ./lscpu
Architecture: ppc64le
Byte Order: Little Endian
CPU(s): 120
On-line CPU(s) list: 8-127
Thread(s) per core: 8
Core(s) per socket: 3
Socket(s): 4
NUMA node(s): 4
Model: 2.1 (pvr 004b 0201)
Model name: POWER8E (raw), altivec supported
CPU max MHz: 4322.0000
CPU min MHz: 2061.0000
L1d cache: 64K
L1i cache: 32K
L2 cache: 512K
L3 cache: 8192K
NUMA node0 CPU(s): 8-31
NUMA node1 CPU(s): 32-63
NUMA node16 CPU(s): 64-95
NUMA node17 CPU(s): 96-127
[kzak@redhat.com: - cpu_{max,min}_mhz() refactoring]
Signed-off-by: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer
Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.
Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
It seems that aarch64 uses a different names for some /proc/cpuinfo
fields (e.g. intel: bogomips, flags, and aarch64: BogoMIPS, features, ...)
Addresses: https://github.com/karelzak/util-linux/issues/392
Signed-off-by: Karel Zak <kzak@redhat.com>
lscpu calculates the number of threads per core by dividing the number
of online cpus with the number of cores. This may or may not give the
correct number of threads per core depending on the number of online
CPUs (and which CPUs are online).
At least on s390 there is a new "max thread id" field within
/proc/cpuinfo present which reliably allows us to tell the number of
threads per core. Let's use this instead, like we already have also
special treatment to figure out the number core per socket etc. on
s390.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
lscpu can skip all CPUs which are possible but not present. For
configurations where a lot of CPUs are possible but only few CPUs are
present this saves a lot of pointless glibc/system calls.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
With the --physical option lscpu will use the IDs that are reported by
the kernel (e.g. core id for the CORE column) instead of calculating
them on it's own.
This has the advantage that it is possible to tell on which physical
hardware CPUs a Linux instance runs. The logical IDs that lscpu
generates on it own are based on comparing of CPU masks and may or may
not be identical with the physical IDs.
If the kernel was unable to retrieve an ID for a topology element then
the corresponding sysfs file will normally contain "-1". In the
extended and parsable output a dash "-" will be displayed for such
cases.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
The Linux kernel exposes the cache topology via sysfs. However on
virtualized machines like s390 the cache topology contains only cpu
private caches.
For shared caches it is not known which cpus share them. The
hypervisor would have to update this information whenever a virtual
cpu would be scheduled on a different physical cpu and make the guest
aware of that change. Given that there is hardly any benefit, if it
all, this isn't done.
However it is still of interest to know about the non-private
caches. Therefore this information is available via /proc/cpuinfo at
least on s390.
This patch adds additional lines to the summary output for all shared
caches for which information can be found in /proc/cpuinfo, since we
know these aren't exposed via sysfs.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>