Commit Graph

281 Commits

Author SHA1 Message Date
Karel Zak 89222b17fc lscpu: make cpu_{max,min}_mhz() usage more elegant
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 12:29:24 +02:00
Mamatha Inamdar fc07d9f5ab lscpu: Read available CPUs max and min frequencies
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>
2017-05-09 12:23:37 +02:00
Karel Zak c6f6afc164 lscpu: fix mem leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-31 11:05:26 +02:00
Karel Zak bf1eab0731 lscpu: check return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-31 10:58:50 +02:00
Karel Zak 19a5510b96 lscpu: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-14 15:32:53 +01:00
Karel Zak c82b12a0a2 lscpu: use libsmartcols to print summary too
Addresses: https://github.com/karelzak/util-linux/issues/419
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-14 15:19:12 +01:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
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>
2017-02-20 12:58:49 +01:00
Karel Zak 904ffe1fd2 lscpu: don't use path_exist() before path_fopen()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-31 20:55:07 +01:00
Karel Zak 4dfc54b6b1 lscpu: make osrelease file optional
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-31 13:44:43 +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
Karel Zak a3c455ac9b lscpu: add aarch64 specific names
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>
2017-01-09 13:04:41 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Ruediger Meier 223939d95b misc: spelling, always use "cannot" instead of "can not"
Just to be consistent ...

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-11-30 14:56:50 +01:00
Karel Zak b5d61108e4 lscpu: disable is_vmware_platform() for non-root users
References: http://www.spinics.net/lists/util-linux-ng/msg13302.html
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-11-03 10:53:09 +01:00
Heiko Carstens 2c497d3288 lscpu: print correct number of threads per core if possible
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>
2016-08-03 13:35:05 +02:00
Heiko Carstens 0002704ebe lscpu: only try to read sysfs attributes of present CPUs
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>
2016-08-03 13:35:05 +02:00
Heiko Carstens 0d2b5d2a72 lscpu: add --physical option
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>
2016-08-03 13:35:05 +02:00
Karel Zak 81a307bd4d lscpu: make lookup_cache() more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-24 11:07:00 +02:00
Heiko Carstens 28b1658f8b lscpu: show additional caches (s390)
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>
2016-06-24 10:54:09 +02:00
Heiko Carstens 0c28f0c815 lscpu: show machine type (s390)
Show also the machine type within the lscpu output. With the machine
type it is possible to identify the cpu generation and the supported
features.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-06-24 10:54:09 +02:00
Heiko Carstens 4632b28811 lscpu: show static and dynamic MHz (s390)
s390 machines provide static and dynamic cpu mhz information via
/proc/cpuinfo. The static cpu mhz is the normal cpu frequency a cpu is
supposed to run with.

The dynamic cpu mhz is the actual frequency a cpu is running
with. This is usually the same as the static cpu mhz. Note that this
values are different to the min/max mhz values available on other
architecutes. The min/max values are unknown.

This patch adds two new fields to the summary output which display
these two values.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-06-24 10:54:09 +02:00
Heiko Carstens 156740ca37 lscpu: fix typo in summary output
The new drawer support did have a type in the summary output:
it reported Drawers(s) instead of Drawer(s). Fix this.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-06-24 10:54:09 +02:00
Heiko Carstens b3adf6ef66 lscpu: add drawer support
The s390 architecture gained another cpu topology level called
"drawer" which is above the book level.

Add support for this to lscpu.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-06-24 10:52:32 +02:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Karel Zak b4d1fbda1e lscpu: revert unnecessary path_exist()
The features file is there from 2.6.31 when Xen has been added to
kernel. Sorry.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-22 10:31:16 +01:00
Dongli Zhang 0ebbe9f104 lscpu: correct the Virtualization type on Xen DomU PV guest
Nowadays, most Intel CPUs have "cpuid faulting" available which could trap
the execution of "cpuid" instruction when CPL>0  with GP fault. Thus,
"cpuid" instruction could trap to Xen hypervisor on the paravirtualized PV
guest on most servers today, except on old CPUs prior to 2011. On CPU after
2011, Xen will put "XenVMMXenVMM" on both HVM and PV guests, which could
have lscpu command erroneously classify the guest as type "full".  The
current lscpu command, which is based on "cpuid" instruction, still assumes
that it will not cause the trap to Xen hypervisor on Xen PV guest and uses
/proc/xen to identify whether it's running on PV DomU or not.  To identify
this kind of information under the help of
/sys/hypervisor/properties/features would be more accurate for the CPU
nowadays. The bit 5 (XENFEAT_mmu_pt_update_preserve_ad) of the features
will be set only when it's running on Xen PV domain. The combo of bit 3 and
8 (XENFEAT_supervisor_mode_kernel and XENFEAT_hvm_callback_vector) will be
set simultaneously only when it's running on Xen PVH domain.

