Pages

2011-11-06

Hotplug cpu

There's a way to make specified cpus online -- maxcpus=N as an initialization argument. The shortcoming is obvious that every time have to reboot.

We can change dynamically if the current kernel has CONFIG_HOTPLUG_CPU set. After that:
% ll /sys/devices/system/cpu/cpu1
total 0
 4498 drwxr-xr-x 5 root root    0 Nov  6 17:38 cache
10292 drwxr-xr-x 2 root root    0 Nov  6 16:29 cpufreq
10185 drwxr-xr-x 5 root root    0 Nov  6 17:38 cpuidle
  201 -r-------- 1 root root 4.0K Nov  6 17:38 crash_notes
  200 -rw-r--r-- 1 root root 4.0K Nov  6 17:38 online
 7337 drwxr-xr-x 2 root root    0 Nov  6 17:38 topology
$ su -c 'echo 0 > /sys/devices/system/cpu/cpu1/online'
to shutdown cpu1.

There must be at least one cpu, so that cpu0 has no online
% ll /sys/devices/system/cpu/cpu0
total 0
 4467 drwxr-xr-x 5 root root    0 Nov  6 17:43 cache
10276 drwxr-xr-x 2 root root    0 Nov  6 16:29 cpufreq
10140 drwxr-xr-x 5 root root    0 Nov  6 17:43 cpuidle
  198 -r-------- 1 root root 4.0K Nov  6 17:43 crash_notes
 7330 drwxr-xr-x 2 root root    0 Nov  6 17:43 topology

No comments:

Post a Comment