online, possible and disabled cpus

Srivatsa Bhat bhat.srivatsa at gmail.com
Tue Oct 23 05:00:40 EDT 2012


On Tue, Oct 23, 2012 at 2:12 PM, Robert P. J. Day <rpjday at crashcourse.ca> wrote:
> On Tue, 23 Oct 2012, Srivatsa Bhat wrote:
>
>> I don't think we should worry too much about this.. I can think of a
>> simple reason why one would want to iterate through all possible
>> CPUs.. : IIUC, this function prints, for each softirq, the number of
>> times it ran on a particular CPU. So if a CPU was online for a while
>> and then was taken offline, in order to print the softirq stats
>> properly (including how many times it ran on that CPU when it was
>> online), we will have to iterate through all possible CPUs.. That is
>> a simple and valid reason, IMHO.
>
>   that's the same reason i came up with as well, but it still seems
> somewhat lazy -- how hard would it be to have a bitmap that shows
> whether a possible CPU was *ever* active/online, and print
> accordingly?  but this inspired another thought.
>
>   a lot of this complexity is introduced if you configure your kernel
> with CONFIG_HOTPLUG_CPU, and there are a lot of references to that in
> the kernel source tree:
>
> $ grep -rw CONFIG_HOTPLUG_CPU * | wc -l
> 332
> $
>
> but how many people really need to have a CPU-hotpluggable kernel?
> it would seem that you could simplify things by just turning off that
> option.  i'm puzzled that the default x86 config files have that
> option turned on.
>
>   seriously, how many people out there are hotplugging CPUs?  i'm just
> curious.  and is there any obvious drawback to just unconfiguring that
> option?
>

Ah, that's the thing.. CPU hotplug does not always refer to "physically
pull out or plug in CPUs into the system". As you might have gathered
from reading the help text, it also refers to "soft" offline/online of CPUs.
As a result, CPU hotplug is used in several occasions.. (guess what,
you are also using it I bet ;)

Examples: Suspend/Resume, Hibernation, Boot-up (yes, SMP booting
is also done by invoking the CPU hotplug code), Shutdown etc.. use
CPU hotplug.

Also, an interesting by-product of offlining a CPU is that it makes the
CPU totally quiescent - it doesn't run tasks, doesn't handle interrupts
etc.. People tend to (ab)use this for power-management, in cases where
there are platform limitations to saving power by idling CPUs, or
sometimes as a big hammer approach instead of relying on the scheduler/
load-balancer to do it..

Regards,
Srivatsa S. Bhat



More information about the Kernelnewbies mailing list