[kzak@redhat.com: - add path_exist()]

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-22 10:13:03 +01:00
Ruediger Meier e5fc6d6fb5 lscpu: fix memleak because of ambiguous tags
Now the first one of certain ambiguous tags wins. Alternatively to
this patch we could have called free() before xstrdup().

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-16 14:17:34 +01:00
Ruediger Meier c95e388972 lscpu: use cpu and revision tag if available
Avoid ifdef which does not work with --sysroot. Our existing test
dumps produce even better output now for ppc and sparc.

The logic moved to the printing section.

CC: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-16 14:17:33 +01:00
Ruediger Meier 86c4817e0e Revert "lscpu: keep lscpu usable on snapshots"
This reverts commit 641350fe82.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-16 14:17:33 +01:00
Karel Zak 641350fe82 lscpu: keep lscpu usable on snapshots
This patch reverts 3ac03fe4d2 for
snapshots (--sysroot).

Yeah, poor-man solution. It would be really nice to have runtime
detection to support model overwriting also on snapshots.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-15 14:23:59 +01:00
Vasant Hegde 3ac03fe4d2 lscpu: Fix model and model name on Power Systems
On Power System, lspcu presently displays system model number instead of
processor model name. 'model' tag in cpuinfo contains system model name,
not processor model. Instead it uses 'cpu' tag for processor model name.
Also it uses 'revision' tag for processor model.

Fix lspcu so that it displays processor model number. Also display processor
model name.

cpuinfo output on Power System:
  ...
  ...

  processor	: 127
  cpu		: POWER8E (raw), altivec supported
  clock		: 4322.000000MHz
  revision	: 2.1 (pvr 004b 0201)

  timebase	: 512000000
  platform	: PowerNV
  model		: 8286-42A
  machine	: PowerNV 8286-42A
  firmware	: OPAL

Output without this patch:
  Architecture:          ppc64le
  Byte Order:            Little Endian
  CPU(s):                128
  On-line CPU(s) list:   0-127
  Thread(s) per core:    8
  Core(s) per socket:    4
  Socket(s):             4
  NUMA node(s):          4
  Model:                 8286-42A
  ...
  ...

Output with this patch:
  Architecture:          ppc64le
  Byte Order:            Little Endian
  CPU(s):                128
  On-line CPU(s) list:   0-127
  Thread(s) per core:    8
  Core(s) per socket:    4
  Socket(s):             4
  NUMA node(s):          4
  Model:                 2.1 (pvr 004b 0201)
  Model name:            POWER8E (raw), altivec supported
  ...
  ...

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
2016-03-14 16:17:19 +01:00
Yuriy M. Kaminskiy 06fa581748 misc: safer (and uniform) handling of return value
When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-07 15:11:06 +01:00
Yuriy M. Kaminskiy 0c5bbafaf9 lscpu: fix backward buffer size adjustment after adding delimiter
remaining buffer space was increased after adding character, instead
of decreasing

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-07 15:10:46 +01:00
Sukadev Bhattiprolu bd9b94d12a lscpu: Print physical cpu information
lscpu currently prints information for CPUs configured in the system.
In case of KVM or other virtualized guest operating systems, this
refers to the virtual system, and bears no relation to the physical
topology of the system.

It would be useful if lscpu could also display the physical topology
info when available:

	$ ./lscpu
	Architecture:          ppc64le
	Byte Order:            Little Endian
	CPU(s):                16
	On-line CPU(s) list:   0-15
	Thread(s) per core:    1
	Core(s) per socket:    1
	Socket(s):             16
	NUMA node(s):          1
	Model:                 IBM pSeries (emulated by qemu)
	Hypervisor vendor:     KVM
	Virtualization type:   para
	L1d cache:             64K
	L1i cache:             32K
	NUMA node0 CPU(s):     0-15
	Physical sockets:      2		<<< New
	Physical chips:        4		<<< New
	Physical cores/chip:   4		<<< New

For now, physical topology information is available on platforms that
support the following RTAS (Real time abstraction service) call provided
by librtas:

	rtas_get_sysparm(PROCESSOR_MODULE_INFO).

Currently this call is available to the PowerVM (pHYP) guests on PowerPC.
With a patch propoosed to PowerKVM, this RTAS call would also be available
to PowerKVM guests.

Based on input from Nishanth Aravamudan and Karel Zak.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
2015-12-02 11:33:58 +01:00
Karel Zak e03b613e8d lscpu: fix read_hypervisor_powerpc() logic
We care about /proc/device-tree/compatible content...

