玟茵开源社区知识库

如果您有自己的想法或者金点子,请提交给我们或直接参与项目,在此欢迎各位,您的反馈是我们持续前进的动力。
  1. 首页
  2. 设置文档
  3. 正文

Linux热插拔CPU核心

2022年10月30日 280点热度 0人点赞 0条评论

文章目录[隐藏]

  • 显示系统中共有多少个CPU核心:
    • How do I logically turn on (online) cpu#6 ?
    • How do I verify cpu is online and offline?

显示系统中共有多少个CPU核心:

输入以下命令:

# cd /sys/devices/system/cpu
# ls -l

示例:

total 0
drwxr-xr-x 4 root root    0 Apr  2 12:03 cpu0
drwxr-xr-x 4 root root    0 Feb 15 07:06 cpu1
drwxr-xr-x 4 root root    0 Feb 15 07:06 cpu2
drwxr-xr-x 4 root root    0 Feb 15 07:06 cpu3
drwxr-xr-x 4 root root    0 Feb 15 07:06 cpu4
drwxr-xr-x 4 root root    0 Feb 15 07:06 cpu5
drwxr-xr-x 4 root root    0 Feb 15 07:06 cpu6
drwxr-xr-x 4 root root    0 Feb 15 07:06 cpu7
-rw-r--r-- 1 root root 4096 Apr  2 12:03 sched_mc_power_savings

共有8个CPU逻辑内核。转换为人类可读格式:

# lscpu

示例:

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                32
On-line CPU(s) list:   0-31
Thread(s) per core:    2
Core(s) per socket:    8
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 45
Stepping:              7
CPU MHz:               2000.209
BogoMIPS:              4001.65
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              20480K
NUMA node0 CPU(s):     0-7,16-23
NUMA node1 CPU(s):     8-15,24-31

Under each directory you would find an “online” file which is the control file to logically online/offline a processor.

(查看哪些核心是在线状态:)

关闭某个核心,输入下列命令:

# echo 0 > /sys/devices/system/cpu/cpu6/online
# grep "processor" /proc/cpuinfo

How do I logically turn on (online) cpu#6 ?

Type the following command:

# echo 1 > /sys/devices/system/cpu/cpu6/online
# grep "processor" /proc/cpuinfo

Once done, you can can actually remove CPU if your BIOS and server vendor supports such operation.

How do I verify cpu is online and offline?

Type the following cat command to see a list of cpus which are online:

# cat /sys/devices/system/cpu/online

To see a list of all offline cpus, run:

# cat /sys/devices/system/cpu/offline
本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可
标签: CPU Linux
最后更新:2022年10月30日

WenYinOS

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

COPYLEFT © 2023 玟茵开源社区知识库. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang