Where are the powerd log files?

D

Deleted member 65953

Guest
I have enabled powerd(8) on my desktop. Is there a way to gain insight into what it is doing to save energy? I looked around for its log files but I could not find any. Where can I see powerd's logs?
 
Okay. This is what I get when running powerd -v:

Code:
# service powerd stop
# powerd -v
powerd: unable to determine AC line status
load   0%, current freq 1096 MHz ( 0), wanted freq 3100 MHz
load   0%, current freq 1096 MHz ( 0), wanted freq 3100 MHz
load   4%, current freq 1096 MHz ( 0), wanted freq 3100 MHz
load   0%, current freq 1096 MHz ( 0), wanted freq 3100 MHz
load  14%, current freq 1096 MHz ( 0), wanted freq 3100 MHz
load   0%, current freq 1096 MHz ( 0), wanted freq 3100 MHz
load  16%, current freq 1096 MHz ( 0), wanted freq 3100 MHz
load   0%, current freq 1096 MHz ( 0), wanted freq 3100 MHz
load   0%, current freq 1040 MHz ( 0), wanted freq 3490 MHz
load   0%, current freq 1040 MHz ( 0), wanted freq 3380 MHz
load   0%, current freq 1040 MHz ( 0), wanted freq 3274 MHz
load   0%, current freq 1040 MHz ( 0), wanted freq 3171 MHz
...

I ran the above for a few minutes but "current freq" never approaches "wanted freq". Does this mean that powerd(8) is ineffective on my computer?
 
Please show:
% grep powerd </etc/rc.conf
% sysctl dev.cpu.0

Code:
# grep powerd </etc/rc.conf
powerd_enable="YES"

Code:
# sysctl dev.cpu.0
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 1853709 0 0
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 74422us
dev.cpu.0.cx_lowest: C1
dev.cpu.0.cx_supported: C1/1/1 C2/2/151 C3/3/1034
dev.cpu.0.freq_levels: 3100/-1
dev.cpu.0.freq: 1096
dev.cpu.0.%parent: acpi0
dev.cpu.0.%pnpinfo: _HID=none _UID=0 _CID=none
dev.cpu.0.%location: handle=\_SB_.PR00
dev.cpu.0.%driver: cpu
dev.cpu.0.%desc: ACPI CPU
 
[…] I ran the above for a few minutes but "current freq" never approaches "wanted freq". Does this mean that powerd(8) is ineffective on my computer?
I guess you have multiple CPUs. If you have installed the sources (optional during installation) you can read /usr/src/usr.sbin/powerd/powerd.c for details.
 
On halfway modern CPUs by far the most energy saving will be achieved by setting performance_cx_lowest="Cmax" in /etc/rc.conf.
With enabled C-states powerd(xx) usually doesn't achieve any further power savings but can have a noticeable impact on performance.
 
Code:
# grep powerd </etc/rc.conf
powerd_enable="YES"

Ok. Reason I asked was to see if you'd overridden the default powerd_flags, because ...

powerd: unable to determine AC line status

... which is a bit strange, but not the main issues, which are:

Code:
# sysctl dev.cpu.0
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 1853709 0 0
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 74422us
dev.cpu.0.cx_lowest: C1
dev.cpu.0.cx_supported: C1/1/1 C2/2/151 C3/3/1034

Agree with what sko said re setting performance_cx_lowest="Cmax" (or at least ="C2").

But the real reason that powerd is no use to you ...

Code:
dev.cpu.0.freq_levels: 3100/-1
dev.cpu.0.freq: 1096

... is that this processor offers only one frequency, 3100MHz, so powerd cannot change it.

Check /var/run/dmesg.boot: it's likely using "Speed Shift" rather than the older "Speed Step" that offers a range of freq_levels for selection.

The 1096MHz is chosen by the CPU itself, and powerd[xx] has not yet been modified to use the new selection mechanism.
 
Check /var/run/dmesg.boot: it's likely using "Speed Shift" rather than the older "Speed Step" that offers a range of freq_levels for selection.

You are right:

Code:
# grep cpu /var/run/dmesg.boot 
cpu0: <ACPI CPU> on acpi0
hwpstate_intel0: <Intel Speed Shift> on cpu0
hwpstate_intel1: <Intel Speed Shift> on cpu1
hwpstate_intel2: <Intel Speed Shift> on cpu2
hwpstate_intel3: <Intel Speed Shift> on cpu3
hwpstate_intel4: <Intel Speed Shift> on cpu4
hwpstate_intel5: <Intel Speed Shift> on cpu5
hwpstate_intel6: <Intel Speed Shift> on cpu6
hwpstate_intel7: <Intel Speed Shift> on cpu7
hwpstate_intel8: <Intel Speed Shift> on cpu8
hwpstate_intel9: <Intel Speed Shift> on cpu9
hwpstate_intel10: <Intel Speed Shift> on cpu10
hwpstate_intel11: <Intel Speed Shift> on cpu11
 
On halfway modern CPUs by far the most energy saving will be achieved by setting performance_cx_lowest="Cmax" in /etc/rc.conf.

What is performance_cx_lowest="Cmax"?

In rc.conf(5), only performance_cx_lowest="LOW" and performance_cx_lowest="HIGH" are documented:

performance_cx_lowest

(str) CPU idle state to use while on AC power. The string
"LOW" indicates that acpi(4) should use the lowest power
state available while "HIGH" indicates that the lowest la-
tency state (less power savings) should be used.
 
  • Thanks