The patch also removes unnecessary path_exist(), it seems good enough
to call open() rather than access() + open().

Addresses: https://github.com/karelzak/util-linux/issues/218
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-01 12:37:18 +02:00
Karel Zak 6d9b1c19ea lscpu: add warning for __SANITIZE_ADDRESS__
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-02 14:55:52 +02:00
Cristian Rodríguez a680b2abe7 sys-utils: lscpu segfaults when built with -fsanitize=address
This is expected and a false positive, exclude the vmware detection
trick when __SANITIZE_ADDRESS__ is defined.
2015-06-02 11:58:53 +02:00
WANG Chao ee1f1057e2 lscpu: add cpu flags entry to summary output
It'd be convenient to have unified cpu "Flags: " entry in the summary
output.

Signed-off-by: WANG Chao <wcwxyz@gmail.com>
2015-05-13 11:27:16 +02: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
Karel Zak d45984bef6 lscpu: fix typos in ppc code
Reported-by: David Gibson <dgibson@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-09 12:03:18 +01:00
Karel Zak 79738105b1 lscpu: cleanup ppc virtualization detection
References: https://bugzilla.redhat.com/show_bug.cgi?id=1151604
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-06 11:23:40 +01:00
Karel Zak f93993b746 lscpu: fix compiler error [-Werror=format-security]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-06 10:31:03 +01:00
Karel Zak 3565bd7aec lscpu: detect also QEMU emulation on ppc
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-05 16:52:43 +01:00
Ruediger Meier f205c90a72 build: fix printf warnings for icc (-Wformat-security)
Intel compiler complains about printf style function calls with trivial
format string and no other arguments. Like this one:

../sys-utils/ipcrm.c(117): warning #2279: printf/scanf format not a string literal and no format arguments
                        err(EXIT_FAILURE, iskey ? _("key failed") : _("id failed"));
2015-01-21 11:15:19 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Sami Kerola 772420322d lscpu: blacklist vmware_bdoor() AddressSanitizer check
AddressSanitizer is identifying the __asm__ segment as suspicious.

==1215==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
(pc 0x0000004ccffd bp 0x7fff9b7184f0 sp 0x7fff9b7184e0 T0)
    #0 0x4ccffc in vmware_bdoor /home/src/util-linux/sys-utils/lscpu.c:660

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 11:32:38 +01:00
Tobias Stoeckmann 6cbf75e56e lscpu: theoretical buffer overflow
there is a theoretical buffer overflow possible in the hypervisor
parsing code of lscpu.  It would require a proc entry to return way more
than expected so it's no high priority.  But better be safe than sorry.

At first I thought about switching to fgets but there is another
code file that adds a format specifier.  The diff is less intrusive
that way, too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-18 11:38:21 +01:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Boris Egorov 73f2bec5f8 lscpu: fix cppcheck warnings
CppCheck founds a few wrong arguments in format strings and a NULL
pointer dereference.

Amended version with fixed strcmp() usage.

Signed-off-by: Boris Egorov <egorov@linux.com>
2014-09-16 11:16:09 +02:00
Mike Frysinger 7845b91dbc lscpu: clean up vmware inline asm
This code is not PIC clean which means it fails to build on hardened
32bit x86 systems (i.e. building as PIE).

While here, optimize the existing cpuid logic slightly.

URL: https://bugs.gentoo.org/518936
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-08-11 14:51:53 +02:00
Sami Kerola 9dd2d49735 lscpu: avoid use of bzero() in favor of memset()
The bzero() is marked as LEGACY in POSIX.1-2001.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:29:23 +01:00
Karel Zak 65322517eb lscpu: fix ifdef HAVE_sys_io_h [checkconfig]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-18 12:51:25 +02:00
Karel Zak 710ed55dcd libsmartcols: add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 13:47:06 +02:00
Ruediger Meier b7744730f6 lscpu: improve vmware detection
This patch comes from openSUSE / SLE. Original author was probably
Petr Uzel.
Internal SUSE references: fate310255, sr226509

VMmware backdoor assembler code has been fixed for old clang compiler
(travis), see
see http://llvm.org/bugs/show_bug.cgi?id=9379

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 13:17:46 +02: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
Karel Zak 0925a9dd6c libsmartcols: clean up flags usage
* rename flags functions to scols_table_enable_*
 * rename *_no_foo() functions to _nofoo()
 * output formats are mutually exclusive, so don't use flags there
 * don't assume symbols in scols_new_table(), use scols_table_set_symbols()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 16:09:57 +02:00
