OPNsense Forum

Archive => 22.1 Legacy Series => Topic started by: payback007 on June 29, 2022, 11:37:27 pm

Title: powerD seem not working
Post by: payback007 on June 29, 2022, 11:37:27 pm
Dear all,

I'm trying to enable powerD functionality, but it seems powerD is not working:

from BIOS: CPU frequency 800-2100 MHz possible
P-states: enabled
C-states: enabled
HWP-states: enabled

Mainboard: Supermicro X11SSH-LN4F
CPU: Intel XEON E3-1240L v5

Is there anything I need to enable too?

sysctl dev.cpu.0 show following output:

Code: [Select]
dev.cpu.0.temperature: 45.0C
dev.cpu.0.coretemp.throttle_log: 0
dev.cpu.0.coretemp.tjmax: 100.0C
dev.cpu.0.coretemp.resolution: 1
dev.cpu.0.coretemp.delta: 55
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 313694 0 0
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 335us
dev.cpu.0.cx_lowest: C1
dev.cpu.0.cx_supported: C1/1/1 C2/2/151 C3/3/256
dev.cpu.0.freq_levels: 2100/-1
dev.cpu.0.freq: 2914
dev.cpu.0.%parent: acpi0
dev.cpu.0.%pnpinfo: _HID=none _UID=0 _CID=none
dev.cpu.0.%location: handle=\_PR_.CPU0
dev.cpu.0.%driver: cpu
dev.cpu.0.%desc: ACPI CPU

result: there is only one CPU level. Is there anything wrong in configuration or do I have to enable something different?
Title: Re: powerD seem not working
Post by: torob2 on August 14, 2022, 04:14:44 pm
I can confirm this even with 22.7. PowerD doesn't seem to work at all. On a system with a Intel Celeron N5105, the CPU clock stays all the time at 2 GHz while in another ...sense you can see frequencies as low as 800 MHz on the same hardware.
Title: Re: powerD seem not working
Post by: netnut on August 14, 2022, 09:46:43 pm
I can confirm this even with 22.7. PowerD doesn't seem to work at all.

You might want to check your bios (updates/settings), because PowerD does work:

Code: [Select]
dev.cpu.0.temperature: 57.0C
dev.cpu.0.coretemp.throttle_log: 0
dev.cpu.0.coretemp.tjmax: 96.0C
dev.cpu.0.coretemp.resolution: 1
dev.cpu.0.coretemp.delta: 38
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc
dev.cpu.0.cx_usage_counters: 36741498 0
dev.cpu.0.cx_usage: 100.00% 0.00% last 96us
dev.cpu.0.cx_lowest: C1
dev.cpu.0.cx_supported: C1/1/1 C2/2/50
dev.cpu.0.freq_levels: 2000/0 1900/0 1800/0 1700/0 1600/0 1500/0 1400/0 1300/0 1200/0 1100/0 1000/0 900/0 800/0
dev.cpu.0.freq: 800
dev.cpu.0.%parent: acpi0
dev.cpu.0.%pnpinfo: _HID=none _UID=0 _CID=none
dev.cpu.0.%location: handle=\_PR_.CPU0
dev.cpu.0.%driver: cpu
dev.cpu.0.%desc: ACPI CPU
Title: Re: powerD seem not working
Post by: torob2 on August 15, 2022, 11:24:24 am
Well, that's not what's happening here with an Intel Celeron N5105 system:

Code: [Select]
dev.cpu.0.temperature: 53.0C
dev.cpu.0.coretemp.throttle_log: 0
dev.cpu.0.coretemp.tjmax: 105.0C
dev.cpu.0.coretemp.resolution: 1
dev.cpu.0.coretemp.delta: 52
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 10643 0 0
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 134us
dev.cpu.0.cx_lowest: C1
dev.cpu.0.cx_supported: C1/1/1 C2/2/253 C3/3/1048
dev.cpu.0.freq_levels: 1996/-1
dev.cpu.0.freq: 2096
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

It has nothing to do with the BIOS settings because the same settings are used for the other ...sense system which is able to throttle the CPU below 2 GHz. I would have expected an opposing result because the other system is based on FreeBSD 12.3 while OPNsense 22.7 is using FreeBSD 13.1 and the Intel Celeron N5105 (Jasper Lake) is still quite new given its release in 2021.
Title: Re: powerD seem not working
Post by: cookiemonster on August 15, 2022, 12:08:30 pm
What's set to in System > Settings > Miscellaneous > Thermal Sensors and Power Savings ?
They might need a review.
Title: Re: powerD seem not working
Post by: torob2 on August 15, 2022, 12:45:07 pm
Thermal Sensors are set to Intel, of course. PowerD is enabled and set to Hiadaptive. The same settings as in the other ...sense. CPU clock goes up (max 2.9 GHz) if needed but never below 2 GHz whenever I checked.
Title: Re: powerD seem not working
Post by: Patrick M. Hausen on August 15, 2022, 01:29:40 pm
What happens when you change from hiadaptive to adaptive?
Title: Re: powerD seem not working
Post by: Taunt9930 on August 15, 2022, 07:20:40 pm
I seem to have the same on an Intel 8565U. Adaptive / Hi-Adaptive makes no difference. Running 22.7.1.

