Linux Command - lscpu
The Linux lscpu command is used to display information about the CPU or CPUs on a system.
“The cache sizes are reported as summary from all CPUs. The versions before v2.34 reported per-core sizes, but this output was confusing due to complicated CPUs topology and the way how caches are shared between CPUs.”
lscpu # dump a bunch of CPU info
lscpu -e # table, per CPU, human readable
lscpu -e=core,MHZ,MAXMHZ # specify columns
lscpu -e --output-all # all columns
lscpu -p # table, per CPU, easy parse
lscpu -p=MAXMHZ,MINMHZ # specify columns
lscpu -p=+MAXMHZ,MINMHZ # use "+" to extend ( append cols )
lscpu -C # cache details, as table
lscpu -C=name,level # cache details, as table, specify columns
lscpu -C --output-all # all columns
lscpu -J # json output
Options:
-a, –all | Include lines for online and offline CPUs in the output (default for -e). This option may only be specified together with option -e or -p. |
-B, –bytes | Print the sizes in bytes rather than in a human-readable format. |
-b, –online | Limit the output to online CPUs (default for -p). This option may only be specified together with option -e or -p. |
-C, –caches[=list] | Display details about CPU caches. all details or specify a list |
-c, –offline | Limit the output to offline CPUs. This option may only be specified together with option -e or -p. |
-e, –extended[=list] | Display the CPU information in human-readable format. - table output, human readable, can specify a list of fields |
-h, –help | Display help text and exit. |
-J, –json | Use JSON output format for the default summary or extended output (see –extended). |
-p, –parse[=list] | Optimize the command output for easy parsing. |
-s, –sysroot directory | Gather CPU data for a Linux instance other than the instance from which the lscpu command is issued. The specified directory is the system root of the Linux instance to be inspected. |
-x, –hex | Use hexadecimal masks for CPU sets (for example “ff”). The default is to print the sets in list format (for example 0,1). Note that before version 2.30 the mask has been printed with 0x prefix. |
-y, –physical | Display physical IDs for all columns with topology elements - platform specific, not logical, might not be unique |
-V, –version | Display version information and exit. |
–output-all | Output all available columns. This option must be combined with either –extended, –parse or –caches. |
Available output columns for -e or -p:
BOGOMIPS | crude measurement of CPU speed |
CPU | logical CPU number |
CORE | logical core number |
SOCKET | logical socket number |
CLUSTER | logical cluster number |
NODE | logical NUMA node number |
BOOK | logical book number |
DRAWER | logical drawer number |
CACHE | shows how caches are shared between CPUs |
POLARIZATION | CPU dispatching mode on virtual hardware |
ADDRESS | physical address of a CPU |
CONFIGURED | shows if the hypervisor has allocated the CPU |
ONLINE | shows if Linux currently makes use of the CPU |
MHZ | shows the currently MHz of the CPU |
MAXMHZ | shows the maximum MHz of the CPU |
MINMHZ | shows the minimum MHz of the CPU |
Available output columns for -C:
ALL-SIZE | size of all system caches |
LEVEL | cache level |
NAME | cache name |
ONE-SIZE | size of one cache |
TYPE | cache type |
WAYS | ways of associativity |
ALLOC-POLICY | allocation policy |
WRITE-POLICY | write policy |
PHY-LINE | number of physical cache line per cache t |
SETS | number of sets in the cache; set lines has the same cache index |
COHERENCY-SIZE | minimum amount of data in bytes transferred from memory to cache |