Karel Zak e7213e34f3 lscpu: clean up scols usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:20 +02:00
Ondrej Oprala 83db4eb2c2 lscpu: use libsmartcols
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:19 +02:00
Ruediger Meier 1d56b55ea1 lscpu: cleanup, use _PATH_SYS_CPU/NODE
This make most lines shorter than 80 chars again (tab-witdh 4).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-03-27 09:25:47 +01:00
Ruediger Meier 10d927ab3b lscpu: don't abort if cache size is unknown
There are systems where the size file does not exist. Most badly even
lscpu -p would abort allthough it does not use the size:
$ lscpu -p
lscpu: error: cannot open
/sys/devices/system/cpu/cpu0/cache/index0/size: No such file or directory

This patch does not abort in this case and prints "unknown size" in
human-readable case. For examle on this qemu pcc test machine:
$ lscpu
Architecture:          ppc
CPU op-mode(s):        32-bit
Byte Order:            Big Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
Model:                 Power Macintosh
BogoMIPS:              33.25
L1d cache:             unknown size
L1i cache:             unknown size

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-03-27 09:11:57 +01:00
Stewart Smith c0cf4ae9b0 lscpu: don't assume filesystem supports d_type when searching for NUMA nodes
Not all file systems support the d_type field and simply checking for
d_type == DT_DIR in is_node_dirent would cause the test suite to fail
if run on (for example) XFS.

The simple fix is to check for DT_DIR or DT_UNKNOWN in is_node_dirent.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-03-04 11:47:23 +01:00
Karel Zak 39c758d140 lscpu: sort NUMA nodes to keep output human readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-14 13:59:34 +01:00
Karel Zak e9074a167c lscpu: support discontinuous NUMA nodes
lscpu fails to print proper NUMA node values in a system with
discontinuous nodes. This patch adds support by creating a nodeidx
array to map node numbers.

Based on patch from Madhavan Srinivasan <maddy@linux.vnet.ibm.com>.

Reported-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-06 16:48:44 +01:00
Alexander Troosh 4f64286321 lscpu: support non sequentially numbering of CPUs
lscpu don't work correctly on my system with:

 $ cat /sys/devices/system/cpu/possible
 0-1,4-5,8-9,12-13

[kzak@redhat.com: - coding style,
                  - add commit message
                  - add real_cpu_num() macro,
                  - fix functions where we need idx as well as CPU number]

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-05 12:46:03 +01:00
Benno Schulenberg 4df288452e textual: properly use uppercase in certain abbreviations
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:28 +02:00
Karel Zak dbbf839586 lscpu: cleanup DMI code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-02 14:07:32 +02:00
Davidlohr Bueso e065a597d6 lscpu: report cpu min mhz
The lscpu tool only shows the current and max CPU frequencies, however,
in many scenarios this is not enough. If there are energy saving situations
(like some CPUs being idle, or not fully used) the cpugov can lower this value.

Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
2013-09-25 11:13:35 +02:00
Karel Zak 082479c582 lscpu: use TT_FL_FREEDATA for tt table
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:59 +02:00
Sami Kerola 145a3ca364 lscpu: fix shadow declaration [smatch scan]
sys-utils/lscpu.c:572:22: warning: symbol 'fd' shadows an earlier one

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-01 13:35:24 +02:00
Sami Kerola 44320710bd lscpu: add max MHz value to make cpu governor effects more visible
The existing 'CPU MHz' is usually dynamic value, which CPU governor
changes up on needs of CPU demand.  Assuming lscpu is used to gather
information to a hardware inventory the dynamic value is misleading.  For
inventing the maximum MHz value is more sensible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-06-07 12:24:42 +02:00
Karel Zak 857d9cdf49 lscpu: add virtualization types
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-20 16:41:19 +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
Karel Zak 6d791b4cc0 include: fix SYS_{unshare,nsenter} usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-17 16:58:00 +02:00
Karel Zak 4581b716b5 lscpu: set 32-bit / 64-bit for ppc
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-17 16:20:10 +02:00
Karel Zak 1461094c14 lscpu: add Model name
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-10 14:29:53 +02:00
Sami Kerola ac56e5558e lscpu: fix error message
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 13:56:06 +02:00
Karel Zak b3eff5dd74 lscpu: make /proc/sysinfo usage more robust [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 15:59:40 +01:00
Karel Zak e36aad2139 lscpu: remove dead code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 15:01:41 +01:00
Karel Zak eff79ceb0b lscpu: don't read cpuid on non-live systems
Reported-by: Luis Aranguren <pizzaman@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 15:38:08 +01:00
Benno Schulenberg c6f095cf59 textual: slice the help text of lscpu into strips, for translators
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-30 15:24:03 +01:00
Benno Schulenberg 52f63b29ac lscpu: correct the description of --sysroot in help text
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-30 15:23:54 +01:00
Karel Zak 9d8537ff21 lscpu: don't care about xasprintf() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 12:13:38 +01:00
Karel Zak 6c32b388b5 lscpu: remove unnecessary variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 15:01:27 +01:00
Karel Zak ca01695b77 lib/path: rename functions to be more explicit
... and to have names compatible with lib/sysfs.c

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak d4bfa64d44 lscpu: make read_topology() more robust to avoid SIGFPE
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-13 10:36:25 +01:00
Toshi Kani a5cfffff28 lscpu: Fix issue found on CPU hot-remove
read_basicinfo() relies on sysfs cpu directories
"/sys/devices/system/cpu/cpu%d" with assumption that cpu
logical number %d is always sequentially assigned for all
CPUs. However, this assumption is not correct with CPU
hot-remove operation since it removes a target sysfs cpu
directory after it is ejected. As a result, lscpu may not
recognize all CPUs.

The issue can be easily reproduced on KVM or VirtualBox,
which supports CPU eject operation, as follows.

1) The system has 4 CPUs
  $ lscpu -a -e
  CPU NODE SOCKET CORE L1d:L1i:L2 ONLINE
  0   0    0      0    0:0:0      yes
  1   0    1      1    1:1:1      yes
  2   0    2      2    2:2:2      yes
  3   0    3      3    3:3:3      yes

