Re: Processor P-states and power management
Posted: Fri Jan 06, 2012 8:12 pm
Hi,
For thermal management (rather than thermal protection), I'd want a scheduler that is able to shift load to cooler CPUs as part of it's load balancing, fan speed control and P-state control. I wouldn't want an OS where a CPUs unexpectedly drop from 100% to 12.5% when you're running a high priority or real-time thread.
Load is load. The CPU doesn't know the difference between "load that is a computer game" and "load that is a complex scientific calculation" and "load that is a compiler". Desktop computers are typically large enough to have adequate cooling and can typically handle high load for extended periods of time without over-heating; and they rarely run from battery (e.g. a UPS). On the other hand, laptops often don't have adequate cooling (due to size/space restrictions) and often do run from battery.
When you said "I don't think I will bother with throttling at all, as this is typically most useful for games on desktop computers, and that is not my "thing"." did you really mean "I don't think I will bother with thermal throttling at all, as this is typically most useful for scientific calculations and compiling on laptops, and that is not my "thing"."?
What exactly is your "thing"? Are you deliberately trying to write an OS that is only useful for situations where the ambient temperature is controlled (e.g. air-conditioned server rooms), which happens to be crap for things like ATMs that are often installed in exterior walls (where around here, the ambient temperature can reach 45 degrees Celsius in the afternoon in summer)?
My only objective was to get you to think about how P-states could be used properly (including things like acoustic/noise management and thermal management), so that you're at least aware of ways to improve your "only half a solution" solution.
Maybe something like:
NOTICE: this example pseudo-code for an incomplete solution is only an example, is only psuedo-code, and is only an incomplete solution.
For any "fuzzy logic" code, just change the comments to convert it into "non-fuzzy logic" code.
Cheers,
Brendan
Most (Intel) CPUs will suddenly drop down to about 12.5% or 25% of their performance when the CPU gets hot, and stop completely for catastrophic over-temperature. Firmware only sets a few settings during boot (shouldn't be hard to find the relevant MSRs in Intel's manual), and everything else is done automatically by the CPU (with no SMM involved). These things are not power management - they're thermal protection to (try to) make sure the CPU doesn't melt.rdos wrote:That's correct. I'm not going to implement temperature control right now, and especially not with p-states. The BIOS already sets up the cores in P0, and SMM handles catastrophic overtemperatures (along with some processors as well), so what I want to do is to put cores at suitable power-consumption states that are lower power than P0.Brendan wrote:You mean that you aren't going to think about using P-states to control CPU temperature at the moment, and you're going to implement something that breaks as soon as you do implement CPU temperature management properly?
For thermal management (rather than thermal protection), I'd want a scheduler that is able to shift load to cooler CPUs as part of it's load balancing, fan speed control and P-state control. I wouldn't want an OS where a CPUs unexpectedly drop from 100% to 12.5% when you're running a high priority or real-time thread.
Um? "Throttling" is using any P-state (except P0) for any reason; where the reason might be to help manage temperature and/or acoustics (e.g. fan noise), or to help reduce power consumption (e.g. increase battery life).rdos wrote:Additionally, I'll implement the functions to start/stop cores depending on load. I don't think I will bother with throttling at all, as this is typically most useful for games on desktop computers, and that is not my "thing".
Load is load. The CPU doesn't know the difference between "load that is a computer game" and "load that is a complex scientific calculation" and "load that is a compiler". Desktop computers are typically large enough to have adequate cooling and can typically handle high load for extended periods of time without over-heating; and they rarely run from battery (e.g. a UPS). On the other hand, laptops often don't have adequate cooling (due to size/space restrictions) and often do run from battery.
When you said "I don't think I will bother with throttling at all, as this is typically most useful for games on desktop computers, and that is not my "thing"." did you really mean "I don't think I will bother with thermal throttling at all, as this is typically most useful for scientific calculations and compiling on laptops, and that is not my "thing"."?
What exactly is your "thing"? Are you deliberately trying to write an OS that is only useful for situations where the ambient temperature is controlled (e.g. air-conditioned server rooms), which happens to be crap for things like ATMs that are often installed in exterior walls (where around here, the ambient temperature can reach 45 degrees Celsius in the afternoon in summer)?
As soon as you start looking at thermal throttling, you start getting feedback loops.rdos wrote:So if I decide to change my mind, and build-in throttling and temperature management, that is perfectly possible to do on top of the p-state interface. That is basically only a sub-mode of P0 state.
I'm sorry to hear that my rough example wasn't exactly what you wanted. I will refund all of the Research and Development money you've paid me as soon as I can.rdos wrote:I don't find that satisfactory. You should be able to get from 10% to 100% in 100ms, worse case 250ms, otherwise it is too slow. The other direction could take seconds, that's no problem, but decreasing p-state should be fast.Brendan wrote:The time that P-state changes take depends on which CPU. For the rough formula I used as an example in my last post, you'd be running at 50% within 1 second, at 75% within 2 seconds and at 87.5% within 3 seconds. The main flaw in my example is that you'd never actually reach 100% (but you'd round to the nearest supported P-state, so that doesn't matter much).
My only objective was to get you to think about how P-states could be used properly (including things like acoustic/noise management and thermal management), so that you're at least aware of ways to improve your "only half a solution" solution.
I wouldn't - I'd design something better, because I wouldn't limit my design to a small subset of available operators.rdos wrote:I've used fuzzy logic before, and it is efficient for certain types of problems that are hard to describe with determinstic rules. In this case, you want sudden increases in load to affect p-states fast, while also keeping the system at optimal load (around 50%). That is a problem that isn't easy to formulate with algebra.Brendan wrote:Of course - nobody would be silly enough to use boring old algebra with variables that range from 0 to 1 when there's a way to ignore most of the common operators and use the power of hype instead....
Example of rules:
1. If load is very high, quickly go to P0
2. If load is high, decrease p-state one mark
3. If load is intermediate, your system is fine, and you do nothing
4. If load is low, increase p-state one mark
Conditions: (just a preliminary example)
A. Very high is a slope from 75% to 90%, and then 1.0
B. High has a slope from 50% to 65%, is 1.0 from 65% to 80% and then has a slope to 90% where it is 0.0
C. Intermediate has a slope from 25% to 40%, is 1.0 from 40% to 60%, and then has a slope to 75% where it is 0.0
D. Low is 1.0 up to 25%, then has a slope to 40% where it is 0.0
How would you formulate this with algerbra?
Maybe something like:
Code: Select all
CPU_load_rating = high_priority_load * 0.7 + medium_priority_load * 0.3;
if( system_is_on_battery) {
power_multiplier = performance_or_efficiency_user_preference_for_battery;
} else {
power_multiplier = performance_or_efficiency_user_preference_for_mains_power;
}
desired_CPU_speed = CPU_load_rating * power_multiplier;
if(CPU_speed < desired_CPU_speed) {
CPU_speed = desired_CPU_speed * 0.9 + CPU_speed * 0.1; // Fast speed up
} else {
CPU_speed = desired_CPU_speed * 0.4 + CPU_speed * 0.6; // Slow speed down
}
Pstate = find_Pstate( CPU_speed ); // Search for the closest available P-state for the CPU speed,
// based on information for the specific CPU we're running on
set_Pstate(Pstate);
}
For any "fuzzy logic" code, just change the comments to convert it into "non-fuzzy logic" code.
Cheers,
Brendan