2

I understand from this question that Ubuntu is now using "Intel P-State", and that as a result, there are only two governor options: performance, and powersave.

But is it possible to automatically switch to powersave when on battery, and performance when a charger is connected? I'm surprised that this functionality isn't already implemented by default.

7
  • Actually there is no need to set to performance, Intel powersave is very intelligent. But it is possible. – Pilot6 Feb 9 '17 at 22:08
  • Ah, so under load, powersave defaults to a low frequency, but like 'ondemand', automatically increases the frequency? In that case, does that mean that there is no way to actually restrict the CPU? (and is that a good thing?) I'm wondering if it'd be better to force tasks to take longer, allowing longer battery as well, which is useful when reading while background processes may cause frequency spikes. – user8437812 Feb 9 '17 at 22:09
  • 2
    Do not mix up the old powersave and pstate powersave. The Intel powersave is better than ondemand in performance. That is why old states have been dropped. – Pilot6 Feb 9 '17 at 22:10
  • Energy consumption with modern processors is a difficult subject. It is not obvious if allowing a task to run faster, and thus allowing the CPU to go into a deep idle state sooner saves energy compared to having the task run slower. The subject is often referred to as "race to idle". The answer is processor and workflow dependent. I have an older Intel i7, which tends to favor slower CPU speeds for maximum energy savings. However some newer i7s tend to favor faster CPU speeds and more time in deep idle for maximum energy savings. Turbo frequencies tend to consume more power. – Doug Smythies Feb 10 '17 at 0:15
  • @DougSmythies, It does actually seem that my computer is consuming significantly more power than before (even on new batteries), so I should probably try measuring power draw. Perhaps current draw over 1 minute, with a task that takes 20 seconds with turbo and, perhaps, 40 seconds without turbo. Are there any other benefits of using P-State? – user8437812 Feb 10 '17 at 8:31
2

You can use acpid to manage acpi events such as connecting to AC adapter. /etc/acpi/hadler.sh can be configured to change cpu governor on acpi events.

#/etc/acpi/handler.sh

ac_adapter)
    case "$2" in
        AC*)
            case "$4" in
                00000000)
                    echo "powersave" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor    
                ;;
                00000001)
                    echo "performance" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
                ;;
            esac
        ;;
        *) logger "ACPI action undefined: $2" ;;
    esac
;;

If you use tlp, you can set

CPU_SCALING_GOVERNOR_ON_AC=performance

on /etc/default/tlp to do the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.