CentOS 上查看与“配置”CPU 信息的注意事项
一、先明确 cpuinfo 的本质
二、正确查看与解读关键字段
cat /proc/cpuinfolscpudmidecode | grep -i cpu、getconf LONG_BIT(查看位数)grep -c ^processor /proc/cpuinfosort -u /proc/cpuinfo | grep "physical id" | wc -lgrep -q ht /proc/cpuinfo && echo "HT enabled" || echo "HT disabled"(亦可用 dmidecode -t processor | grep HTT)lscpu | grep "Core(s) per socket" | awk '{print $4}'lscpu | grep "Thread(s) per core" | awk '{print $4}'getconf LONG_BIT三、常见“配置/优化”与 cpuinfo 的关联要点
cpupower -c all frequency-info 或 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governorcpupower -c all frequency-set -g performance(或 powersave)grep ht /proc/cpuinfo 或 dmidecode -t processor | grep HTTnoht);更改后需重启,/proc/cpuinfo 的 siblings 与 flags 会相应变化。numactl --hardware、grep -i numa /var/log/dmesgnumactl --cpunodebind=0 --membind=0 <cmd>),以减少跨 NUMA 访问开销。cat /sys/kernel/mm/transparent_hugepage/enabled、cat /sys/kernel/mm/transparent_hugepage/defrag/proc/cpuinfo 无直接变化,但应用性能与调度行为会受影响。四、排错与一致性校验清单
lscpu、cpupower 是否安装)。lscpu/cpupower 缺失,使用包管理器安装(如 yum/dnf install util-linux 等对应包),避免因依赖缺失导致信息不完整。physical id 的呈现可能不直观或与物理机不一致;可结合 dmidecode、lscpu 与宿主机信息交叉验证。cat /proc/cpuinfo、lscpu、numactl --hardware 进行前后对比,确认 flags、siblings、cpu cores、NUMA 节点 等是否符合预期。