Score:0

How to update possible C States

ug flag

I've been running ubuntu 20.04.4 LTS on an old motherboard with intel i5 3570k. This CPU has a limitted number of C States available and as such power consumption was mediocre. I have now updated to a new motherboard with i7 11700k installed and when using powertop to check how my ubuntu distribution does I noticed that available C States has decreased which probably means that there is more room for power saving. I checked ubuntu launched from usb drive and all the C States were available. This is how powertop sees the C States at the moment: enter image description here

It states that only C1, C2 and C3 states are available using ACPI. What do I need to do to start making use of all the other c states?

I was asked to provide the output of grep cpu:

/sys/devices/system/cpu/cpu0/cpuidle/state0/name:POLL
/sys/devices/system/cpu/cpu0/cpuidle/state1/name:C1_ACPI
/sys/devices/system/cpu/cpu0/cpuidle/state2/name:C2_ACPI
/sys/devices/system/cpu/cpu0/cpuidle/state3/name:C3_ACPI
in flag
Could you [edit] your question to include the output of `grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name`? This will list the available C-States for your CPU as per the installed kernel and the limitations imposed by the UEFI configuration. With this info, it may be possible to offer a solution.
Score:0
gn flag

On a per processor family basis, Intel decides if they want to override the default ACPI idle state structure used by linux kernels. This is done in the kernel source tree under drivers/idle/intel_idle.c. An example override for my Comet Lake processor:

doug@s19:~/temp-k-git/linux$ git diff
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 3273360f30f7..770660d777c4 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -1155,6 +1155,7 @@ static const struct x86_cpu_id intel_idle_ids[] __initconst = {
        X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L,          &idle_cpu_skl),
        X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE,            &idle_cpu_skl),
        X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X,           &idle_cpu_skx),
+       X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE,           &idle_cpu_skl),
        X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X,           &idle_cpu_icx),
        X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL,        &idle_cpu_knl),
        X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM,        &idle_cpu_knl),

By default the idle states are:

$ grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name
/sys/devices/system/cpu/cpu0/cpuidle/state0/name:POLL
/sys/devices/system/cpu/cpu0/cpuidle/state1/name:C1_ACPI
/sys/devices/system/cpu/cpu0/cpuidle/state2/name:C2_ACPI
/sys/devices/system/cpu/cpu0/cpuidle/state3/name:C3_ACPI

$ grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/desc
/sys/devices/system/cpu/cpu0/cpuidle/state0/desc:CPUIDLE CORE POLL IDLE
/sys/devices/system/cpu/cpu0/cpuidle/state1/desc:ACPI FFH MWAIT 0x0
/sys/devices/system/cpu/cpu0/cpuidle/state2/desc:ACPI FFH MWAIT 0x30
/sys/devices/system/cpu/cpu0/cpuidle/state3/desc:ACPI FFH MWAIT 0x60

Via the above override the idle states are:

$ grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name
/sys/devices/system/cpu/cpu0/cpuidle/state0/name:POLL
/sys/devices/system/cpu/cpu0/cpuidle/state1/name:C1
/sys/devices/system/cpu/cpu0/cpuidle/state2/name:C1E
/sys/devices/system/cpu/cpu0/cpuidle/state3/name:C3
/sys/devices/system/cpu/cpu0/cpuidle/state4/name:C6
/sys/devices/system/cpu/cpu0/cpuidle/state5/name:C7s
/sys/devices/system/cpu/cpu0/cpuidle/state6/name:C8
/sys/devices/system/cpu/cpu0/cpuidle/state7/name:C9
/sys/devices/system/cpu/cpu0/cpuidle/state8/name:C10

$ grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/desc
/sys/devices/system/cpu/cpu0/cpuidle/state0/desc:CPUIDLE CORE POLL IDLE
/sys/devices/system/cpu/cpu0/cpuidle/state1/desc:MWAIT 0x00
/sys/devices/system/cpu/cpu0/cpuidle/state2/desc:MWAIT 0x01
/sys/devices/system/cpu/cpu0/cpuidle/state3/desc:MWAIT 0x10
/sys/devices/system/cpu/cpu0/cpuidle/state4/desc:MWAIT 0x20
/sys/devices/system/cpu/cpu0/cpuidle/state5/desc:MWAIT 0x33
/sys/devices/system/cpu/cpu0/cpuidle/state6/desc:MWAIT 0x40
/sys/devices/system/cpu/cpu0/cpuidle/state7/desc:MWAIT 0x50
/sys/devices/system/cpu/cpu0/cpuidle/state8/desc:MWAIT 0x60

This statement:

I noticed that available C States has decreased which probably means that there is more room for power saving.

Is incorrect, there isn't room for power saving just in currently available states. Observe the deepest state is the same. You might achieve some power savings via selection of the idle governor as a function of your particular workflow requirements:

$ grep . /sys/devices/system/cpu/cpuidle/*
/sys/devices/system/cpu/cpuidle/available_governors:ladder menu teo
/sys/devices/system/cpu/cpuidle/current_driver:intel_idle
/sys/devices/system/cpu/cpuidle/current_governor:teo
/sys/devices/system/cpu/cpuidle/current_governor_ro:teo
/sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us:0
/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us:0
Maciej Musialek avatar
ug flag
If I understand correctly there is no point in correcting the cpu states that are available in default linux?
Doug Smythies avatar
gn flag
There is no point in changing them. "Correcting" is not the right term to use.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.