I'm using Ubuntu Server Edition 11.10 and I have two extremely CPU intensive programs running on the same core. Neither of these processes were programmed for multi-core processing. Is there a way I can tell process A to run on Core 1 and process B to run on Core 2?
Ubuntu – How to assign different CPU cores to different processes
cpumulti-coreserver
Related Solutions
For the time being, I do not have a clear answer for this, however it is obvious that the linux Kernel is using some energy saving mechanisms.
However, doing some quick research around, I quickly realised that the most recent Linux kernels make use of a feature called ACPI which is an acronym for Advanced Configuration and Power Interface.
What the ACPI is doing:
the Advanced Configuration and Power Interface (ACPI) specification provides an open standard for device configuration and power management by the operating system.
via Wikipedia.
Basically the ACPI allows for control of different CPU states, to allow for better power management.
Different ACPI CPU-states:
CPU C-States (power management)
Basically, there is probably nothing that you have to worry about concerning the CPU "C states". These are automatically controlled by the kernel+ACPI system taking into consideration current system load. (CAVEAT: check out the note about AMD Athlon and Duron processors below). The ACPI code in the newer (2.6+) kernels automatically puts your CPU to sleep when there is idle time (note: this does not change the CPU frequency. That is controlled by "P states" - see below).
The only thing to realize is that your system is completely "conscious" when the CPU is momentarily halted - you won't notice much of a difference. However, the power savings can be considerable. Just think of it as having your CPU taking thousands of "micro-naps" whenever it is idle.
CPU-T States (throttling)
These are very much like "C states" (the same HLT instruction is used), however the difference is that throttling is "forced by you" (like every 4th cycle is forced to be a sleep cycle, as opposed to the "C states" above which are automatically determined by the system load). Note that the frequency has NOT been changed... see the "P states" below.
CPU-P States (performance)
Many processors these days (especially laptops) can have the clock frequency actually slowed "on the fly". This adds up to huge power savings. Intel calls this "SpeedStep" and AMD calls it "Cool'n'Quiet" or "PowerNow". More generically these states are called "P states". You will almost certainly have to go into the BIOS and enable this feature for your CPU FIRST!
** Some consumption benchmarks:**
What are the power savings from the above CPU states? The following data is extracted from the AMD website. Consider an AMD 64 3400+/2200MHz with 1 MB of L2 cache. By the way, while I'm here, let me complain about the AMD naming convention. The number 3400+ doesn't mean jack squat. This is just AMD's way of saying that this processor "looks like" an Intel Pentium-4 running at 3400MHz. I guess this is their way of not losing marketshare. Here are the P and T state power consumption values (the C state is the same HLT instruction as the T state):
- Performance State 0 (Fully Active) (2200MHz): 89 Watts
- Performance State 1 (2000MHz): 70 Watts
- Performance State 2 (800MHz): 35 Watts
- Throttled (HLT instruction): 2.2 Watts
Some references for further reading
- Red Hat power management guide ( I know you asked about Ubuntu, but this is still a good read)
- http://www.spencerstirling.com/computergeek/powersaving.html
- This article talks about APM mostly (an older version of ACPI) but it makes a reference to ACPI too.
- Very technical information can be found here.
- The PowerTop software, which seems to be cool.
- The Gentoo Power management guide. Still a good read.
- An introductory Linux Journal Article.
- And the Wikipedia article.
EDITS
[EDIT #1]: Googling around, I found some other posts in some forums too (OpenSuse forum seems to be relevant to what you seek) and found out that this is not that much of an issue for Linux as it is for windows and especially in gaming. I also dug up some information in two mails (first one and second one [follow-up]) in the RedHat mailing lists that seems to be related. I am currently researching the information in it.
[EDIT #2]: I have researched the issue a bit, and I am getting more and more certain that there is not a core parking mechanism in Linux, unless there is one the ACPI that I am unaware of. Some interesting findings are some pieces of software that allow for direct manipulation of the cpu and the processes run on it, like cpuset, numactl and last but not least, CPUfreq. Will continue with my research.
Best Answer
The accepted answer may be good advice, but it certainly isn't an answer to your question. Your question doesn't indicate to me that you aren't qualified to hear the answer either, in fact it sounds like a good example of a situation in which you'd want to specifically indicate which processors should do what.
Getting to the point, what you want are CPU Sets. They are supported in 11.10 of Ubuntu, since it uses a recent enough Linux Kernel. I believe Linux 2.6 is required.
You can read the man page for cpuset here: http://www.kernel.org/doc/man-pages/online/pages/man7/cpuset.7.html
Here is another page for general reading: http://www.bullopensource.org/cpuset/
Linux may be "great" at deciding how to allocate CPU time, but it isn't perfect.