2) Eject cpu2
  # echo 1 > /sys/bus/acpi/devices/LNXCPU:02/eject

3) lscpu no longer recognizes cpu3 after cpu2 is ejected
  $ lscpu -a -e
  CPU NODE SOCKET CORE L1d:L1i:L2 ONLINE
  0   0    0      0    0:0:0      yes
  1   0    1      1    1:1:1      yes

The following changes are made to address this issue.
 - Use maxcpus to allocate and parse bitmaps.
 - Set desc->ncpu from cpu/present, which includes both on-line
   and off-line CPUs.
 - Add is_cpu_present() to check if a CPU is present. Ejected
   CPUs are not present.

[kzak@redhat.com: - read also /sys/devices/system/cpu/possible mask to
                    determine maximal number of CPUs,
                  - err() if possible mask is not found in /sys]

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 14:47:13 +01:00
Heiko Carstens 7fc12cd276 lscpu: limit options --all, --online, --offline to parsable and extended output
Passing the --all, --online or --offline options for the output summary
doesn't make much sense. It should be limited to the two list output options.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2012-08-13 14:42:21 +02:00
Sami Kerola 2d7bee2554 lscpu: fix shadow declaration
sys-utils/lscpu.c:1084:8: warning: declaration of 'buf' shadows a previous local [-Wshadow]
sys-utils/lscpu.c:1077:7: warning: shadowed declaration is here [-Wshadow]
sys-utils/lscpu.c:1144:9: warning: declaration of 'buf' shadows a previous local [-Wshadow]
sys-utils/lscpu.c:1077:7: warning: shadowed declaration is here [-Wshadow]
sys-utils/lscpu.c:1196:8: warning: declaration of 'buf' shadows a previous local [-Wshadow]
sys-utils/lscpu.c:1077:7: warning: shadowed declaration is here [-Wshadow]
sys-utils/lscpu.c:1197:7: warning: declaration of 'i' shadows a previous local [-Wshadow]
sys-utils/lscpu.c:1078:6: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:37:29 +02:00
Karel Zak 8e97eb4b9f lscpu: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:26:10 +02:00
Karel Zak 583f14ccbd lscpu: fix compiler warning [-Wmissing-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-16 18:52:30 +02:00
Karel Zak 140014a424 lscpu: fix compiler warning [-Wsign-compare]
lscpu.c: In function ‘has_pci_device’:
lscpu.c:425:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
lscpu.c:425:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-19 13:14:20 +02:00
Sami Kerola 13cf6fc8d9 lscpu: values in /proc/bus/pci/devices are always unsigned
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 18:00:00 +02:00
Sami Kerola 41a8940d43 lscpu: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Petr Uzel 14e8be8ab3 lscpu: fix possibly undefined operation
With -Wall -Werror, compilation of lscpu.c fails with:

  Making all in sys-utils
  make[2]: Entering directory `/home/petr/upstream/util-linux/sys-utils'
  gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -include ../config.h -I../include -DLOCALEDIR=\"/usr/share/locale\"  -fsigned-char -Wall -Werror -MT lscpu.o -MD -MP -MF .deps/lscpu.Tpo -c -o lscpu.o lscpu.c
  lscpu.c: In function ‘print_parsable’:
  lscpu.c:971:7: error: operation on ‘p’ may be undefined [-Werror=sequence-point]
  cc1: all warnings being treated as errors

Fix by splitting the pointer increment to separate statement.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-04-23 14:05:29 +02:00
Bernhard Voelker 455fe9a075 Fix typos found by misspellings
The tool misspellings (https://github.com/lyda/misspell-check)
detected several typos. Command used:

  $ git ls-files | grep -v ^po/ | misspellings -f -

* isosize: Fix typo in usage string.
* configure.ac: Fix typo in help string of --enable-most-builds option.
* fdisk: Fix typo in man page.
* libblkid, blkid, mount: Likewise.
* Fix various typos in docs and in source code comments.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-04-23 13:16:35 +02:00
Sami Kerola efb8854f4c sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:49:40 +02:00
Sami Kerola 6f312c8957 xalloc: use xasprintf in all files
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
The COPYING and Documentation/licenses/COPYING* files are being
replaced by files from GNU web site.

http://www.gnu.org/licenses/gpl-2.0.txt
http://www.gnu.org/licenses/lgpl-2.1.txt

Postal addresses to FSF in other files are updated to match with the
address in license files.

Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-24 14:13:35 +01:00
Karel Zak ad655c88ff lscpu: fix fd leak
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-02 12:32:45 +01:00
Karel Zak 701e2b8e53 chcpu: check get_max_number_of_cpus() result properly
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-01 12:26:32 +01:00
Karel Zak 960bf13048 lscpu: dereferencing NULL pointer [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-31 15:00:52 +01:00
Davidlohr Bueso 756d79cd63 lscpu: fix compiler warnings
The string format is not being passed triggering:

    lscpu.c: In function ‘read_hypervisor’:
    lscpu.c:545:4: warning: format not a string literal and no format arguments
    lscpu.c: In function ‘get_cell_header’:
    lscpu.c:904:2: warning: format not a string literal and no format arguments
    lscpu.c:904:2: warning: format not a string literal and no format arguments

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-01-05 17:09:27 +01:00
Dave Reisner 8290a24952 lscpu: use xalloc libs
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-01-04 13:53:38 +01:00
Karel Zak 3d27b76ac1 lscpu: add columns description to help, fix header for parsable output
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-11 12:23:23 +02:00
Heiko Carstens f23608b892 lscpu: fix typo in help text
Add missing 'n' in help text for extended output line.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-10-11 11:36:05 +02:00
Heiko Carstens 847b982ee3 lscpu: switch Yes/No output to lower case
Some people complained about the first letter of Yes/No as seen in the
online and configured column in the human readabe output being a capital
letter instead of the expected lower case letter.
So let's try to make everbody happy and convert them to lower case.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-10-11 11:36:03 +02:00
Heiko Carstens 7bbb7829ca lscpu: stricter command line parsing
Disallow superfluous commands for lscpu like e.g. "lscpu bla" and let it
fail print the help text instead.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 14:48:33 +02:00
Heiko Carstens 7afc23874e lscpu: add --offline option
Implement "--offline" option which only prints offline cpus. As a side effect
we can get rid of the internal "allcpus" flag, since if we want to print
informations for online and offline cpus we simply set both flags.

When reading sysfs attributes of cpus this is now done for all cpus, since
e.g. the topology informations of the online cpus may influence the
topology informations of the offline cpus. This mainly because online cpus
may contain masks which include offline cpus while offline cpus have a
missing topology directory.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 14:48:33 +02:00
Heiko Carstens 81137d1c0b lscpu: fix -e output
The modifier mod->allcpus must be set earlier and also must be used
earlier. The current code only reads sysfs attributes from online
cpus but skips offline cpus.
So initialize mod->allcpus earlier.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:37:52 +02:00
Heiko Carstens 8148217b5b lib,path: move path access functions from lscpu into lib/path.c
A couple of these functions already have been copied to chcpu.c,
so it makes sense to move these functions into an own file.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:36:41 +02:00
Karel Zak b9d18bc3f8 lscpu: add column names to --help
* use uppercase by default (only -p uses lowercase)
 * a little cleanup usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 12:45:42 +02:00
Karel Zak 50c6ee4cb4 lscpu: gettextize two columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 12:26:02 +02:00
Heiko Carstens e43fc13e76 lscpu: s/Y/Yes/ s/N/No/
However I'd like to see one change if you don't object: printing just "N" or
"Y" instead of "No" and "Yes" in the human readable output looks a bit ugly to
me.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-12 12:39:30 +02:00
Heiko Carstens 10829cd73c lscpu: add Hypervisor to output
Some vendors have several hypervisors. Therefore it makes sense to not only
print out the hypervisor vendor but also the name of the hypervisor.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 23:54:01 +02:00
Karel Zak 23e9e95ac3 lscpu: add --online option
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 23:50:41 +02:00
Heiko Carstens 0ad29ff6b0 lscpu: add --all option
The parsable output includes only lines of online CPUs. To also include
lines for all offline CPUs the "--all" option can be specified.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-09 23:50:01 +02:00
Heiko Carstens a7e5300c97 lscpu: add online state to output
lscpu only prints lines for online CPUs. At least for the human readable
list the offline CPUs are of interest as well. In order to distinguish
between online and offline CPUs introduce the "Online" column.
By default the human readable output now displays online and offline CPUs.
The parsable output is not changed. It will print only lines for online
CPUs as it used to do.

[kzak@redhat.com: - minor changes]

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 23:49:22 +02:00
Heiko Carstens d231eea114 lscpu: add configured state to output
CPUs may be in a configured or deconfigured state depending if the CPU resource
may be used by the guest.  If a CPU is in configured state the guest may use it
(i.e. set it online). It it is in deconfigured state it cannot use it before
changing its state to configured.  Display this CPU attribute as well.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-09 23:41:25 +02:00
Karel Zak ba45d8c1ea lscpu: add human readable extended cpu table output
Based on patch from Heiko Carstens <heiko.carstens@de.ibm.com>:

lscpu currently only supports a parsable output which contains a row for
each cpu and its attributes. This output contains only comas as separators
and is hard to read for humans.

Therefore add a new option "-e | --extended" which outputs the rows in a
much more readable (and non-parsable) form. Just like for the -p option a
list of columns can be specified that shall be included in the output.

By default this option will print all columns that contain data.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 23:41:01 +02:00
Karel Zak e3b3a2f3f8 lscpu: use buffer for data and headers
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 23:40:28 +02:00
Karel Zak e9d659ea85 lscpu: use function to search in cpu masks arrays
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 23:27:40 +02:00
Karel Zak 8005924a89 lscpu: cleanup output modes
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 07:25:21 +02:00
Heiko Carstens 44de912cdf lscpu: add --version option
Add a --version option like most other tools have it.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-09 06:34:43 +02:00
Heiko Carstens dcdead4271 lscpu: allow read_cache() to be called for offline cpus
First check path before accessing files to be sure they actually exist. This is
necessary when also informations for offline CPUs will be printed.  Since we do
not necessarily know if "cpu is offline" means the same as "path does not
exist" just check for it.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-09 06:30:06 +02:00
Heiko Carstens f6512068b2 lscpu: simplify cache column output function
Simplify the logic to "always print a ',' for each cache except if it is the
last one.  This is also a preparation patch for printing the cache column for
offline CPUs where it would print one colon too much because of the current
logic.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-09 06:24:26 +02:00
Heiko Carstens 08cd09415a lscpu: fix cache output for extended parsable output
The extended parsable output prints a colon instead of comma between each
item. The case where a CPU doesn't belong to any cache was not converted.
Just fix this.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-09 06:24:14 +02:00
Heiko Carstens c403ae6a1a lscpu: remove comma operator
Fix typo where the comma operator has been introduced.
Use a semicolon instead so we end up with simple assignment expressions.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-09 06:24:12 +02:00
Karel Zak b82c15bd19 Merge branch 'chcpu' of git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux
* 'chcpu' of git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux:
  chcpu: new tool
  cpuset: add option to allow cpulist_parse() to fail
2011-08-31 11:49:27 +02:00
Karel Zak e8a728df31 Merge branch 'lscpu' of git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux
* 'lscpu' of git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux:
  lscpu: add physical cpu address to parseable output
  lscpu: add cpu polarization to parseable output
  lscpu: show dispatching mode
  lscpu: use hypervisor generated topology information
  lscpu: detect IBM hypervisor
  lscpu: fix fallback nthreads calculation
  lscpu: fix cpu map array sizes
  lscpu: fix s390 bogomips detection coding style
2011-08-30 12:05:05 +02:00
Karel Zak 7f1ec5e8d4 lscpu: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:28:02 +02:00
Heiko Carstens b16f615afb cpuset: add option to allow cpulist_parse() to fail
This is a preparation patch for chcpu. If a cpu should be added to
a cpu_set where the cpu doesn't fit into the cpu_set this got silently
ignored.
Since the cpu-list is user space provided it should be checked if cpus
are specified that are completely out of range of the system.
In order to do that add a parameter which specifies if cpulist_parse()
should fail if it parses a cpu-list with "impossible" cpus.
The current callers have been converted so they behave like before.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-15 07:52:44 +02:00
Heiko Carstens 596b884510 lscpu: add physical cpu address to parseable output
Print also the physical cpu address for each logical cpu in parsable
output if selected and present via sysfs.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-14 17:34:39 +02:00
Heiko Carstens 2b8fcb8138 lscpu: add cpu polarization to parseable output
When running in different dispatching mode the virtual cpus may
have different polarizations.
E.g. in "vertical" mode cpus may have a polarization of "vertical:high"
which means the virtual cpu has dedicated physical cpu assigned.
Print this information in the parsable output.

Note that this breaks the current rule that
a) the parseable output contains only numbers
b) these numbers are equal or increased in each line

Since however this new item must be selected with the "list" argument
this shouldn't be a problem.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-14 17:34:34 +02:00
Heiko Carstens a0fff77e93 lscpu: show dispatching mode
A virtual guest my run in either "horiziontal" or "vertical" mode
which is the mode in which the underlying hypervisor schedules the
guest cpu.
Since this is of interest print this in the readable output.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-14 17:34:30 +02:00
Heiko Carstens 8648ca961f lscpu: use hypervisor generated topology information
The readable output prints also informations like cores per socket etc.
On newer kernel versions on s390 this information is available via
/proc/sysinfo. However it does not contain the layout of the guest but
the layout of the real machine.
Nevertheless this is better than random guessing with completely broken
numbers like we have it now on s390. If the information is not available
we fall back to old mechanism with more or less random numbers.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-14 17:34:26 +02:00
Heiko Carstens b8ec7bdfeb lscpu: detect IBM hypervisor
Detect if the hypervisor on s390 is from KVM or IBM.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-14 17:34:21 +02:00
Heiko Carstens 32a46618bc lscpu: fix fallback nthreads calculation
The fallback calculation of nthreads did not consider books.
In order to avoid division/multiply by/with zero make sure each number
used is at least "1".

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-14 17:34:17 +02:00
Heiko Carstens 9d1a3a18f3 lscpu: fix cpu map array sizes
Completely virtualized architectures like s390 may have multiple
virtual sockets and/or cores where each of them has a different
number of cores and cpus.
So the general assumption within the allocation scheme that e.g.
each socket contains the same number of cores is not necessarily
true. To make sure the arrays are always large enough we simply
allocate enough memory so that each array could hold cpu masks
for all present cpus.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-14 17:34:12 +02:00
Heiko Carstens abcd6368e6 lscpu: fix s390 bogomips detection coding style
Just make the s390 bogomips detection line look like all others.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-14 17:34:06 +02:00
Karel Zak 329fd1c3a0 lscpu: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 13:03:19 +02:00
Karel Zak 477251f8f5 lscpu: extend --parse functionality
... to allow define output columns, for example:

	$ lscpu --parse=CPU,CORE,NODE,CACHE
	# CPU,Core,Node,L1d:L1i:L2
	0,0,0,0:0:0
	1,1,0,1:1:0

Note that CPU caches are separated by ":" in the new format. The
output for --parse (without the list of the columns) is backwardly
compatible, it means:

	$ lscpu --parse
	# CPU,Core,Socket,Node,,L1d,L1i,L2
	0,0,0,0,,0,0,0
	1,1,0,0,,1,1,0

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 23:10:01 +02:00
Davidlohr Bueso 08de16d003 lscpu: use xalloc
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-07-26 11:58:38 +02:00
Heiko Carstens 56baaa4e1f lscpu: add support for books
This patch adds support for books in cpu topology output. Books are
currently only present on the s390 architecture, however it looks like
others will follow to use the extra scheduling domain of the kernel.

Books are logically between sockets and nodes. In order to not break
any existing tools that might parse the output of lscpu the output
is changed so that books will follow nodes:
CPU,Core,Socket,Node,Book

In addition the readable output is changed from
"CPU socket(s):" to "Socket(s) per book:" or simply "Socket(s):" in the
absence of books.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-07-18 10:46:35 +02:00
Heiko Carstens 1f5b7d4b87 lscpu: fix bogomips detection for s390
s390 has a "bogomips per cpu" string instead of a "bogomips" string in
/proc/sysinfo. So add a second bogomips lookup which detects the s390
variant.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-06-27 16:13:48 +02:00
Stephen Hemminger 99fbc877e5 lscpu: detect VMware hypervisor
Add detection of VMware.
Tested on VMware Workstation 7.1.4

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
2011-06-20 12:53:28 +02:00
Karel Zak c487c90ccd lscpu: detect sun4{u,v} in /proc/cpuinfo for sparc64
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-31 14:30:06 +02:00
Karel Zak 4e740fd81a lscpu: fix op-mode for /{sys,proc} dumps
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-31 13:09:50 +02:00