UNIX CPU Diagnostics
CPU Usage
Linux
top
Once in top.. hit 'z' to colourize, '1' to show individual cpu cores, '?' for other optionshtop
htop
Processes using most CPU
dstat -c --top-cpu
AIX
topas
tprof -skeu -x sleep 10
tprof -skex sleep 10
CPU Load
Load average generally display three figures representing the average load over the last 1 minute, 5 minutes, and 15 minutes. The load average is displayed by various tools (w,top, htop), but this is probably the simplest...
uptime
On Linux, system load includes threads in Runnable (R) and in Uninterruptible sleep (D) states (typically disk I/O). On other flavours of UNIX this is usually just R (not D).Load should be less than the number of cores in your system. i.e. On a single core machine you would want load to be less than 1. On a quad core machine you would want load to be less than 4.
We can see which users are contributing to system load using...
ps -eo s,user | grep ^[RD] | sort | uniq -c | sort -nbr | head -20
On Linux, system load includes threads in Runnable (R) and in Uninterruptible sleep (D) states (typically disk I/O). On other flavours of UNIX this is usually just R (not D).To see what they are running use...
ps -eo s,user,cmd | grep ^[RD] | sort | uniq -c | sort -nbr | head -20
On Linux, system load includes threads in Runnable (R) and in Uninterruptible sleep (D) states (typically disk I/O). On other flavours of UNIX this is usually just R (not D).The vmstat command also gives some useful information. The first two columns under "procs" on Linux or "kthr" on AIX show runnable (r) and blocked (b) processes/threads. The value of "r" should generally be less than or equal to the number of logical CPUs. The value of "b" should generally be zero.
vmstat -wWI 2 10
CPU Benchmarking
Sysbench
sysbench --test=cpu run
CPU Blowfish
Screenshot is from hardinfo. This tends to be available in Ubuntu as "System Profiler and Benchmark"
Geekbench
TODO
CPU Information
CPU Count
nproc --all
getconf _NPROCESSORS_ONLN
CPU Information
lscpu
cat /proc/cpuinfo
sudo dmidecode -t 4
Handle 0x0004, DMI type 4, 42 bytesProcessor Information Socket Designation: CPU0 Type: Central Processor Family: Xeon Manufacturer: Intel ID: D7 06 02 00 FF FB EB BF Signature: Type 0, Family 6, Model 45, Stepping 7 Flags: FPU (Floating-point unit on-chip) VME (Virtual mode extension) DE (Debugging extension) PSE (Page size extension) TSC (Time stamp counter) MSR (Model specific registers) PAE (Physical address extension) MCE (Machine check exception) CX8 (CMPXCHG8 instruction supported) APIC (On-chip APIC hardware supported) SEP (Fast system call) MTRR (Memory type range registers) PGE (Page global enable) MCA (Machine check architecture) CMOV (Conditional move instruction supported) PAT (Page attribute table) PSE-36 (36-bit page size extension) CLFSH (CLFLUSH instruction supported) DS (Debug store) ACPI (ACPI supported) MMX (MMX technology supported) FXSR (FXSAVE and FXSTOR instructions supported) SSE (Streaming SIMD extensions) SSE2 (Streaming SIMD extensions 2) SS (Self-snoop) HTT (Multi-threading) TM (Thermal monitor supported) PBE (Pending break enabled) Version: Intel(R) Xeon(R) CPU E5-2667 @ 2.90GHz Voltage: 1.1 V External Clock: 100 MHz Max Speed: 3800 MHz Current Speed: 2900 MHz Status: Populated, Enabled Upgrade: Socket LGA2011 L1 Cache Handle: 0x0005 L2 Cache Handle: 0x0006 L3 Cache Handle: 0x0007 Serial Number: Not Specified Asset Tag: Not Specified Part Number: Not Specified Core Count: 6 Core Enabled: 6 Thread Count: 12 Characteristics: 64-bit capable Multi-Core Hardware Thread Execute Protection Enhanced Virtualization Power/Performance Control
Handle 0x0008, DMI type 4, 42 bytesProcessor Information Socket Designation: CPU1 Type: Central Processor Family: Xeon Manufacturer: Intel ID: 00 00 00 00 00 00 00 00 Signature: Type 0, Family 0, Model 0, Stepping 0 Flags: None Version: Intel(R) Xeon(R) CPU E5-2667 @ 2.90GHz Voltage: 0.2 V External Clock: 100 MHz Max Speed: 4000 MHz Current Speed: Unknown Status: Unpopulated Upgrade: Socket LGA2011 L1 Cache Handle: Not Provided L2 Cache Handle: Not Provided L3 Cache Handle: Not Provided Serial Number: Not Specified Asset Tag: Not Specified Part Number: Not Specified Core Count: 101 Core Enabled: 85 Thread Count: 63 Characteristics: Multi-Core Enhanced Virtualization Power/Performance Control
sudo lshw -class processor
sudo dmidecode -t 4 | egrep -i 'core (count|enabled)|thread count|Version'
hwinfo --cpu --short
hwinfo --cpu
inxi -Cx -c 5
cpuid -1
The -1 flag stops cpuid returning duplicate information (if you know all CPUs are the same)fpuvmedepsetscmsrpaemcecx8apicsepmttrpgemcacmovpatpse36
clflushdtsacpimmxfxsrssesse2sshttm
pbe
pnipclmulqdqdtes64monitords_cplvmxsmxesttm2ssse3
cx16xtprpdcmpciddcasse4_1sse4_2x2apic
popcnttsc_deadline_timeraesxsave
avx
dthermidaaratplnpts
md_clear
flush_lid
CPU Information (AIX)
CPU SMT Type...
lparstat -i | grep ^Type
LPAR CPU usage Mode...
lparstat -i | grep ^Mode
LPAR CPU Entitlement...
lparstat -i | grep Entitled | grep -v of
Online Virtual CPUs...
lparstat -i | grep "Online Virtual"
Shared Pool ID...
lparstat -i | grep "Shared Pool ID"
Active CPUs in Pool...
lparstat -i | grep "Active CPUs in Pool"
CPU Type/Speed...
prtconf | grep "Processor Type"
prtconf -s
prtconf -c
Architecture (32-bit or 64-bit)
arch
uname -m
getconf LONG_BIT
lscpu | grep Architecture
hwinfo --cpu | grep Arch | uniq
inxi -Cx | grep bits
Flags/Capabilities
SMT - Symmetric Multi-Threading
AIX
You can see details of SMT using the smtctl command (but this is only executable by 'root' and can be a bad thing if run with the wrong arguments... i.e. it can turn off SMT).
smtctl
This system is SMT capable.
This system supports up to 4 SMT threads per processor.
SMT is currently enabled.
SMT boot mode is not set.
SMT threads are bound to the same virtual processor.
proc0 has 4 SMT threads.
Bind processor 0 is bound with proc0
Bind processor 1 is bound with proc0
Bind processor 2 is bound with proc0
Bind processor 3 is bound with proc0
Things like OEM and topas see each thread as a cpu and therefore show 4 cpus, when in fact they are all just simultaneous threads on the same core... which can be very misleading... to make matters worse 4 threads cannot do the same work as 4 dedicated cores... so even cpu utilisation figures can be skewed... i.e. if you are running 1 transaction in 1 second on 1 thread, you won't be able to run 2 transactions in 1 second using 2 threads (but you might get 2 transactions in 1.5 seconds using 2 threads instead of the 2 transactions in 2 seconds that you would expect from a single thread... i.e. it makes better use of the cores than single threading but there are still bottlenecks that stop 2 transactions running at full speed through the same cpu core at the same time)... if you looked at topas whilst your hypothetical 1 transaction in 1 second was running on 1 thread you would see cpu utilisation of 25% on a core with 4 threads (which just isn't true).
Bibliography
Benchmarkinghttps://www.addictivetips.com/ubuntu-linux-tips/linux-cpu-benchmark-tool/
Flagshttps://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean
SMThttps://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/s_commands/smtctl.html
AIXhttps://unix.stackexchange.com/questions/94404/cpu-usage-monitoring-in-aix-servers