Code: [Select]
dev.cpu.0.temperature: 35.0C
dev.cpu.0.coretemp.throttle_log: 1
dev.cpu.0.coretemp.tjmax: 100.0C
dev.cpu.0.coretemp.resolution: 1
dev.cpu.0.coretemp.delta: 65
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 139656250 0 0
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 94us
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: 2000/-1
dev.cpu.0.freq: 795
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

Title: Re: powerD seem not working
Post by: cookiemonster on August 15, 2022, 10:46:50 pm
Sorry I can't diagnose at the moment. All my Intel freebsd machines are switched off, only amd in use at present. At a glance however it seems the cpu or bios is not reporting scaling frequencies available.
Title: Re: powerD seem not working
Post by: netnut on August 15, 2022, 11:15:21 pm
At a glance however it seems the cpu or bios is not reporting scaling frequencies available.

PowerD can only switch frequencies if your CPU reports them, like:

Code: [Select]
dev.cpu.0.freq_levels: 2000/0 1900/0 1800/0 1700/0 1600/0 1500/0 1400/0 1300/0 1200/0 1100/0 1000/0 900/0 800/0
If you see something like this you probably have a Intel Speed Shift CPU:

Code: [Select]
dev.cpu.0.freq_levels: 2000/-1
PowerD can't "switch" between a single entry, so don't blaim PowerD, nothing wrong with that poor little daemon...

Tweaking your base speed (or disable it all together and try to use a "legacy" driver _with_ PowerD), play around with:

Code: [Select]
man hwpstate_intel


Title: Re: powerD seem not working
Post by: Taunt9930 on August 15, 2022, 11:32:04 pm
That could be the issue for me - a bit of research suggests the i7-8565 is an Intel Speedshift CPU. I didn't realise this was different/exclusive to the normal Processor / C-State scaling.

That being the case, what are my options with OPNSense? You've hinted at a different driver, but as a newbie to the platform I'm not clear.

I found this that suggest Speedshift should just work? https://forum.opnsense.org/index.php?topic=26590.0

EDIT:

OK, so freeBSD 13.0 introduced a Speedshiftdriver. I have validated that is what my system is using, and why powerd does not work:

Code: [Select]
dmesg | grep hwpstate_inte
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

I've also seen that this indicates that the new man:hwpstate_intel driver is in use.

Code: [Select]
sysctl dev.cpufreq.0.freq_driver
dev.cpufreq.0.freq_driver: hwpstate_intel0

On such systems, the oid `dev.cpu.%d.freq_levels` will show only the maximum CPU frequency, and will indicate a power consumption level of `-1`.

Code: [Select]
sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 795

Thus, the reason you see xxxx/-1 when querying. What I need to work out now is why the maximum shown is 2000, not what the chip is able to do. And also why it *seems* to be stuck at the lowest level of 795.

Any further guidance appreciated - hopefully some of the above helps the others, as I see similar outputs.


Thanks.
Title: Re: powerD seem not working
Post by: netnut on August 16, 2022, 12:16:42 am

I found this that suggest Speedstep should just work? https://forum.opnsense.org/index.php?topic=26590.0


Mind the little details: SpeedStep & SpeedShift, the latter is the shiny new thing supported by hwpstate_intel. I don't have a recent Intel CPU in reach, but you can try to completly disable hwpstate (and hope the "legacy" cpufreq drivers kick in that should be supported by PowerD)

From the man page:

Tunable: (0=enabled, 1=disabled)
Code: [Select]
hint.hwpstate_intel.0.disabled
Or tweak hwpstate from it's default "performance" (0) to "efficient" (100) so it lowers its base clock

Code: [Select]
dev.hwpstate_intel.0.epp 100
SpeedShift should be controlled by the CPU itself instead of PowerD in that case
Title: Re: powerD seem not working
Post by: Taunt9930 on August 16, 2022, 12:23:44 am

I found this that suggest Speedstep should just work? https://forum.opnsense.org/index.php?topic=26590.0


