(3)lscpu详解

(3)lscpu详解 ,第1张

(3)lscpu详解 (每周一个linux命令系列) (3)lscpu详解 (每周一个linux命令系列)

linux命令 lscpu详解

引言:今天的命令是用来看cpu信息的lscpu

lscpu

我们先看man lscpu


display information about the CPU architecture

翻译:显示cpu架构信息

具体的描述如下:


lscpu gathers CPU architecture information from sysfs, /proc/cpuinfo
and any applicable architecture-specific libraries (e.g. librtas on
Powerpc). The command output can be optimized for parsing or for
easy readability by humans. The information includes, for example,
the number of CPUs, threads, cores, sockets, and Non-Uniform Memory
Access (NUMA) nodes. There is also information about the CPU caches
and cache sharing, family, model, bogoMIPS, byte order, and stepping. In virtualized environments, the CPU architecture information dis‐
played reflects the configuration of the guest operating system which
is typically different from the physical (host) system. On architec‐
tures that support retrieving physical topology information, lscpu
also displays the number of physical sockets, chips, cores in the
host system. Options that result in an output table have a list argument. Use
this argument to customize the command output. Specify a comma-sepa‐
rated list of column labels to limit the output table to only the
specified columns, arranged in the specified order. See COLUMNS for
a list of valid column labels. The column labels are not case sensi‐
tive. Not all columns are supported on all architectures. If an unsup‐
ported column is specified, lscpu prints the column but does not pro‐
vide any data for it.

翻译如下:

lscpu命令从sysfs、/proc/cpuinfo、或者某些适用于特定架构的库中收集数据。


命令的输出会以人类易读的方式展示如下信息:cpu、线程、核心、插槽和Non-Uniform MemoryAccess (NUMA)节点的数量,也有cpu共享缓存,cpu的族号,运行模式,处理指令的速度,大小端,步进等信息

在虚拟环境下,系统架构信息展示映射着客户 *** 作系统的设置,这和物理主机是有明显差异的。


在架构上支持检索物理拓扑信息,lscpu命令也显示主机系统中的物理插槽数量,芯片,内核数。


Options可以提供一些参数,用这些参数可以自定义命令输出。


指定一个列表分隔符,指定一个逗号分隔的列标签列表,以将输出表限制为按指定的顺序排列的指定的列。


按指定顺序排列。


有效列标签请参考COLUMNS的列表。


列标签不区分大小写。


(man的输出中有各种参数太多这里就不放出来了。


可以自己去查看)

我们再来看一下命令执行结果

Architecture:          x86_64 //架构--这里的64指的位处理器
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian //小端法
CPU(s): 4 //cpu数量
On-line CPU(s) list: 0-3 //在线的cpu数量 有些时候为了省电或者过热的时候,某些CPU会停止运行
Thread(s) per core: 1 //每个核心的线程数
Core(s) per socket: 4 //每个插槽上有几个核心
座: 1
NUMA 节点: 1 //NUMA 这个太复杂,所以他的解释在下面
厂商 ID: GenuineIntel
CPU 系列: 6
型号: 94
型号名称: Intel(R) Xeon(R) CPU E3-1225 v5 @ 3.30GHz
步进: 3 //这个可以简单理解为版本号 也有A0这样的标识方式
CPU MHz: 900.023
CPU max MHz: 3700.0000
CPU min MHz: 800.0000
BogoMIPS: 6624.00 // MIPS是每秒百万条指令,Bogo是Bogus(伪)的意思,这里是估算MIPS值
虚拟化: VT-x //虚拟化技术,这个我不太懂,不敢乱说
L1d 缓存: 32K //一级高速缓存 dcache 用来存储数据
L1i 缓存: 32K //一级高速缓存 icache 用来存储指令
L2 缓存: 256K
L3 缓存: 8192K //缓存速度上 L1 > L2 > L3 > DDR(内存) 内存的理论速度在几十g一秒
NUMA 节点0 CPU: 0-3 //四个cpu在一个numa节点上
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb invpcid_single intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm arat pln pts hwp hwp_notify hwp_act_window hwp_epp //Flags是标识了一些cpu的特征 具体可以查看https://blog.csdn.net/nemo2011/article/details/7531212

