summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: replaces atexit(close_stdout) with new close_stdout_atexit()Karel Zak2019-06-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: add a new columns to --cacheKarel Zak2019-06-171-5/+49
| | | | | References: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: check scols_line_set_data() return value [coverity scan]Karel Zak2019-05-281-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: make lookup() use more consistent [coverity scan]Karel Zak2019-05-281-2/+4
| | | | | | | We usually check lookup() return value. Let's do it in this case too. It seems static analyzers will be happy with consistent code. Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch '2019wk19' of https://github.com/kerolasa/util-linuxKarel Zak2019-05-201-8/+12
|\ | | | | | | | | | | | | | | | | | | | | * '2019wk19' of https://github.com/kerolasa/util-linux: lib/colors: remove redundant if statement wipefs: fix variable / function shadowing [cppcheck] sulogin: fix variable / function shadowing [cppcheck] lscpu: remove redundant condition check [cppcheck] libmount: avoid possible null pointer dereference [cppcheck] lib/mangle: fix possible null pointer dereference [cppcheck] sfdisk: remove unnecessary size check [cppcheck]
| * lscpu: remove redundant condition check [cppcheck]Sami Kerola2019-05-181-8/+12
| | | | | | | | | | | | | | | | | | [sys-utils/lscpu.c:1783] -> [sys-utils/lscpu.c:1785]: (warning) Either the condition 'desc' is redundant or there is possible null pointer dereference: desc. [sys-utils/lscpu.c:1840] -> [sys-utils/lscpu.c:1842]: (warning) Either the condition 'desc' is redundant or there is possible null pointer dereference: desc. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | lscpu: fix floating point exceptionSami Kerola2019-05-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | As the title tells this change indeed fixes floating point exception, but post processing as value overwrite feels a wrong. Possibly something in input is making cpu set count to go wrong, but I could not get my head around what could it be. Anyway avoiding division by zero seems better than crashing so lets do this atleast for now. Caused-by: e5f721132ec8b8c933a396d8dcb3efcb67854f13 Addresses: https://github.com/karelzak/util-linux/issues/788 Reported-by: Lars Wendler <polynomial-c@gentoo.org> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | lscpu: remove extra space from field key nameSami Kerola2019-05-161-3/+3
|/ | | | | | | | | | | | | | | | | | | The extra space was more obvious in json output. But as the expected test output displays also the standard output can be effected by this change. $ lscpu --json | jq '.lscpu | .[].field' | grep ': ' "L1d cache: " "L1i cache: " "L2 cache: " "L3 cache: " "Vulnerability L1tf: " "Vulnerability Mds: " "Vulnerability Meltdown: " "Vulnerability Spec store bypass: " "Vulnerability Spectre v1: " "Vulnerability Spectre v2: " Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-5/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: wrap default output long lines on terminalKarel Zak2019-04-111-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: report CPU vulnerabilitiesKarel Zak2019-04-111-0/+73
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: fix excl[] array orderKarel Zak2019-03-191-1/+1
| | | | | | It (rows and columns) must be in ASCII order. Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: fix and document --output-allKarel Zak2019-03-191-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: define libsmartcols flags for -eKarel Zak2019-03-191-10/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: fix --caches orderKarel Zak2019-03-191-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: add --bytesKarel Zak2019-03-191-10/+23
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: add --cachesKarel Zak2019-03-191-37/+214
| | | | | | | | | | | | | | | $ 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>
* lscpu: rename macros and functionsKarel Zak2019-03-191-77/+77
| | | | | | | 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>
* lscpu: report more usable cache sizesKarel Zak2019-03-191-2/+41
| | | | | | | | | | | | | | | | | 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>
* lscpu: add 'Frequency boost'Karel Zak2019-03-151-0/+7
| | | | | | | | 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>
* lscpu: Add aarch32 detection on aarch64Jeremy Linton2018-12-111-0/+14
| | | | | | | | | 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>
* lscpu: use the first VM from /proc/sysinfoKarel Zak2018-09-041-0/+1
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/685 Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: make xasprintf call more robustKarel Zak2018-09-041-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: add 'Address sizes'Karel Zak2018-08-011-0/+5
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/674 Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: fix resource leak [coverity scan]Karel Zak2018-07-251-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: use new ul_path_* APIKarel Zak2018-06-211-133/+132Star
| | | | | | | | | * 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>
* Merge branch 'output-all' of https://github.com/kerolasa/lelux-utiliteetitKarel Zak2018-05-101-0/+11
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'output-all' of https://github.com/kerolasa/lelux-utiliteetit: zramctl: add --output-all option swapon: add --output-all option rfkill: add --output-all option partx: add --output-all option lsns: add --output-all option lsmem: add --output-all option lslogins: add --output-all option lslocks: add --output-all option lscpu: add --output-all option losetup: add --output-all option findmnt: add --output-all option
| * lscpu: add --output-all optionSami Kerola2018-05-031-0/+11
| | | | | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | lscpu, chcpu: Avoid use of the old CPU macrosStanislav Brabec2018-05-101-4/+9
|/ | | | | | | | 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>
* Avoid crash in min/max caculation when cpu#0 being offlineDirk Mueller2018-03-171-6/+6
| | | | | | | | 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.
* lscpu: move ARM decoding to lscpu-arm.cKarel Zak2018-01-221-42/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: move struct lscpu_desc header fileKarel Zak2018-01-221-154/+1Star
| | | | | | | The lscpu code is growing and it seems better to allow to make code more structured. Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: Decode ARM CPUsRiku Voipio2018-01-191-0/+47
| | | | | | | | 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>
* lscpu: Treat read failure on Xen Hypervisor properties as non-fatalDirk Mueller2017-11-041-3/+0Star
| | | | | | At least on the Sydney Amazon EC2 region this file doesn't show up, and the fatal exit code causes the rest of the useful information to not show up.
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | 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>
* lscpu: make clang analyzer happyRuediger Meier2017-06-291-14/+13Star
| | | | | | | | | | | | | | | | | | 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>
* lsmem: fix, using freed memoryRuediger Meier2017-06-291-3/+3
| | | | | | | | | | | | | 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>
* lib/path: fix crash, pathbuf overflowRuediger Meier2017-06-271-1/+2
| | | | | | | | | | | | | | Before: $ lscpu -s "$(tr '\0' 'x' < /dev/zero | head -c 10000)" Segmentation fault (core dumped) After: $ lscpu -s "$(tr '\0' 'x' < /dev/zero | head -c 10000)" lscpu: invalid argument to --sysroot: File name too long Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | 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>
* misc: never use usage(stderr)Ruediger Meier2017-06-261-5/+8
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* include/c.h: add USAGE_COMMANDS and USAGE_COLUMNSJ William Piggott2017-06-241-2/+1Star
| | | | | | | | | | | | * login-utils/lslogins.c: all uses changed * misc-utils/findmnt.c: likewise * sys-utils/blkzone.c: likewise * disk-utils/sfdisk.c: likewise * sys-utils/lscpu.c: likewise * sys-utils/lsmem.c: likewise * sys-utils/wdctl.c: likewise Signed-off-by: J William Piggott <elseifthen@gmx.com>
* lscpu: make min/max freq arrays usage more robustKarel Zak2017-06-011-4/+6
| | | | | | | | | 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>
* misc: consolidate smartcols error messagesKarel Zak2017-05-181-8/+8
| | | | | | ... just to keep translators happy Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: reuse the same bufferKarel Zak2017-05-091-14/+9Star
| | | | | | | | 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>
* lscpu: make cpu_{max,min}_mhz() usage more elegantKarel Zak2017-05-091-16/+12Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: Read available CPUs max and min frequenciesMamatha Inamdar2017-05-091-5/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lscpu: fix mem leak [coverity scan]Karel Zak2017-03-311-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: check return code [coverity scan]Karel Zak2017-03-311-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: add --jsonKarel Zak2017-03-141-2/+16
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: use libsmartcols to print summary tooKarel Zak2017-03-141-52/+91
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/419 Signed-off-by: Karel Zak <kzak@redhat.com>