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>
This commit is contained in:
parent
9c72131065
commit
10d927ab3b
|
@ -897,10 +897,13 @@ read_cache(struct lscpu_desc *desc, int idx)
|
|||
ca->name = xstrdup(buf);
|
||||
|
||||
/* cache size */
|
||||
path_read_str(buf, sizeof(buf),
|
||||
_PATH_SYS_CPU "/cpu%d/cache/index%d/size",
|
||||
num, i);
|
||||
ca->size = xstrdup(buf);
|
||||
if (path_exist(_PATH_SYS_CPU "/cpu%d/cache/index%d/size",num, i)) {
|
||||
path_read_str(buf, sizeof(buf),
|
||||
_PATH_SYS_CPU "/cpu%d/cache/index%d/size", num, i);
|
||||
ca->size = xstrdup(buf);
|
||||
} else {
|
||||
ca->size = xstrdup("unknown size");
|
||||
}
|
||||
}
|
||||
|
||||
/* information about how CPUs share different caches */
|
||||
|
|
Loading…
Reference in New Issue