powerd and c states enable on Truenas, how?

tio

Contributor
Joined
Oct 30, 2013
Messages
119
Hi all

Need some help please. How do i enable powerd now and also how do i also enable the c states power saving? My cpu supports C3 according to the output but the documentation isn't clear from what i can see. Id also like to be able to throttle the cpu back when its idle to save every watt i can. I saw a post about doing a tunable for adaptive power but cant work out how to enable it.

Many thanks

the configuration database and will be reset on reboot.

root@truenas[~]# sysctl -a | grep cx_
hw.acpi.cpu.cx_lowest: C8
dev.cpu.15.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.15.cx_usage_counters: 60697 755735 41798968
dev.cpu.15.cx_usage: 0.14% 1.77% 98.08% last 83162us
dev.cpu.15.cx_lowest: C8
dev.cpu.15.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.14.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.14.cx_usage_counters: 56580 730214 41630144
dev.cpu.14.cx_usage: 0.13% 1.72% 98.14% last 25747us
dev.cpu.14.cx_lowest: C8
dev.cpu.14.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.13.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.13.cx_usage_counters: 65692 740520 40630147
dev.cpu.13.cx_usage: 0.15% 1.78% 98.05% last 46628us
dev.cpu.13.cx_lowest: C8
dev.cpu.13.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.12.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.12.cx_usage_counters: 54824 726562 40916963
dev.cpu.12.cx_usage: 0.13% 1.74% 98.12% last 29447us
dev.cpu.12.cx_lowest: C8
dev.cpu.12.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.11.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.11.cx_usage_counters: 163418 891401 40578063
dev.cpu.11.cx_usage: 0.39% 2.14% 97.46% last 88875us
dev.cpu.11.cx_lowest: C8
dev.cpu.11.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.10.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.10.cx_usage_counters: 528333 3238433 57794797
dev.cpu.10.cx_usage: 0.85% 5.26% 93.88% last 43147us
dev.cpu.10.cx_lowest: C8
dev.cpu.10.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.9.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.9.cx_usage_counters: 56787 735186 39765631
dev.cpu.9.cx_usage: 0.14% 1.81% 98.04% last 678us
dev.cpu.9.cx_lowest: C8
dev.cpu.9.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.8.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.8.cx_usage_counters: 60330 721968 38032598
dev.cpu.8.cx_usage: 0.15% 1.86% 97.98% last 30us
dev.cpu.8.cx_lowest: C8
dev.cpu.8.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.7.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.7.cx_usage_counters: 2482480 3462630 48805238
dev.cpu.7.cx_usage: 4.53% 6.32% 89.14% last 59us
dev.cpu.7.cx_lowest: C8
dev.cpu.7.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.6.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.6.cx_usage_counters: 51080 704700 40020068
dev.cpu.6.cx_usage: 0.12% 1.72% 98.14% last 432us
dev.cpu.6.cx_lowest: C8
dev.cpu.6.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.5.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.5.cx_usage_counters: 50452 700986 40766471
dev.cpu.5.cx_usage: 0.12% 1.68% 98.19% last 266us
dev.cpu.5.cx_lowest: C8
dev.cpu.5.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.4.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.4.cx_usage_counters: 48488 692795 39390406
dev.cpu.4.cx_usage: 0.12% 1.72% 98.15% last 7126us
dev.cpu.4.cx_lowest: C8
dev.cpu.4.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.3.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.3.cx_usage_counters: 49928 709424 39275800
dev.cpu.3.cx_usage: 0.12% 1.77% 98.10% last 9217us
dev.cpu.3.cx_lowest: C8
dev.cpu.3.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.2.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.2.cx_usage_counters: 54611 707313 47076283
dev.cpu.2.cx_usage: 0.11% 1.47% 98.40% last 237us
dev.cpu.2.cx_lowest: C8
dev.cpu.2.cx_supported: C1/1/1 C2/2/15 C3/2/41
dev.cpu.1.cx_method: C1/mwait/hwc C2/mwait/hwc/bma C3/mwait/hwc/bma
dev.cpu.1.cx_usage_counters: 49270 692739 38584173
dev.cpu.1.cx_usage: 0.12% 1.76% 98.11% last 5731us
dev.cpu.1.cx_lowest: C8
 
Last edited:

tio

Contributor
Joined
Oct 30, 2013
Messages
119
Is has been enabled, however i cant see it in the tuneable and im trying to throttle the CPU at idle.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
I think they ditched powerd support awhile back. Modern CPU's already self-manage power very aggressively. powerd is really a mid-2000's hack to try to help the hardware cope, but it is a bit of a blunt tool to do so.

You can try running powerd manually to see if it makes any difference.
 

tio

