Finding how many processors
I wanted to find out the processor details in my laptop and I found out that there are several ways to check. For example, see The RedHat community discussion on Figuring out CPUs and Sockets.
The lscpu command reads /proc/cpuinfo file to get the CPU architecture details. So, you can also read it get more info.
In this blog post, I'm listing few commands to find out details about CPUs.
I'm using Ubuntu in my Lenovo ThinkPad T530 laptop and following commands should be working any Linux system.
Display information about CPU architecture
$ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 2 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 58 Model name: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz Stepping: 9 CPU MHz: 1199.988 CPU max MHz: 3600.0000 CPU min MHz: 1200.0000 BogoMIPS: 5787.10 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 4096K NUMA node0 CPU(s): 0-3 $ lscpu -e CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ 0 0 0 0 0:0:0:0 yes 3600.0000 1200.0000 1 0 0 0 0:0:0:0 yes 3600.0000 1200.0000 2 0 0 1 1:1:1:0 yes 3600.0000 1200.0000 3 0 0 1 1:1:1:0 yes 3600.0000 1200.0000
The lscpu command reads /proc/cpuinfo file to get the CPU architecture details. So, you can also read it get more info.
$ cat /proc/cpuinfo
The lshw (list hardware) is another command to get CPU details.
There is a GUI tool named "hardinfo", which can show details about various hardware components.
The dmidecode is another tool to find out hardware details. Following is an example to find processor details. The value "4" is the Dmi Type for the processor.
The cpuid tool can dump CPUID information for each CPU.
The inxi is also another tool to check hardware information on Linux.
$ sudo lshw -class processor
There is a GUI tool named "hardinfo", which can show details about various hardware components.
$ sudo apt-get install hardinfo $ hardinfo
The dmidecode is another tool to find out hardware details. Following is an example to find processor details. The value "4" is the Dmi Type for the processor.
$ sudo dmidecode -t 4
The cpuid tool can dump CPUID information for each CPU.
$ sudo apt-get install cpuid $ cpuid
The inxi is also another tool to check hardware information on Linux.
$ sudo apt-get install inxi # Show full CPU output, including per CPU clockspeed and CPU max speed $ inxi -C
Finding number of processors
# Print the number of processing units available $ nproc 4
$ cat /proc/cpuinfo | grep processor | wc -l 4
Finding number of Physical CPUs
$ cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l 1
Finding number of cores per socket
$ lscpu | grep 'socket' Core(s) per socket: 2
$ cat /proc/cpuinfo | grep "cpu cores" | uniq cpu cores : 2
Finding number of threads per core
$ lscpu | grep -i thread Thread(s) per core: 2
Summary
It's important to know about the CPUs when we are doing performance tests. A physical CPU is inserted into a single CPU socket. There should be multiple CPU sockets to support multiple CPUs. However modern CPUs support multiple cores and hyper-threading. See: CPU Basics: Multiple CPUs, Cores, and Hyper-Threading Explained
We can use following formula to calculate the number of logical processors we see in our system.
Number of Logical Processors = Number of Sockets x Number of Cores per CPU x Threads per Core
In my Laptop, there is one physical processor with two cores and each core has two threads. So, I have 4 logical processors. :)
Comments