Bug 243233 - Coffee lake frequency scaling
Summary: Coffee lake frequency scaling
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.1-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-09 22:18 UTC by Dennis Noordsij
Modified: 2020-01-11 21:46 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Noordsij 2020-01-09 22:18:09 UTC
I have a workload where I benefit from single core speed, so I got a system with an i9-9900K (not overclocked) 8C CPU that should go up to 5GHz single core speed. (I know it's not server hardware but that's important for this application).

This works fine in Linux, but I would like to use, as always, FreeBSD.

The system seems stuck at 800MHz, despite powerds efforts, but the frequency table also doesn't look right.

kern.timecounter.hw defaults to TSC-low which precludes frequency scaling, but after changing it to HPET nothing really changes.

sysctl:

dev.cpu.0.freq_levels: 3601/95000 3600/95000 3400/87275 3200/79831 3000/73564 2800/66644 2600/60837 2400/54439 2200/49091 2000/43173 1800/38278 1600/32835 1400/27639 1200/23380 1000/18628 800/14778
dev.cpu.0.freq: 800


powerd -v:

load   0%, current freq  800 MHz (15), wanted freq  800 MHz
load   0%, current freq  800 MHz (15), wanted freq  800 MHz
load  20%, current freq  800 MHz (15), wanted freq  800 MHz
load 100%, current freq  800 MHz (15), wanted freq 3200 MHz
changing clock speed from 800 MHz to 3200 MHz
load 100%, current freq  800 MHz (15), wanted freq 7202 MHz
changing clock speed from 800 MHz to 3601 MHz
load  65%, current freq  800 MHz (15), wanted freq 7202 MHz
changing clock speed from 800 MHz to 3601 MHz
load 100%, current freq  800 MHz (15), wanted freq 7202 MHz
changing clock speed from 800 MHz to 3601 MHz
load 100%, current freq  800 MHz (15), wanted freq 7202 MHz
changing clock speed from 800 MHz to 3601 MHz
load 100%, current freq  800 MHz (15), wanted freq 7202 MHz
changing clock speed from 800 MHz to 3601 MHz

etc.

Hardware:
Handle 0x0047, DMI type 4, 48 bytes
Processor Information
        Socket Designation: U3E1
        Type: Central Processor
        Family: Core i9
        Manufacturer: Intel(R) Corporation
        ID: EC 06 09 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 158, Stepping 12
        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) Core(TM) i9-9900K CPU @ 3.60GHz
        Voltage: 1.3 V
        External Clock: 100 MHz
        Max Speed: 8300 MHz       // What ?
        Current Speed: 4653 MHz   // What? Seems fixed
        Status: Populated, Enabled
        Upgrade: Socket LGA1151
        L1 Cache Handle: 0x0044
        L2 Cache Handle: 0x0045
        L3 Cache Handle: 0x0046
        Serial Number: To Be Filled By O.E.M.
        Asset Tag: To Be Filled By O.E.M.
        Part Number: To Be Filled By O.E.M.
        Core Count: 8
        Core Enabled: 8
        Thread Count: 16
        Characteristics:
                64-bit capable
                Multi-Core
                Hardware Thread
                Execute Protection
                Enhanced Virtualization
                Power/Performance Control



What should I do? I have been happily using FreeBSD for so long that I never considered something like this not working.

1) Can I lock the frequency somehow at boot?

2) Is there some alternative way to scale up the frequency?

3) Can it be locked from BIOS? Some BIOS setting changed?

4) Can it be fixed? Where should I start looking? What is new in coffee lake / the i9-9900 that is different from the usual Intel cpufreq approach?
Comment 1 Dennis Noordsij 2020-01-10 00:50:18 UTC
After more testing:

If I kldload cpuctl and run i7z it does appear frequency scaling is working for some default scaling setup (hover around 1200MHz-2000MHz but scale up to 5GHz under load).

powerd does not seem to be able to tell the current frequency correctly (i7z can, and I have verified with basic benchmarks that performance matches i7z's output).

when powerd is run with "-n maximum" it matches the above behaviour (~2GHz baseline and scale up under load, although it says it wants to go 7200MHz and IMO should be at 3600Mhz), then powerd -v drops to 800MHz under no load.

this is "good enough" for me at the moment, as the default behaviour is what I'd like, but there seems be something wrong (scaling/multiplier?) with powerd/cpufreq.
Comment 2 Conrad Meyer freebsd_committer 2020-01-10 01:50:24 UTC
Disable powerd and the system should turboboost just fine.  powerd is functionally obsolescent / broken.

The "3601/xxx" frequency level is "3.6GHz base clock + turboboost."
Comment 3 Conrad Meyer freebsd_committer 2020-01-10 01:52:08 UTC
See also this work in progress: https://reviews.freebsd.org/D18028
Comment 4 Dennis Noordsij 2020-01-11 21:46:28 UTC
Thank you for your comments Conrad.

Despite the confusing feedback from powerd the system works fine as you said.

I don't really need powerd functionality at the moment, but look forward to the work in progress making it into one of the next versions, as it would be nice to occasionally lock it to the max speed.