Contributor
Joined
Oct 30, 2013
Messages
119
I think they ditched powerd support awhile back. Modern CPU's already self-manage power very aggressively. powerd is really a mid-2000's hack to try to help the hardware cope, but it is a bit of a blunt tool to do so.

You can try running powerd manually to see if it makes any difference.
How do I run it?
 

tio

Contributor
Joined
Oct 30, 2013
Messages
119
Type "powerd".
Done that and it just returns to the command prompt. Is that it? How do I enable the runs led for c states?
 

tio

Contributor
Joined
Oct 30, 2013
Messages
119
Well, yes, of course. You were expecting fireworks? :smile:

I suppose you could run "powerd -v" to see fireworks.



"runs led"?
Sorry, autocorrect and my not taking my time.

It was supposed to say “tunable”.

I’ve checked and it now downclocks to 800mhz from 2.1ghz. Power usage is down a little and need to see it I can get even more power savings out of it.

Currently have some sea gate exos drives I will be installing shortly as according to documentation they idle power down to just under 2w without shutting down the spindle.
 

tio

Contributor
Joined
Oct 30, 2013
Messages
119
Ok think i may have got it, just need to check.

According to output it says highest state supported by Truenas is C8, this is fairly deep as it shuts off the processor. Id like to be able to shut off 14 of the 16 threads as its a 8 core 16 thread Xeon D 1541 chip.

So if i do this, would this achieve what im after?
dev.cpu.1.cx_lowest C2
dev.cpu.3.cx_lowest C2
dev.cpu.3.cx_lowest C3 (changing number until thread 16 is hit
 
Last edited:

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
Really, I have no idea. You're in waters few have bothered to venture into. Do feel free to experiment and report back with your findings, as I'm sure it will help future explorers.
 

tio

Contributor
Joined
Oct 30, 2013
Messages
119
It would appear ive been reading the figures wrong and its already supported and in fact spends almost 98% of the time in C3 state accusing to output in the OP.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
already supported and in fact spends almost 98% of the time in C3 state

Well, yes, obviously. As I mentioned earlier, powerd is really a relic from when CPU's needed some guidance from the OS/userland, and as far as I know, the modern stuff which is sort of a combination of strategies "in silicon" and better in-kernel support for those are much better than the blunt and laggy reactive throttling strategy of powerd, which is probably fine for laptops but not that great for servers etc. You came in showing that you had C3 saving and that it was working well. Running powerd in addition may save a little extra power but that's happening at the cost of performance, similar to how L-series CPU's manage to control TDP simply by not throttling all the way up. I don't know offhand how to get to your goal of

shut off 14 of the 16 threads

because it's really something I've never tinkered with on modern systems, and, with a 1541 being a 45W TDP part, I have to imagine it's idling at substantially less than that, and it isn't clear how much "better" it can get.
 
  • Like
Reactions: tio

tio

Contributor
Joined
Oct 30, 2013
Messages
119
I’ve found what’s causing a power hog. It’s my UPS!

Batteries are shot even though health says ok. Plugged into a watt meter the system is 70w at idle at the wall and 110w at load. Happy with that.

Enabling powerd with adaptive in the flags throttled down the chip down to 800mhz and it ramps up very fast under load. It’s a plex server mainly along with family backups.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
Well that's lovely, I hate UPS's too. Expensive battery cookers. Sadly necessary in my line of work. :-(
 

zizzithefox

Dabbler
Joined
Dec 18, 2017
Messages
41
Hi all

Need some help please. How do i enable powerd now and also how do i also enable the c states power saving? My cpu supports C3 according to the output but the documentation isn't clear from what i can see. Id also like to be able to throttle the cpu back when its idle to save every watt i can. I saw a post about doing a tunable for adaptive power but cant work out how to enable it.

Many thanks

the configuration database and will be reset on reboot.

I see you have solved your problems, but I don't see any readily usable response to some of your questions, in case someone less capable than you reads this post.

First of all, in order to have dynamic freq scaling with powerd, you have to use two RC tunables like this, which will ensure the values will not be reset on reboot:
1672741062804.png


powerd_enable will enable powerd between reboots
powerd_flags are nothing but the parameters to the powerd daemon, and you can test them as stated before by running
powerd -v $powerd_flags
In order to know which values you can put for -M and -m (max and min freq) you can just issue this command in the shell
sysctl dev.cpu.0.freq_levels
and decide according to your needs.

If powerd cannot detect if you are on battery or not, please remember to specify the -n parameter, otherwise -a and -b will do nothing. Since I am lazy, it took me a couple of years back in the days to figure why, on my UPS-backed NAS, powerd was working while on the other one didn't.

For the rest, please look at powerd manual which is pretty clear.

About c-states, they are normally not disabled in truenas as far as I know. If they are, it's in the BIOS (as stated before).
 
Last edited:
Top