手动触发
lscpu | grep "Off-line"
echo 1 > /sys/devices/system/cpu/cpu9/online
OFF_CPUS=$(lscpu | grep "Off-line" | awk '{print $NF}' | tr ',-' ' ')
for i in $(seq $OFF_CPUS);do echo 1 > /sys/devices/system/cpu/cpu$i/online;done
自动触发
# vim /etc/udev/rules.d/99-cpu-hotplug.rules
ACTION=="add", SUBSYSTEM=="cpu", ATTR{online}=="0", ATTR{online}="1"
# 触发 ubuntu 18.04 无效
sudo udevadm control --reload
sudo udevadm trigger --subsystem-match=cpu
解决:
重启虚拟机后 热添加CPU则正常
查看生效
root@ubuntu:~# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Off-line CPU(s) list: 4