Onlining and Offlining CPU's in Linux
Dynamically enabling and disabling CPU’s in Linux is not as convenient as it is in Solaris with psradm command. I was trying the following on VMware vSphere 5.0 with guest running RedHat 5.9.
Since this was a VM I had to make sure the VM had CPU hotplugging functionality enabled. I did this in VM settings window, clicking on Options tab and making sure Memory/CPU Hotplug was enabled.
On the VM already running with the above option enabled, in VM’s settings window I increased Number of virtual sockets. In my case I upped it from 1 to 2. This caused creation of /sys/devices/system/cpu/cpu1 directory. So at this point the system saw the new CPU but did not use it quite yet.
[root@vm-prd-001 ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 46
model name : Intel(R) Xeon(R) CPU E7520 @ 1.87GHz
stepping : 6
cpu MHz : 1862.000
cache size : 18432 KB
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
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 syscall nx rdtscp lm constant_tsc up nonstop_tsc pni ssse3 cx16 sse4_1 sse4_2 popcnt lahf_lm
bogomips : 3724.00
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: [8]
I still had to online the new CPU:
[root@vm-prd-001 ~]# echo 1 > /sys/devices/system/cpu/cpu1/online
Cannot setup NMI watchdog on CPU 1
[root@vm-prd-001 ~]#
As you can see it threw and error message. More on that in a bit. First I checked if CPU was online:
[root@vm-prd-001 ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 46
model name : Intel(R) Xeon(R) CPU E7520 @ 1.87GHz
stepping : 6
cpu MHz : 1862.000
cache size : 18432 KB
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
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 syscall nx rdtscp lm constant_tsc nonstop_tsc pni ssse3 cx16 sse4_1 sse4_2 popcnt lahf_lm
bogomips : 3724.00
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: [8]
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 46
model name : Intel(R) Xeon(R) CPU E7520 @ 1.87GHz
stepping : 6
cpu MHz : 1862.000
cache size : 18432 KB
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
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 syscall nx rdtscp lm constant_tsc nonstop_tsc pni ssse3 cx16 sse4_1 sse4_2 popcnt lahf_lm
bogomips : 3724.00
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: [8]
That looked good. I offlined the CPU in a similar way:
[root@vm-prd-001 ~]# echo 0 > /sys/devices/system/cpu/cpu1/online
[root@vm-prd-001 ~]#
Now back to that error message. It’s harmless. VMware has it described here. Essentially you have to disable support for NMI in guest’s kernel by adding nmi_watchdog=0 to your grub.conf.