Skip to content

Disambiguate hwmon chips with duplicate names (#33) - #52

Merged
eous merged 2 commits into
mainfrom
fix/hwmon-duplicate-chip-names
Mar 31, 2026
Merged

eous merged 2 commits into
mainfrom
fix/hwmon-duplicate-chip-names

Conversation

@eous

@eous eous commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

When multiple hwmon sysfs devices share the same name (e.g. jc42 DIMM temp sensors, multiple NVMe drives), they produced identical SensorIds and collided in the HashMap — only one reading survived.

Detect duplicate chip names during discovery and append the sysfs device symlink basename to disambiguate (e.g. jc42-9-0018, nvme-nvme0). Falls back to the hwmon directory index when no device symlink exists.

Also fixes is_gpu_hwmon_chip to use prefix matching so multi-GPU systems still get "GPU " label prefixes, and pre-expands board template label overrides so unqualified names continue to match disambiguated chips.

#33

When multiple hwmon sysfs devices share the same name (e.g. jc42 DIMM
temp sensors, multiple NVMe drives), they produced identical SensorIds
and collided in the HashMap — only one reading survived.

Detect duplicate chip names during discovery and append the sysfs device
symlink basename to disambiguate (e.g. jc42-9-0018, nvme-nvme0). Falls
back to the hwmon directory index when no device symlink exists.

Also fixes is_gpu_hwmon_chip to use prefix matching so multi-GPU systems
still get "GPU " label prefixes, and pre-expands board template label
overrides so unqualified names continue to match disambiguated chips.

#33
Copilot AI review requested due to automatic review settings March 30, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses hwmon sensor ID collisions when multiple sysfs hwmon devices share the same name (e.g., multiple jc42 DIMM sensors or multiple NVMe drives), ensuring each sensor remains uniquely addressable and readable across discovery/polling.

Changes:

  • Detects duplicate hwmon chip names during discovery and disambiguates them by appending a sysfs-derived suffix (device symlink basename, with a fallback).
  • Updates GPU hwmon chip detection to also match disambiguated multi-GPU chip names (prefix match).
  • Pre-expands board-template label overrides so existing unqualified overrides continue to apply after chip disambiguation.
Comments suppressed due to low confidence (1)

src/sensors/hwmon.rs:154

  • discover_type for current sensors is still passed label_overrides instead of the newly built effective_overrides. For disambiguated chips (e.g. jc42-9-0018), this prevents board template label overrides from applying to curr* sensors and makes behavior inconsistent with temp/fan/in/power discovery. Pass &effective_overrides here as well.
            discover_type(
                hwmon_dir,
                display_name,
                "curr",
                SensorCategory::Current,
                SensorUnit::Amps,
                1000.0,
                label_overrides,
                &mut entries,
            );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sensors/hwmon.rs Outdated
Comment thread src/sensors/hwmon.rs
- Avoid allocation in is_gpu_hwmon_chip by using strip_prefix instead
  of format!
- Fix curr sensor discovery passing original label_overrides instead
  of effective_overrides
- Extract expand_label_overrides as a pure testable function
- Add unit tests for label override expansion (no duplicates, with
  duplicates, qualified precedence)
@eous
eous merged commit 42edde5 into main Mar 31, 2026
6 checks passed
@eous
eous deleted the fix/hwmon-duplicate-chip-names branch March 31, 2026 00:25
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.

2 participants