The sys file system knows all about this:
$ ls /sys/devices/system/cpu
cpu0 cpu2 cpuidle possible sched_mc_power_savings
cpu1 cpu3 online present
$ ls /sys/devices/system/cpu/cpu0/topology/
core_id core_siblings_list thread_siblings
core_siblings physical_package_id thread_siblings_list
Here's the documentation
Using this file system, you can find out how many processors you have, how many threads they have, which processors are next to any other processor, and also which processors share caches with others.
- Q: CPU cpu0 L2 ?
$ cat /sys/devices/system/cpu/cpu0/cache/index2/{type,level,shared_cpu_list}
Unified
2
0-1
A: L2 cpu1 ( ).
: Q: cpu0 ( ):
cat /sys/devices/system/cpu/cpu0/topology/core_siblings
00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000055
A: 0, 2, 4 6. ( , lsb = cpu0)
Linux- sys . (, proc/sys?). thread_siblings_list , thread_siblings (bit pattern) .