[内容] Linux CPU 详细信息的显示

内容一:显示 Linux CPU 详细信息
1.1 显示 Linux CPU 详细信息

# cat /proc/cpuinfo

或者:

# lscpu

1.2 /proc/cpuinfo 文件里或者 lscpu 命令里重要参数

1) processor,逻辑核心 ID
2) physical id,物理封装 CPU ID 也就是 CPU socket ID
3) core ID,物理核心 ID
4) cpu cores 物理封装 CPU 也就是 CPU socket 里的物理核心数量
5) siblings 物理封装 CPU 也就是 CPU socket 里的逻辑核心数量

内容二:显示 Linux CPU 详细信息的案例
2.1 显示 Linux CPU 详细信息

# cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 23
model		: 1
model name	: AMD Ryzen 7 1700 Eight-Core Processor
stepping	: 1
microcode	: 0x8001138
cpu MHz		: 1371.214
cache size	: 512 KB
physical id	: 0
siblings	: 16
core id		: 0
cpu cores	: 8
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca
bugs		: sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass
bogomips	: 5987.93
TLB size	: 2560 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 43 bits physical, 48 bits virtual
power management: ts ttp tm hwpstate eff_freq_ro [13] [14]

......
# cat /proc/cpuinfo | grep processor
processor	: 0
processor	: 1
processor	: 2
processor	: 3
processor	: 4
processor	: 5
processor	: 6
processor	: 7
processor	: 8
processor	: 9
processor	: 10
processor	: 11
processor	: 12
processor	: 13
processor	: 14
processor	: 15
# cat /proc/cpuinfo | grep 'physical id'
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
physical id	: 0
# cat /proc/cpuinfo | grep 'core id'
core id		: 0
core id		: 1
core id		: 2
core id		: 3
core id		: 4
core id		: 5
core id		: 6
core id		: 7
core id		: 0
core id		: 1
core id		: 2
core id		: 3
core id		: 4
core id		: 5
core id		: 6
core id		: 7
# cat /proc/cpuinfo | grep 'cpu cores'
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
cpu cores	: 8
# cat /proc/cpuinfo | grep 'siblings'
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16
siblings	: 16

2.2 理解显示的 CPU 详细信息

1) processor 的数字从 0 到 15,代表有 16 个逻辑核心
2) physical id 的数字都是 0,代表只有 1 个物理封装 CPU ID 也就是 CPU socket ID
3) core id 的数字从 0 到 7,代表有 8 个物理核心
4) cpu cores 的数字都是 8,代表每 1 个物理封装 CPU 也就是 CPU socket 里有 8 个物理核心
5) siblings 的数字都是 8,代表每 1 个物理封装 CPU 也就是 CPU socket 里有 16 个逻辑核心
6) 简单的理解:1 个 CPU,8 个物理核心,16 个逻辑核心

[排错] 解决 Linux 运行时报错 “watchdog: Bug: soft lockup – CPU……” (CPU 软锁)

报错代码:

watchdog: Bug: soft lockup - CPU......

分析:

当 CPU 的负载过高时,一个 CPU 在运行某一个进程时,在内核模式下超过 20 秒没有回应,则看门狗程序会将系统所有 CPU 软锁住,然后会让这些 CPU 显示各自正在运行的进程堆栈跟踪

缓解方法:

延长看门狗等待 CPU 内核模式下的回应时间

方法一:通过 /proc/sys/kernel/watchdog_thresh 文件提高看门狗软所 CPU 的时间

# echo 20 > /proc/sys/kernel/watchdog_thresh

(补充:这里以将看门狗的值提高到为 20 为例,也可以根据自己的需求提高更多,默认值为 10)

方法二:通过新建文件提高看门狗软所 CPU 的时间
2.1 通过新建文件提高看门狗软所 CPU 的时间

# echo "kernel.watchdog_thresh=20" > /etc/sysctl.d/99-watchdog_thresh.conf

(补充:这里以将看门狗的值提高到为 20 为例,也可以根据自己的需求提高更多,默认值为 10)

2.2 让新建文件立刻生效

# sysctl -p  /etc/sysctl.d/99-watchdog_thresh.conf

深究方法:

开启 Kdump,等此报错再次发生时分析 Kdump 在内核崩溃时搜集信息 vmcore

[命令] Linux 命令 hdparm (测试硬盘读取速度)

 # hdparm -Ttv /dev/sda

/dev/sda:
 multcount     = 128 (on)
 IO_support    =  1 (32-bit)
 readonly      =  0 (off)
 readahead     = 1024 (on)
 geometry      = 8354/255/63, sectors = 134217728, start = 0
 Timing cached reads:   7304 MB in  2.00 seconds = 3658.90 MB/sec
 Timing buffered disk reads: 612 MB in  3.01 seconds = 203.07 MB/sec

(补充:这里以测试 /dev/sda 硬盘的读取速度为例)

[内容] Linux 常见存储和存储类型介绍

内容一:常见的存储

1. DAS(直连存储),就是接在主板上的硬盘
2. NAS(网络附加存储),例如:NFS、Samba、FTP、HTTP,优点是管理简单,缺点是单点故障
3. SAN(网络块存储),例如:Iscsi
4. 分布时云存储,例如:Ceph、Swift

内容二:常见的存储类型

1. Block-based access(基于块存储的访问),对应的是块存储(block),例如:直接接在主板上的硬盘、Iscsi、Ceph
2. File-based access(基于文件系统的访问),对应的是文件系统存储(filesystem),例如:NFS、Samba、FTP、HTTP、Ceph
3. Object-based access(基于对象的访问),对应的是对象存储(object),例如:Ceph