Repository navigation
Read CPU topology and identifier on DragonFly BSD - #3789
Conversation
DragonFly BSD has no kern.sched.topology_spec, so FreeBsdCentralProcessor fell back to a single logical processor. Read each CPU's package and core from hw.cpu_topology.cpuN.physical_id and core_id instead; core_id is only published when a chip has more than one core, so a missing one means a core of its own. physical_siblings is not used: on DragonFly 6.4 it reads cpus() for every CPU but the first. DragonFly's dmesg.boot writes the Origin line as Origin = "GenuineIntel" Id = 0x50655 Stepping = 5 with spaces around "=" and no Family or Model fields, which left vendor, family, model, stepping and the feature flags (found by matching the exact text "Origin=") empty. Parse the line's key=value fields generically and decode family and model from the CPUID signature when they are absent. Pre-existing bug: the CPUID decoder moved from OpenBsdCentralProcessor to AbstractCentralProcessor so both can share it. It OR'd the extended family into the base family instead of adding it, and only when the base was 0xF, so AMD Zen (0x00800F12) decoded as family 143 rather than 23. The microarchitecture table is keyed by the display family, so every AMD processor of family 16 or later was unknown on OpenBSD. The test that asserted 143 now asserts 23, with Zen 3 and K8 vectors added. Verified on DragonFly BSD 6.4 (cfarm152), JNA and FFM: 8 packages, 8 cores, 8 logical processors, Intel64 Family 6 Model 85 Stepping 5, Cascade Lake, feature flags present.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No actionable issue is established; the change is mergeable after normal checks. Pre-merge checks |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3789 +/- ##
============================================
- Coverage 80.62% 80.58% -0.04%
- Complexity 310 536 +226
============================================
Files 724 724
Lines 26005 26027 +22
Branches 4395 4401 +6
============================================
+ Hits 20966 20974 +8
- Misses 2795 2808 +13
- Partials 2244 2245 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
createProcessorID builds the x86 processor signature (CPUID leaf 1 EAX) from the displayed family, model and stepping when no platform source supplies one. A family above 15 is defined as a base family of 15 plus an extended family, but the encoder split the family's own bits between the two fields: family 23 (AMD Zen) became base 7 / extended 1, giving 00100712 instead of 00800F12. Every AMD processor from family 16 (K10) on was affected; Intel's families 6 and 15 were already correct. This is the inverse of the decoding bug fixed in #3789. The encoded value is used on Linux when neither dmidecode nor cpuid is available, on Solaris, and on Windows when WMI returns no ProcessorId. Tests encode Zen and Zen 4 against known signatures, and round-trip six real Intel and AMD signatures through cpuidToFamilyModelStepping and back.
Fixes
CentralProcessoron DragonFly BSD, which reported one logical processor and no family, model, stepping, vendor or feature flags.Topology
DragonFly has no
kern.sched.topology_spec. When it is empty,FreeBsdCentralProcessornow readshw.cpu_topology.cpuN.physical_idandcore_idfor each CPU.core_idexists only when a chip has more than one core, so a CPU without one is treated as a core of its own.physical_siblingsis not used; on DragonFly 6.4 it readscpus()for every CPU but the first.Identifier
DragonFly's
dmesg.bootwritesOrigin = "GenuineIntel" Id = 0x50655 Stepping = 5, with spaces around=and no Family or Model. The Origin line is now parsed as generic key=value fields, with family and model decoded from the CPUID signature when absent. The feature flags were missing because the code matched the exact textOrigin=.Pre-existing OpenBSD bug
The CPUID decoder moved from
OpenBsdCentralProcessortoAbstractCentralProcessorso both share it. It combined the extended family incorrectly, decoding AMD Zen (0x00800F12) as family 143 instead of 23, so every AMD processor of family 16 or later showed an unknown microarchitecture on OpenBSD. Tests now assert 23, with Zen 3 and K8 vectors added.Verification
core_id, so the multi-core and SMT grouping is covered only by unit tests.Summary by CodeRabbit