Commit Graph

28 Commits

Author SHA1 Message Date
Karel Zak f5d1353246 lscpu: new cpuinfo parser
* extendable by new patterns
* simple semantic
* the same code for all pattern types

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 801b125f8f lscpu: temporary commit
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak fd5999d9ac lscpu: support s390 cpuinfo processor-pre-line format
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak fd35a1dae6 lsblk: add lscpu_read_topology_polarization()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak f669523ba0 lscpu: move topology stuff to separate file
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 0266f5cbab lscpu: improve topology debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak fa6a21bf63 lscpu: calculate threads number from type specific values
Don't use global CPU masks (like "online" or "present") to
calculate type specific number of threads due systems with
mixed CPU types.

It's also necessary to check all thread_siblings maps to get the
highest number, because some threads (CPUs) may be disables, for
example old lscpu calculates number of threads from the cpu0 and
if you disable cpu0's sibling (cpu4):

	CPU(s):                          8
	On-line CPU(s) list:             0-7
	Thread(s) per core:              2        <---
	Core(s) per socket:              4
	Socket(s):                       1

 # chcpu --disable 4
 CPU 4 disabled

	CPU(s):                          8
	On-line CPU(s) list:             0-3,5-7
	Off-line CPU(s) list:            4
	Thread(s) per core:              1        <--- !
	Core(s) per socket:              4
	Socket(s):                       1

because 'thread_siblings' contains only one thread for cpu0:

 # cat /sys/devices/system/cpu/cpu{0,1,2,3,4,5,6,7}/topology/thread_siblings_list
 0
 1,5
 2,6
 3,7
 cat: /sys/devices/system/cpu/cpu4/topology/thread_siblings_list: No such file or directory
 1,5
 2,6
 3,7

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak b8a319460d lscpu: deallocate maps
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 314aa95fd5 lscpu: add lscpu_read_topolgy_ids()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 9d5f3b4873 lscpu: add lscpu_read_topology()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 9c5b106b01 lscpu: add lscpu_cpus_loopup_by_type(), improve readability
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 a94bb4357e lscpu: cleaup arch freeing
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 909d35758e lscpu: add lscpu_read_virtualization()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 154ee5a992 lscpu: add lscpu_read_numas()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 0796923aa8 lscpu: add lscpu_read_vulnerabilities()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak b152ec5436 lscpu: cleanup lscpu_unref_cputype()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 5a6da72c42 lscpu: add lscpu_read_extra()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 551f2b4dc9 lscpu: add lscpu_read_cpulists()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak d34b7f1b82 lscpu: add lscpu_read_architecture()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak d234a38101 lscpu: (cputype) simplify cpuinfo parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 855bab2a2e lscpu: add lscpu_cpu to internal API
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 7079f4662c lscpu: (cputype) move temporary stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak cbf8f1297b lscpu: (cputype) add header file, cleanup patterns code
* move structs definitions to header file
* define set of /proc/cpuinfo parsing patterns for cpu-type and for
  CPUs

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 329ec35ff0 lscpu: (cputype) add cpuinfo parser
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 71464ded30 lscpu: (cputype) add ref-counting, allocate context
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 450cb0b724 lscpu: (cputype) add debug stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 405d51edf4 lscpu: add very basic cputype code
The current lscpu assumes that all CPUs in the system are the same.
Unfortunately this is not true. We need to split all internal CPUs
descriptions to CPU-type and CPU.

This patch add lscpu-cputype.c where will be CPU-type description --
mostly based on /proc/cpuinfo.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00