Skip to content

Read NetBSD processor identity, topology and caches - #3818

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:netbsd-arm-cpu
Oct 17, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:netbsd-arm-cpu

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

NetBSD prefixes every dmesg line with a timestamp ([ 1.000004] ), so none of the shared BSD dmesg patterns matched. Every NetBSD machine reported one physical core, no caches and no feature flags.

Changes:

  • Shared BSD base: strips the timestamps, and accepts NetBSD's topology line (cpuN: [node N, ]package P, core C, smt S) and its ARM cache lines (L1 64KB/64B 4-way (256 set) VIPT Instruction cache). The , id 0x... suffix on the model line is dropped. On ARM that is the affinity register, which differs per core and would make each core look like a different type.
  • AArch64 identity: read from the Main ID Register, the first member of machdep.cpu0.cpu_id (struct aarch64_sysctl_cpu_id), in the form Linux reports it. The name comes from the processor's dmesg line, because hw.model names the board.
  • x86: family, model and stepping come from the CPUID signature dmesg prints (id 0xa00f11).
  • 64-bit: read from hw.machine_arch. hw.machine is the port name (evbarm).

Two older bugs in ProcessorIdentifier, affecting every platform:

  • The ARM microarchitecture lookup built the key arm..0xd0c against a table keyed arm.0xd0c, so it never matched.
  • The identifier string used the raw implementer 0x41 rather than the vendor it maps to (ARM).

Verified on NetBSD 10.1 aarch64 (cfarm428, KVM Neoverse N1) in all three configurations (JNA without native library, JNA native, FFM):

Before After
Name netbsd,generic-acpi Arm Neoverse N1 r3p1 (v8.2-A+)
Physical cores 1 16
Identifier QEMU Family Model Stepping ARM Family 8 Model 0xd0c Stepping r3p1
ProcessorID (empty) 413FD0C100000000
Microarchitecture unknown Neoverse-N1

./mvnw clean test -Paggregate-coverage passes there in every module. The x86 test fixtures come from NetBSD 10.1 amd64 on the GitHub Actions VM; cpuctl identify there agrees with the decoded family 25, model 1, stepping 1.

Not addressed: on x86 the vendor still comes from SMBIOS, which is QEMU on a VM, and x86 cache sizes appear only in cpuctl identify, not in dmesg.

Summary by CodeRabbit

  • New Features
    • NetBSD processor detection now recognizes ARM processor identities and microarchitectures, as well as x86 family, model, and stepping details.
    • NetBSD processor information now includes improved topology and ARM cache reporting.
  • Bug Fixes
    • Improved parsing of NetBSD system messages to identify processor names and details reliably, including when timestamps are present.

NetBSD prefixes every dmesg line with a timestamp, "[     1.000004] ", so
none of the shared BSD dmesg patterns matched: every NetBSD machine
reported one physical core, no caches and no feature flags. The shared
base now strips the timestamps and also accepts NetBSD's topology line,
"cpuN: [node N, ]package P, core C, smt S", and its ARM cache lines,
"L1 64KB/64B 4-way (256 set) VIPT Instruction cache". The ", id 0x..."
suffix NetBSD appends to the model line is dropped; on ARM it is the
affinity register, which differs on every processor and would make each
core look like a different type.

On AArch64 the vendor, part number, variant and revision now come from
the Main ID Register, the first member of the struct in
machdep.cpu0.cpu_id, in the form Linux reports them. The name comes from
the processor's dmesg line, since hw.model names the board. On x86 the
family, model and stepping come from the CPUID signature dmesg prints.
64-bit is read from hw.machine_arch, since hw.machine is the port
(evbarm).

Two pre-existing bugs in ProcessorIdentifier, affecting every platform:
the ARM microarchitecture lookup built the key "arm..0xd0c" against a
table keyed "arm.0xd0c", so it never matched; and the identifier string
used the raw implementer "0x41" rather than the vendor it maps to.

Verified on NetBSD 10.1 aarch64 (cfarm428, KVM Neoverse N1) in all three
configurations: 16 cores, Neoverse-N1, MIDR 413FD0C1, full test suite
passing. The x86 fixtures are from NetBSD 10.1 amd64 on the CI VM.
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 24b617db-ce60-49da-aa88-bf464ff86641
📥 Commits

Reviewing files that changed from the base of the PR and between 0b6b275 and c418b55.

