OPNsense Forum

Archive => 24.1, 24.4 Legacy Series => Topic started by: XeonFX on February 05, 2024, 07:56:44 PM

Title: [Solved] Wrongly detected CPU frequency
Post by: XeonFX on February 05, 2024, 07:56:44 PM
Dear colleagues and Opensense makers,

First of all let me thank you all for your hard work and contributions to Opensense! I'm enjoying this platform since 2019.
Upgraded to v24.1_1, fresh install importing config. All good except CPU frequency not being detecting properly so instead of scaling up and down it stays at maximum freq. Hopefully somebody can help me. Not a critical issue.

I have an Intel Celeron 3965U which typically goes from 400Mhz to 2200Mhz but now is stuck to 2200Mhz. Dmidecode is showing that processor max frequency was wrongly recognized (8300 MHz). There is no enough liquid nitrogen in the world to achieve that freq in my tiny CPU LOL. Powerd is getting crazy due that as well. No BIOS changes/updates. I has been working fine with a number of Opensense releases since 2020.

:~ # dmidecode -t processor
# dmidecode 3.5
# SMBIOS entry point at 0x9f61c000
Found SMBIOS entry point in EFI, reading table from /dev/mem.
SMBIOS 2.8 present.

Handle 0x003E, DMI type 4, 48 bytes
Processor Information
        Socket Designation: U3E1
        Type: Central Processor
        Family: Celeron
        Manufacturer: Intel(R) Corporation
        ID: E9 06 08 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 142, Stepping 9
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (FXSAVE and FXSTOR instructions supported)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Multi-threading)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Celeron(R) CPU 3965U @ 2.20GHz
        Voltage: 0.8 V
        External Clock: 100 MHz
        Max Speed: 8300 MHz
        Current Speed: 2100 MHz


:~ # powerd -v
powerd: unable to determine AC line status
CPU frequency is above user-defined maximum; changing frequency to 2200 MHz
load  61%, current freq 2206 MHz ( 0), wanted freq 3588 MHz
load 200%, current freq 2206 MHz ( 0), wanted freq 4400 MHz
load 200%, current freq 2206 MHz ( 0), wanted freq 4400 MHz
load 200%, current freq 2206 MHz ( 0), wanted freq 4400 MHz

Thanks in advance!




Title: Re: Wrongly detected CPU frequency
Post by: newsense on February 06, 2024, 03:26:16 AM
Did you import the config from an Intel or AMD system ?

When going to this URL what are the sensors set for ? (adjust the IP as needed of course)


https://192.168.1.1/system_advanced_misc.php (https://192.168.1.1/system_advanced_misc.php)
Title: Re: Wrongly detected CPU frequency
Post by: XeonFX on February 06, 2024, 09:31:59 AM
Hi Newsense,

Thanks for your reply.
I've imported it from a Proxmox VM running Opensense 24.1_1 on an Intel i5-10210U. I typically do that for major releases to verify that everything works fine first in a non-production easy-to-spin-up VM. Never had any issue importing config back to the production physical FW.

The sensors are set for "Intel Core* CPU on-die thermal sensor (coretemp)". It is working fine as reports the CPU temperature correctly.

Thanks.
Title: Re: Wrongly detected CPU frequency
Post by: Seimus on February 06, 2024, 02:27:25 PM
Hmm,

I think I was dealing with something similiar when i got my N5105. It was constantly locked at MAX burst clock.

I did add these to the tunnables which enabled the CPU to use lower freq.

dev.cpu.0.cx_lowest lowest CX sleep state to used runtime C3
dev.cpu.1.cx_lowest lowest CX sleep state to used runtime C3
dev.cpu.2.cx_lowest lowest CX sleep state to used runtime C3
dev.cpu.3.cx_lowest lowest CX sleep state to used runtime C3
hw.acpi.cpu.cx_lowest lowest CX sleep state to used runtime C3


However my problem was more like it was clocked at max rather than being wrongly detected.

Regards,
S.
Title: Re: Wrongly detected CPU frequency
Post by: XeonFX on February 06, 2024, 03:58:47 PM
Hi Seimus,

Thanks for your advice.
Unfortunately my root issue is CPU max speed is not detected correctly so modifying lowest C states is not helping.

