Multicore laptops and turning off CPU cores

Richard Hughes hughsient at gmail.com
Thu Aug 17 10:05:45 PDT 2006


Now we are playing with cpu frequency scaling, it would make sense in my
opinion to expose a OS neutral API to offline and online CPU's.

I think it was Daniel Drake (post beers) who showed me how to do this at
GUADEC by just echoing a value somewhere in sysfs for his new shiny
dual-core laptop.
He also showed me this *dramatically* reduced the power usage of the
laptop.

I think it went something like this:
echo 0 > /sys/devices/system/cpu/cpuX/online

This is Linux specific, but we can add Solaris and *BSD support easily.
Artem, Joe, what are the commands?

I'm guessing that a dual core laptop appears as two processor objects in
HAL, in which case it makes it trivial to add methods:

void org.freedesktop.Hal.Device.ProcessorHotplug.SetOnline(bool)
bool org.freedesktop.Hal.Device.ProcessorHotplug.GetOnline(void)

This scheme wouldn't be possible if the processor object disappears from
the HAL device tree which I don't think it does. Daniel can you confirm
please?

Note: we can see if a CPU is "offlineable" by the presence of the
file /sys/devices/system/cpu/cpuX/online - if it does not exist then you
can't offline it, and we shouldn't add the methods or the capability
'processor_hotplug'.

Better interface, capability and method names welcome. :-)

Now, I'm imagining this being used on dual core laptops, but the
interface shouldn't rule out other machines, such as insanely big SMP
servers with x CPU's.

Sound sane / insane? Imagine a checkbox in a typical policy agent
preferences program (heh):

When on battery power:

[x] Turn off additional processors

Now, that would ROCK.

Opinions and comments please.

Richard.





More information about the hal mailing list