Disambiguate hwmon chips with duplicate names (#33) - #52
Merged
Merged
Conversation
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
There was a problem hiding this comment.
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_typefor current sensors is still passedlabel_overridesinstead of the newly builteffective_overrides. For disambiguated chips (e.g.jc42-9-0018), this prevents board template label overrides from applying tocurr*sensors and makes behavior inconsistent with temp/fan/in/power discovery. Pass&effective_overrideshere 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.
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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