Mind the little details: SpeedStep & SpeedShift, the latter is the shiny new thing supported by hwpstate_intel. I don't have a recent Intel CPU in reach, but you can try to completly disable hwpstate (and hope the "legacy" cpufreq drivers kick in that should be supported by PowerD)

From the man page:

Tunable: (0=enabled, 1=disabled)
Code: [Select]
hint.hwpstate_intel.0.disabled
Or tweak hwpstate from it's default "performance" (0) to "efficient" (100) so it lowers its base clock

Code: [Select]
dev.hwpstate_intel.0.epp 100
SpeedShift should be controlled by the CPU itself instead of PowerD in that case

Thanks netnut, appreciate the steer! Whilst you were replying I already modified my post above, several times (LoL) - I was getting confused with speedstep/speedshift. My CPU is indeed SpeedShift enabled and I think I've got a bit more work to do to understand what (if anything) is going on - it actually seems to be stuck in the lower state, and reports a top frequency that is too low.
Title: Re: powerD seem not working
Post by: Taunt9930 on August 16, 2022, 12:42:04 am
OK, so in my case, it looks like the reporting is broken, but the driver works.

As per my post above, this response:

Code: [Select]
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 795

Would suggest that the maximum frequency scalable by the Speedshift driver is 2000MHz. However (and this took ages), putting the firewall under some load using a speedtest (PPPoE connection!) and various other things, and repeatedly querying the processor speed using the shell, suggests it is working based on the outputs:

Code: [Select]
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 795
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 894
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 795
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 894
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 894
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 894
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 2508
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 894
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 795
root@LushBrain:~ # sysctl dev.cpu.0.freq_levels dev.cpu.0.freq
dev.cpu.0.freq_levels: 2000/-1
dev.cpu.0.freq: 4082

So, if you have a SpeedSHIFT CPU, disable PowerD (it WILL NOT work with hwpstates driver) and it (SpeedSHIFT) should 'just work'. As Netnut has noted above, you can also tweak hwpstate from it's default "performance" (0) to "efficient" (100).

Hopefully that helps at least one of you guys - @torob2, that is almost certainly the case for you and @payback007 it also looks like you have a speedshift CPU, too.
Title: Re: powerD seem not working
Post by: waka324 on August 25, 2022, 08:15:49 am
Well, that's not what's happening here with an Intel Celeron N5105 system:

Code: [Select]
dev.cpu.0.temperature: 53.0C
dev.cpu.0.coretemp.throttle_log: 0
dev.cpu.0.coretemp.tjmax: 105.0C
dev.cpu.0.coretemp.resolution: 1
dev.cpu.0.coretemp.delta: 52
dev.cpu.0.cx_method: C1/mwait/hwc C2/mwait/hwc C3/mwait/hwc
dev.cpu.0.cx_usage_counters: 10643 0 0
dev.cpu.0.cx_usage: 100.00% 0.00% 0.00% last 134us
dev.cpu.0.cx_lowest: C1
dev.cpu.0.cx_supported: C1/1/1 C2/2/253 C3/3/1048
dev.cpu.0.freq_levels: 1996/-1
dev.cpu.0.freq: 2096
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

It has nothing to do with the BIOS settings because the same settings are used for the other ...sense system which is able to throttle the CPU below 2 GHz. I would have expected an opposing result because the other system is based on FreeBSD 12.3 while OPNsense 22.7 is using FreeBSD 13.1 and the Intel Celeron N5105 (Jasper Lake) is still quite new given its release in 2021.

I'm seeing the same behavior unfortunately. Same processor.
Title: Re: powerD seem not working
Post by: netnut on August 25, 2022, 11:23:41 am
I'm seeing the same behavior unfortunately. Same processor.

Unfortunately ? Did you decide to ignore all other posts (specifically the last one from Taunt9930) on purpose ?
Title: Re: powerD seem not working
Post by: waka324 on August 26, 2022, 10:43:01 pm
I ended up flashing a newer BIOS. That seemed to enable the CPU frequency to actually scale.
Title: Re: powerD seem not working
Post by: waka324 on August 26, 2022, 10:49:45 pm
I'm seeing the same behavior unfortunately. Same processor.

Unfortunately ? Did you decide to ignore all other posts (specifically the last one from Taunt9930) on purpose ?

Don't be obtuse. I was replying specifically to @torob2. The vendor for my N5105 unit seems to have an outdated BIOS. The frequency was never scaling on usage with Speed Shift enabled. Ended up flashing a different BIOS from a similar line of units to get an update.

Seems to have done the trick. My CPU now actually scales depending on the load and the Speed Shift efficiency setting.