Anyway thanks for taking the time to read my post and replying ;)
Title: Re: Wrongly detected CPU frequency
Post by: zan on February 06, 2024, 04:11:02 PM
It looks like your CPU supports Intel Speed Shift. You should be using hwpstate_intel driver instead and disable powerd.

Please refer to handbook section about Intel Speed Shift https://docs.freebsd.org/en/books/handbook/config/#hwpstate_intel
Title: Re: Wrongly detected CPU frequency
Post by: newsense on February 06, 2024, 04:42:46 PM
Thanks Zan, this was quite unexpected.


Looks like N5105 also uses hwpstate_intel0 -- Seimus.

Interestingly powerd was also running on this FW I'm looking at...unsure how that would actually work. (now stopped while doing some reading)

The cores are now idling at 797 Mhz in htop - which I haven't seen before.
Title: Re: Wrongly detected CPU frequency
Post by: XeonFX on February 06, 2024, 05:24:19 PM
Quote from: zan on February 06, 2024, 04:11:02 PM
It looks like your CPU supports Intel Speed Shift. You should be using hwpstate_intel driver instead and disable powerd.

Please refer to handbook section about Intel Speed Shift https://docs.freebsd.org/en/books/handbook/config/#hwpstate_intel

Many thanks Zan! That fixed my issue. Wasn't aware of that driver change.
Thanks again for making this community great!
Title: Re: Wrongly detected CPU frequency
Post by: Seimus on February 06, 2024, 07:21:06 PM
Quote from: zan on February 06, 2024, 04:11:02 PM
It looks like your CPU supports Intel Speed Shift. You should be using hwpstate_intel driver instead and disable powerd.

Please refer to handbook section about Intel Speed Shift https://docs.freebsd.org/en/books/handbook/config/#hwpstate_intel

Quote from: newsense on February 06, 2024, 04:42:46 PM
Thanks Zan, this was quite unexpected.


Looks like N5105 also uses hwpstate_intel0 -- Seimus.

Interestingly powerd was also running on this FW I'm looking at...unsure how that would actually work. (now stopped while doing some reading)

The cores are now idling at 797 Mhz in htop - which I haven't seen before.

Yea I totally forgot about the Intel Speed Shift. The N5105 I think runs it by default I think "out of the box".

$ sysctl dev.cpufreq.0.freq_driver
dev.cpufreq.0.freq_driver: hwpstate_intel0


I had as well before turned on powerD HiAdaptive, but from what I read thru if you have ISS active PowerD settings don't do anything, you would have to disable ISS in order to take PowerD functional.

When I got my N5105 unit the first thing was to look around what was going on and two things that stricked me were:
1. Wrongly set PL1 & PL2, above what the CPU can even draw
- so corrected this in BIOS
2. CPU was always clocked MAX even on IDLE causing unnecessary power drawn and heat
- corrected this by including dev.cpu.X.cx_lowest per core & hw.acpi.cpu.cx_lowest

After this power draw went into normal number, temps went down and mostly the CPU was not clocked on MAX during Idle. On OPNsense forum was a post where one user tested these settings during his time with the modern generation of Intel CPU so that's where I got it mostly + BSD tunables guideline.

Basically now, just PowerD running disabled + those 5 tunables and all works well (+ I slapped a low profile fan on the chassis cause I have my FW in a small rack to help it during summer).

(https://forum.opnsense.org/index.php?action=dlattach;topic=38627.0;attach=32784)

Regards,
S.

Title: Re: [Solved] Wrongly detected CPU frequency
Post by: Seimus on February 06, 2024, 07:51:04 PM
I will post here some nice reading regarding this from serverthehome as well, people did discuss it there were well how to optimize the clock/performance/temp ratio.

https://forums.servethehome.com/index.php?threads/cwwk-topton-nxxx-quad-nic-router.39685/post-374035
https://forums.servethehome.com/index.php?threads/topton-jasper-lake-quad-i225v-mini-pc-report.36699/post-359615

My goal was to have the CPU use the MAX Turbo Freq if needed but as well to be able to go lower when idling while keeping temps in check.

This was achieved as mentioned by tuning PL1 PL2 and setting those 5 tunables ;)

Regards,
S.