Reactions: mro
What is performance_cx_lowest="Cmax"?

Cmax is equivalent to C8, so is greater (numerically) than the highest possible C-state, C7. It means to use maximum power saving during idle CPU periods.

FreeBSD ACPI otherwise uses C1, C2 and (sometimes, on some systems) C3. Yours has a latency of over a millisecond with C3, so C2 might perform better while still providing decent power/heat savings; you could test that.

In rc.conf(5), only performance_cx_lowest="LOW" and performance_cx_lowest="HIGH" are documented:

Yes, that manpage is years out of date, re cx_ settings at least.

HIGH and LOW values are in addition to direct values (C1, C2, C3 ...) but that's also not mentioned there. See script /etc/rc.d/power_profile to see how this works.
 
On halfway modern CPUs by far the most energy saving will be achieved by setting performance_cx_lowest="Cmax" in /etc/rc.conf.

How do I enable performance_cx_lowest="Cmax" without rebooting?
 
you'd have to set "dev.cpu.N.cx_lowest" for every core to C8 manually, e.g. via a loop from 0-N where N is your hw.ncpu value -1.

Should I do sysctl hw.acpi.cpu.cx_lowest=C2 too?
 
Should I do sysctl hw.acpi.cpu.cx_lowest=C2 too?

That's what power_profile sets; that normally gets propagated to each dev.cpu.N.cx_lowest.

Check afterwards though, to confirm, and browse /etc/rc.d/power_profile to see how it works.
 
No, you just need to a) set
performance_cx_lowest="Cmax" in /etc/rc.conf then b) run
% sudo service power_profile 0x01

Thanks for that info. Is that "power_profile" service documented anywhere? apropos couldn't find anything related...
 
Thanks for that info. Is that "power_profile" service documented anywhere? apropos couldn't find anything related...

Not as such, apart from itself and as both an action in /etc/devd.conf and an example in devd.conf(5).

It's particularly pertinent to laptops of course, but runs later in boot for all systems.
 
I have tried the C3 state by running sysctl hw.acpi.cpu.cx_lowest=C3, and after a few hours, sysctl -a | grep dev.cpu.0.cx_ shows this:

Code:
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 7523 13735 129526
dev.cpu.0.cx_usage: 4.98% 9.10% 85.90% last 10235us
dev.cpu.0.cx_lowest: C3
dev.cpu.0.cx_supported: C1/1/1 C2/2/151 C3/3/1034

Questions:

1. Does this show that C3 is a good choice, since dev.cpu.0.cx_usage_counters and dev.cpu.0.cx_usage show that C3's usage (85.90%) is higher than that of C1 and C2?

2. In dev.cpu.0.cx_usage: 4.98% 9.10% 85.90% last 10235us, what does the "last" part mean? Does it mean that dev.cpu.0's most recent use of a C-state lasted for 10235 microseconds?
 
I have tried the C3 state by running sysctl hw.acpi.cpu.cx_lowest=C3, and after a few hours, sysctl -a | grep dev.cpu.0.cx_ shows this:

sysctl dev.cpu | grep cx_usage should give you some further clues, as you have 12 cpus and Speed Shift.

A minute or so would be just as indicative, but we can't see what sort of load the box is running from the below, at the time you queried stats. Here that's over a sample period of only 10.235ms.

Code:
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 7523 13735 129526
dev.cpu.0.cx_usage: 4.98% 9.10% 85.90% last 10235us
dev.cpu.0.cx_lowest: C3
dev.cpu.0.cx_supported: C1/1/1 C2/2/151 C3/3/1034
Questions:

1. Does this show that C3 is a good choice, since dev.cpu.0.cx_usage_counters and dev.cpu.0.cx_usage show that C3's usage (85.90%) is higher than that of C1 and C2?

Looks good from here, but was it completely or somewhat idle at the time you ran sysctl -a?

2. In dev.cpu.0.cx_usage: 4.98% 9.10% 85.90% last 10235us, what does the "last" part mean? Does it mean that dev.cpu.0's most recent use of a C-state lasted for 10235 microseconds?

No. I believe it means that was the measurement period over which cx_usage_counters were accumulated, which are proportunate to those percentages. However it's many years since I explored that code; hopefully someone cluey will help out here. mav@ ? avg@ ?

If you really want to dig deeper, install sysutils/stress and run e.g. % stress -c 6 -t 120 & and watch top, or systat -vm ono, while taking snapshots of cx_ states. That should give you a load average of ~6, i.e. ~50% of your beasts raw CPU capacity - and get it warmed up. Or more traditional methods like make buildworld.

Here's what I see at idle, no X, on a 2.6GHz i5 Thinkpad:

Code:
 smithi@t430s:~ % t430stat
Fri Oct 27 00:15:04 AEDT 2023   dev.cpu.0.freq: 1200
cpu0: 0.65% 99.34% last 1620us  44.0C  tz0: 42.1C
cpu1: 0.83% 99.16% last 1325us  45.0C  { 0.08 0.08 0.08 }
cpu2: 0.73% 99.26% last 586us   48.0C  { LAPIC one-shot }
cpu3: 0.70% 99.29% last 744us   48.0C  { t.cnt: TSC-low }
dev.acpi_ibm.0.fan: 1 (auto)   _level: 0   _speed: 0
high            capacity: 99%   time: unknown
rate: 0 mW      voltage: 12193 mV
 
Back
Top