man中还有更多的描述,对大家来说意义也不大,接下来我们直接看选项

    选项:
-a, --all 同时打印在线和离线 CPU (-e 选项默认值) 此选项只能与选项-e 或-p 一起指定
-b, --online 只打印在线 CPU (-p 选项默认值) 此选项只能与选项-e 或-p 一起指定
-c, --offline 只打印离线 CPU 此选项只能与选项-e 或-p 一起指定。



-e, --extended[=<列表>] 打印扩展的可读格式 (类似表格的形式)
如果省略该列表参数, 则在命令输出中包括所有可用数据的列
指定列表参数时, 选项字符串、等号 (=) 和列表不能包含任何空格或其他空白。



结果如下:
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ
0 0 0 0 0:0:0:0 是 3700.0000 800.0000
1 0 0 1 1:1:1:0 是 3700.0000 800.0000
2 0 0 2 2:2:2:0 是 3700.0000 800.0000
3 0 0 3 3:3:3:0 是 3700.0000 800.0000
带list示例: lscpu -e=cpu,node
-p, --parse[=<列表>] 打印可解析格式
如果省略该列表参数, 则命令输出与早期版本的 lscpu 兼容。



在此兼容格式中, 两个逗号用于分隔 CPU 缓存列。



如果未标识任何 CPU 缓存, 则忽略缓存列。



如果使用列表参数, 则缓存列将用冒号 (:) 分隔
示例: lscpu -p=cpu,node,,L1d:L1i
我在使用上面命令的时候,不带缓存列正常显示,带缓存列不能输出数据也没报错,迷茫
-s, --sysroot <目录> 以指定目录作为系统根目录
收集 lscpu 命令所发出的实例以外的 Linux 实例的 CPU 数据。



指定的目录是要检查的 Linux 实例的系统根。



-x, --hex 打印十六进制掩码而非 CPU 列表
-y, --physical print physical instead of logical IDs
显示所有列的物理 id。


除了由 lscpu 分配的逻辑 id 之外
物理 id 是由内核提供的特定于平台的值。


无法检索元素的物理 ID 用破折号 (-) 字符显示
此选项不影响 CPU 逻辑编号。


-h, --help 显示此帮助并退出
-V, --version 输出版本信息并退出 可用的列:
CPU 逻辑 CPU 数量
CORE 逻辑核心数量
SOCKET 逻辑(CPU)座数量
NODE 逻辑 NUMA 节点数量
BOOK 逻辑 book 数
DRAWER logical drawer number //逻辑抽屉数(不太明白,好像和book有关系)
CACHE shows how caches are shared between CPUs //cpu之间如何共享缓存
POLARIZATION CPU dispatching mode on virtual hardware //虚拟硬件上的CPU调度模式
ADDRESS physical address of a CPU //cpu物理地址
CONFIGURED shows if the hypervisor has allocated the CPU //管理程序是否分配了cpu
ONLINE shows if Linux currently makes use of the CPU //在使用的cpu
MAXMHZ shows the maximum MHz of the CPU //最大频率
MINMHZ shows the minimum MHz of the CPU //最小频率

NUMA(Non-Uniform MemoryAccess)
中文名:分布式体系结构 (非统一内存体系结构)
区别于 UMA,统一内存体系结构

由于展开来讲设计到很多问题,也需要单独写一篇长文章才能说完,这里可以精简的说一下:

UMA中,多个CPU访问内存是没有区别的,成本和速度相同。


而在NUMA中,可以看成每个CPU有自己的内存,被称为本地内存,CPU之间通过一种方式联结,使得CPU可以访问非管辖范围内的内存(非本地内存),但是。


由于不属于自己的一亩三分地,需要通过另一个通道获取,速度回比访问本地内存要慢。


但是好处是这种方式增加了扩展性。


缺点是速度会受影响,尤其是对mysql这类的数据库软件有较大影响。


一般应该是接触不到,接触到了再去详细了解吧

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/586102.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存