# % sysctl dev.cpu.{0,1}.cx_usage gives 100% all the time while % top gives over 99% idle



## bxbzq (May 22, 2021)

Hi there,

My laptop is thinkpad T400, FreeBSD 13.0 release upgraded from 12.2, default kernel.
Question as titled.
Following the instructions on this forum and other resources, I've tried to tweak config files to lower the power consumption. In /etc/rc.conf, these are added:

```
powerd_enable="YES"
powerd_flags="-a hiadaptive -b adaptive"
performance_cx_lowest="Cmax"
economy_cx_lowest="Cmax"
kld_list="acpi_ibm"
```

In /boot/loader.conf, these are added:

```
hw.pci.do_power_nodrive="3"
hint.p4tcc.0.disabled="1"
hint.acpi_throttle.0.disabled="1"
compat.linuxkpi.fastboot="1"
compat.linuxkpi.semaphores="1"
compat.linuxkpi.enable_rc6="7"
compat.linuxkpi.enable_dc="2"
compat.linuxkpi.enable_fbc="1"
```


```
% sysctl dev.cpu.{0,1}.cx_usage
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 1186us
dev.cpu.1.cx_usage: 100.00% 0.00% 0.00% last 887us
```

By running `% top`, I see 99.x% idle.

It doesn't look right to me. What am I doing wrong or missing?


----------



## SirDice (May 31, 2021)

bxbzq said:


> By running `% top`, I see 99.x% idle.


It has nothing to with that. It just means it's been 100% of the time on a certain state.


----------



## Alain De Vos (May 31, 2021)

The 100% you see is the C1 power saving state for a cpu. (the core clock is turned off)
To list the cpu states of all the cpu's:

```
sysctl -a | grep -i cx | sort
```


----------



## bxbzq (Jun 2, 2021)

I guess the real question is, can I relax because from % top the CPU idle time is already 99%?


----------



## bxbzq (Jun 2, 2021)

Here is the output from a T430 laptop:

```
% sysctl dev.cpu.{0,1,2,3}.cx_usage
dev.cpu.0.cx_usage: 15.02% 84.97% last 1906us
dev.cpu.1.cx_usage: 11.53% 88.46% last 346us
dev.cpu.2.cx_usage: 10.97% 89.02% last 804us
dev.cpu.3.cx_usage: 10.61% 89.38% last 1240us
```
How to explain the difference from the output on T400?


----------



## smithi (May 3, 2022)

bxbzq said:


> Here is the output from a T430 laptop:
> 
> ```
> % sysctl dev.cpu.{0,1,2,3}.cx_usage
> ...


What's the value of 
	
	



```
# sysctl hw.acpi.cpu.cx_lowest
```
 if not C8?

My T430s was stuck on C1 at 100% until I set that, or at least less than C1.

Now I get C2 on AC and C3 on battery, nearer 100% on the lowest.

Power use at idle on battery consequently dropped from ~16.5 to ~13.5W


----------



## bxbzq (May 7, 2022)

smithi said:


> What's the value of
> 
> 
> 
> ...



On T400

```
% sysctl -a | grep -i cx | sort
dev.cpu.0.cx_lowest: C8
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc/bma
dev.cpu.0.cx_supported: C1/1/1 C2/2/1 C3/3/57
dev.cpu.0.cx_usage_counters: 81246 0 0
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 1758us
dev.cpu.1.cx_lowest: C8
dev.cpu.1.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc/bma
dev.cpu.1.cx_supported: C1/1/1 C2/2/1 C3/3/57
dev.cpu.1.cx_usage_counters: 95039 0 0
dev.cpu.1.cx_usage: 100.00% 0.00% 0.00% last 79us
dev.hdaa.0.%desc: Conexant CX20561 (Hermosa) Audio Function Group
dev.hdacc.0.%desc: Conexant CX20561 (Hermosa) HDA CODEC
dev.pcm.0.%desc: Conexant CX20561 (Hermosa) (Analog 2.0+HP/2.0)
dev.pcm.1.%desc: Conexant CX20561 (Hermosa) (Internal Analog Mic)
hw.acpi.cpu.cx_lowest: C8
hw.acpi.thermal.tz0._ACx: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
hw.acpi.thermal.tz1._ACx: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
```

On T430

```
% sysctl -a | grep -i cx | sort
dev.cpu.0.cx_lowest: C8
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc
dev.cpu.0.cx_supported: C1/1/1 C2/2/104
dev.cpu.0.cx_usage_counters: 213507 874285
dev.cpu.0.cx_usage: 19.62% 80.37% last 182us
dev.cpu.1.cx_lowest: C8
dev.cpu.1.cx_method: C1/mwait/hwc C2/mwait/hwc
dev.cpu.1.cx_supported: C1/1/1 C2/2/104
dev.cpu.1.cx_usage_counters: 118925 670942
dev.cpu.1.cx_usage: 15.05% 84.94% last 943us
dev.cpu.2.cx_lowest: C8
dev.cpu.2.cx_method: C1/mwait/hwc C2/mwait/hwc
dev.cpu.2.cx_supported: C1/1/1 C2/2/104
dev.cpu.2.cx_usage_counters: 202596 1065609
dev.cpu.2.cx_usage: 15.97% 84.02% last 15us
dev.cpu.3.cx_lowest: C8
dev.cpu.3.cx_method: C1/mwait/hwc C2/mwait/hwc
dev.cpu.3.cx_supported: C1/1/1 C2/2/104
dev.cpu.3.cx_usage_counters: 110302 523490
dev.cpu.3.cx_usage: 17.40% 82.59% last 54us
hw.acpi.cpu.cx_lowest: C8
hw.acpi.thermal.tz0._ACx: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
```


----------



## smithi (May 8, 2022)

Sorry, no idea why the T400 isn't using its higher C-states, particularly while not at all busy.

I noticed this in its `/boot/loader.conf:
hw.pci.do_power_nodrive="3"`

a) it belongs in sysctl.conf not loader.conf
b) "nodriver" not "nodrive"
c) sure you wanted it?

Check `sysctl -d hw.pci.do_power_nodriver`

Otherwise I'm clueless.


----------



## bxbzq (May 9, 2022)

smithi said:


> Sorry, no idea why the T400 isn't using its higher C-states, particularly while not at all busy.
> 
> I noticed this in its `/boot/loader.conf:
> hw.pci.do_power_nodrive="3"`
> ...



Don't remember from where I copied that line in /boot/loader.conf. And I don't know exactly what it does, only that it was recommended as one of the measures to save power. Anyway, if it is in wrong place and wrong in syntax, it has no effect.
One thing though, on T400 the battery was  totally dead, so I got rid of it, while on T430 the battery can last 10 minutes or so. Does it make a difference in terms of CPU usage?


----------



## smithi (May 9, 2022)

bxbzq said:


> One thing though, on T400 the battery was  totally dead, so I got rid of it, while on T430 the battery can last 10 minutes or so. Does it make a difference in terms of CPU usage?


As mentioned above, my T430s uses C1 and (>97%) C2 states on AC power, but on battery C1, C2 and (almost 100%) C3 states, at 99%+ idle, no X, for upto 2.5 hours.

I assume the AC/battery choice is in the AML code for the machine.

Are you running the latest BIOS on your T400?  I had an X200 of similar vintage that a BIOS upgrade helped - I forget how.

I'd replace dead|dying batteries, at least to survive short power outages.  OTOH if never running on battery then power use is no issue, unless overheating.

Good luck.


----------

