Skip to content

Fix Solaris Kstat2 CPU vendor frequency reported in MHz instead of Hz - #3519

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:fix-solaris-kstat2-freq
Jul 22, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:fix-solaris-kstat2-freq

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes the Solaris JNA Kstat2 processor identifier reporting the CPU vendor frequency in MHz instead of Hz.

SolarisCentralProcessorJNA.queryProcessorId2() (the Kstat2 path) read the clock_MHz kstat value and passed it straight to ProcessorIdentifier as the vendor frequency, omitting the * 1_000_000L conversion to Hz that both sibling code paths apply:

  • the non-Kstat2 path in the same class (queryProcessorId()), and
  • the FFM implementation (SolarisCentralProcessorFFM.queryProcessorId()).

On a SPARC system this reported a ~5067 Hz vendor frequency against a ~5.07 GHz max frequency.

// before
long cpuFreq = results[5] == null ? 0L : (long) results[5];
// after
long cpuFreq = results[5] == null ? 0L : (long) results[5] * 1_000_000L;

How it was found

Caught by the CentralProcessorTest.testVendorFreqSanity() assertion added in #3518 (vendor and max frequency must be within an order of magnitude) — the FreeBSD sysctl fix's regression test surfaced this pre-existing Solaris bug.

Testing

This is a cfarm-only path: HAS_KSTAT2 is false on the OpenIndiana x86 CI runner, so the Kstat2 branch is only exercised on real Solaris. Verified by inspection against the two sibling paths that already perform the MHz→Hz conversion. Builds clean (checkstyle, forbiddenapis, javadoc).

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Solaris CPU identification so processor frequencies are reported in hertz rather than megahertz.
    • Improved the accuracy of CPU information displayed to users on Solaris systems.

SolarisCentralProcessorJNA.queryProcessorId2() (the Kstat2 path) read
clock_MHz and passed it straight to ProcessorIdentifier as the vendor
frequency, omitting the * 1_000_000L conversion to Hz that both the
non-Kstat2 path in the same class and the FFM implementation apply. On a
SPARC system this reported a ~5067 Hz vendor frequency against a ~5.07 GHz
max.

Caught by the CentralProcessorTest.testVendorFreqSanity() assertion added
in #3518 (vendor and max frequency must be within an order of magnitude).
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a311c7a6-b4f1-4918-a6f0-96af05d4872f

📥 Commits

Reviewing files that changed from the base of the PR and between 5d304e0 and 9aaa939.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (9)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.java
🔇 Additional comments (2)
oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.java (1)

82-84: LGTM!

CHANGELOG.md (1)

11-11: LGTM!


📝 Walkthrough

Walkthrough

Changes

Solaris processor frequency correction

Layer / File(s) Summary
Kstat2 frequency conversion
oshi-core/src/main/java/oshi/hardware/platform/unix/solaris/SolarisCentralProcessorJNA.java, CHANGELOG.md
queryProcessorId2 converts CPU frequency from MHz to Hz before creating the processor identifier, and the fix is recorded in the changelog.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A rabbit hops through MHz with glee,
Then multiplies by one million precisely.
Solaris now reports Hz just right,
With changelog carrots tucked in sight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing Solaris Kstat2 CPU frequency units from MHz to Hz.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@dbwiddis
dbwiddis merged commit f403790 into oshi:master Jul 22, 2026
23 of 24 checks passed
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.28%. Comparing base (5d304e0) to head (9aaa939).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...tform/unix/solaris/SolarisCentralProcessorJNA.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3519      +/-   ##
============================================
- Coverage     78.36%   78.28%   -0.08%     
- Complexity     3817     4099     +282     
============================================
  Files           697      697              
  Lines         24104    24104              
  Branches       3994     3994              
============================================
- Hits          18888    18869      -19     
- Misses         3018     3043      +25     
+ Partials       2198     2192       -6     
Flag Coverage Δ
freebsd 31.11% <0.00%> (-0.02%) ⬇️
linux 35.03% <0.00%> (-0.02%) ⬇️
macos 35.99% <0.00%> (-0.04%) ⬇️
openbsd 30.31% <0.00%> (-0.01%) ⬇️
solaris 31.57% <0.00%> (+<0.01%) ⬆️
windows 43.18% <0.00%> (+0.02%) ⬆️

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 deleted the fix-solaris-kstat2-freq branch July 22, 2026 21:40
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