📒 Files selected for processing: 7
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/CentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java
  • oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessorTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 8
  • GitHub Check: Test JDK 25, OpenIndiana
  • GitHub Check: Test JDK 25, FreeBSD
  • GitHub Check: Test JDK 25, NetBSD
  • GitHub Check: Test JDK 25, OpenBSD
  • GitHub Check: Analyze (java)
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Error Prone
🧰 Additional context used
📚 Code guidelines: 2
AGENTS.md — unknown
CONTRIBUTING.md — unknown
📓 Path-based instructions: 2
Source excerpt: **Banned APIs** (`config/forbidden-apis.txt` and friends, enforced by `forbiddenapis:check`): `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any `System.load`/`loadLibrary`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
  • oshi-common/src/main/java/oshi/hardware/CentralProcessor.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessorTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java
Applicability reference: AGENTS.md: # AGENTS.md Instructions for AI coding agents working in the OSHI repository.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • CHANGELOG.md
🔇 Additional comments: 7
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.java: 1

39-59: LGTM!

Also applies to: 80-80, 103-135, 147-155, 172-186, 206-216

oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdCentralProcessorTest.java: 1

47-67: LGTM!

Also applies to: 110-150

CHANGELOG.md: 1

25-25: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java: 1

30-33: LGTM!

Also applies to: 49-70, 72-106, 168-180

oshi-common/src/main/java/oshi/hardware/CentralProcessor.java: 1

914-914: LGTM!

Also applies to: 1062-1075

oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessorTest.java: 1

16-16: LGTM!

Also applies to: 44-50, 60-91

oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java: 1

139-147: LGTM!

📝 Walkthrough

NetBSD processor detection now parses timestamped dmesg output for CPU topology, names, caches, and processor identifiers. ARM detection extracts processor fields from the MIDR, while x86 detection converts the CPUID signature into family, model, and stepping values.

Changes: NetBSD processor detection

Layer / File(s) Summary
BSD dmesg parsing
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.java, oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdCentralProcessorTest.java, CHANGELOG.md
BSD processor parsing strips NetBSD timestamps and reads CPU names, topology, ARM caches, and feature flags from dmesg. Tests cover timestamp handling, topology fields, CPU names, and cache parsing.
NetBSD x86 and ARM identification
oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java, oshi-common/src/main/java/oshi/hardware/CentralProcessor.java, oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessorTest.java, oshi-common/src/test/java/oshi/hardware/CentralProcessorTest.java
NetBSD identification parses x86 CPUID signatures and ARM MIDR values. ProcessorIdentifier uses the normalized vendor, and ARM microarchitecture lookup uses the ARM model key. Tests cover parsing and Neoverse N1 identification.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant NetBsdCentralProcessor
  participant NetBSD
  participant BsdCentralProcessor
  participant ProcessorIdentifier
  NetBsdCentralProcessor->>NetBSD: Read architecture and CPU sysctl values
  NetBsdCentralProcessor->>BsdCentralProcessor: Query timestamp-stripped dmesg
  BsdCentralProcessor->>NetBSD: Run dmesg
  NetBSD-->>BsdCentralProcessor: Return dmesg lines
  BsdCentralProcessor-->>NetBsdCentralProcessor: Return normalized lines
  NetBsdCentralProcessor->>NetBsdCentralProcessor: Parse ARM MIDR or x86 CPUID signature
  NetBsdCentralProcessor->>ProcessorIdentifier: Create ARM or generic processor identifier
Loading
Merge Risk: ⚪ Minimal · up to c418b

This change improves NetBSD processor identity, topology and cache detection, and the author reports passing tests. No actionable merge-blocking risk was found. x86 vendor identification still comes from SMBIOS, which is a documented limitation.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 6 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: NetBSD processor identity, topology, and cache parsing.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 6 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checked the dmesg trail
And found each timestamp, cache, and detail
An ARM ID sprang into view
An x86 signature joined it too
“Neoverse!” I thumped, then hopped away!

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.04110% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.87%. Comparing base (0b6b275) to head (c418b55).

Files with missing lines Patch % Lines
...n/platform/unix/netbsd/NetBsdCentralProcessor.java 77.41% 5 Missing and 2 partials ⚠️
.../src/main/java/oshi/hardware/CentralProcessor.java 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3818      +/-   ##
============================================
- Coverage     80.92%   80.87%   -0.05%     
  Complexity      674      674              
============================================
  Files           725      725              
  Lines         26045    26090      +45     
  Branches       4422     4428       +6     
============================================
+ Hits          21076    21100      +24     
- Misses         2757     2774      +17     
- Partials       2212     2216       +4     
Flag Coverage Δ
freebsd 37.26% <79.45%> (+0.12%) ⬆️
linux 41.26% <78.08%> (+0.11%) ⬆️
macos 42.40% <78.08%> (+0.07%) ⬆️
netbsd 36.61% <89.04%> (+0.16%) ⬆️
openbsd 37.13% <79.45%> (+0.11%) ⬆️
solaris 38.42% <79.45%> (+0.11%) ⬆️
windows 48.65% <78.08%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis
dbwiddis merged commit f7714d5 into oshi:master Oct 17, 2026
20 checks passed
@dbwiddis
dbwiddis deleted the netbsd-arm-cpu branch October 17, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant