Forthcoming p4-clockmod changes.

In 2.6.29, the p4-clockmod cpufreq driver has been changed so that it no longer exports a cpufreq interface to sysfs.
This will no doubt have some people complaining that they can no longer change their CPU frequency.

The thing is, they never could.

From a recent posting to the cpufreq list:

I have a laptop (ASUS W7J) with an Intel Core2 T7200 2GHz.

When I use the p4-clockmod, I get:

available frequency steps: 250 MHz, 500 MHz, 750 MHz, 1.00 GHz, 1.25 GHz, 1.50 GHz, 1.75 GHz, 2.00 GHz

For every one of those ‘frequency’ options, the CPU is actually running at 2GHz. It never changes speed. Not at all.
The p4-clockmod driver abuses the cpufreq interface to expose a clock modulation feature that has been in processors for a long time. (Even the earlier pentiums had a variant of it). The driver modulates the clock applied to the processor so that instead of every clock cycle meaning the processor gets do some work, only a percentage of the clocks make the CPU do real work. The remainder of the time, the processor just sits there.

So the 1.00GHz ‘frequency’ is actually “run at 2GHz, but only do work 50% of the time”.

On the surface, this sounds like a good idea. The other 50%, the CPU is idle, so you’re saving power, right?
Not so much. In fact, you could be burning more power. The reason for this is that when the processor is sitting there doing nothing, it isn’t lower frequency, and more importantly, it very likely isn’t entering C states. So you’re burning the same amount of power, but now you’re only doing work for 50% of the time. As a result of this, your workload takes twice as long to complete.

If it isn’t saving any power, what is the point of this at all ?
A clue is revealed by reading the Intel programmers guide for this feature; it’s closely tied to the processors thermal monitoring feature. The idea of this feature is that when the CPU overheats, it can ‘back off’ a little, to prevent overheating. The temperature of a processor isn’t constant. When running flat out, it will generate more heat. So by modulating the clock, the maximum amount of heat possible to generate decreases.

The changes merged into the 2.6.29rc kernel remove the user-visible interface, and replace it with direct calls from the ACPI code that gets triggered on thermal events. It’s all entirely automatic now.

17 thoughts on “Forthcoming p4-clockmod changes.”

  1. I actually had a use for this feature. Years ago I was living in a one-room apartment with my Dell Latitude C640 with a 2.0 GHz P4 Mobile.
    I was at the time running gentoo which meant a lot of compiling. A P4 mobile processor generates a lot of heat and the laptop had a rather noisy fan.
    Thus I activated the clockmod and ran it much slower which prevented the fan from entering its high noise mode.

    1. This is exactly the scenario that the new code is designed for. ACPI will get a thermal event when it gets too hot, and the modulation will kick in. When it cools off, it will stop modulating again. Think of it as a combination of p4-clockmod and ondemand (which never worked well together previously, because the switching latency is so high)

  2. davej,

    Does this apply to all intel procs? Your example shows a Core 2 Duo – a processor I have. What is powertop good for then? Or does this actually only apply to p4 processors? (and anyone using that p4-clockmod that doesn’t really need to)

    1. The core2 duo should really be using acpi-cpufreq.

      There are some cases where BIOSes have been screwed up, and we’ve had to nag the vendor to get an update out, or some cases, we’ve had to fix a bug in Linux’s ACPI interpretor.

  3. Dave,

    With all due respect, I think you are completely missing the advantage of p4-clockmod. Yes, over the long term, it may take more energy to perform a task, but per ErikAndren’s comments and datasheets, it really does reduce the thermal load and thus, the cooling requirements that SOME people may want. That is, by running at a lower clock rate, the user’s fan may not have to run in the loud high-speed mode.

    Waiting for a thermal “overheat” event is not what some people want to wait for.

    This is a feature that should not be taken away. Freedom to do what you may think is stupid should not be limited.

    It appears you have some other motive here, and if so, I wish you would just state it, because you seem to be contradicting yourself.

  4. OK, maybe I’m ignorant. So how does the user manipulate ACPI to enable the same end-result?

  5. How about this case, I used it frequently in the past on my celeron M laptop.

    3d games tend to take 100% cpu to do non-critical processing which is a battery sucker on laptops. It’s nice to be able to throttle down the duty cycle of the cpu in this case for prolonged use during battery discharge.

    1. Exactly the same answer. If a thermal event occurs, it will automatically adjust for you. Also, re-read the part where I mention that you’re not saving power. The effect on battery life from throttling is negligible.

  6. you sure do save power… extra power is spent every time a flip-flop or other logic changes state. This happens less often when there’s less work being done. A 3d game tends to do as much work as it can to provide the best user experience, but it’s really not necessary for it to take 100% of the cpu. They’re just programmed to do so.

    Now, I guess the question is, with this change we users lose flexibility, yes? how do you define a thermal event? Can we users define a thermal event through the acpi interface?

    Could I write somewhere in a config file… if the temp gets above X, then throttle down to 25%?

    1. logic state changes aren’t even on the radar when it comes to power saving. The only way to get noticable results is by either reducing the amount of current going to those gates (through frequency adjustment), or by switching a power domain off completely. Clock modulation does neither of these.

      A thermal event is defined by the platform in ACPI. See /proc/acpi/thermal_zone/*/* for details.

  7. I guess what you don’t understand is, in the case of a 3d game, the workload depends only on how long you’re playing, and it will use all the resources it can ALL the time.

    It doesn’t stop processing sooner at a faster cpu rate like other workloads such as compiling, etc.

  8. nah, man. If it’s getting hotter at a higher rate, that means it’s spending more power.

  9. the above statement is a consequence of thermodynamics and energy balance… all the power gets converted to heat. More heat=more watts used.

  10. Where do you that that ‘more heat’ is coming from? Whilst the CPU is being throttled it’s being prevented from entering lower C states. So you’re effectively disabling runtime power management.

    C states are used even on non idle systems, it’s why there are multiple of them.

  11. I don’t know what else to say except to give you a data point. If my celeron M is using 100% cpu usage to do a task and I let it run at 1.6GHz, it runs hotter than doing the same task at 100% cpu usage at 800Mhz throttled down with p4_clockmod. The battery lasts about 20% longer.

    More heat= more power/minute being drained from the battery, means less battery life.

    However, I don’t even care, as I sold it for a core 2 duo laptop recently that has c-states and can use cpufreqd. I’m just arguing b/c it could affect some people who rely on p4_clockmod’s function like I did.

    Celeron M does not have c-states or speedstep, unlike pentium M, which can lower its own voltage. So for that processor, p4_clockmod was the best you could do to achieve marginal power savings during a scenario like what I describe.

Comments are closed.