feat(hwmon): add IIO power meter fallback for Jetson Nano#2438
feat(hwmon): add IIO power meter fallback for Jetson Nano#2438noFlowWater wants to merge 2 commits intosustainable-computing-io:mainfrom
Conversation
Add support for reading power data from the Linux IIO subsystem as a
fallback when hwmon power sensors are not available. This enables Kepler
to monitor power consumption on NVIDIA Jetson Nano devices where the
INA3221 power monitor chip is bound to the ina3221x IIO driver (L4T R32,
kernel 4.9) instead of the upstream ina3221 hwmon driver (L4T R35+).
The implementation introduces:
- sysfsIIOReader: implements hwmonReader interface, scans
/sys/bus/iio/devices/ for IIO power sensors (in_power{N}_input)
- iioPowerZone: implements EnergyZone interface with mW to µW conversion
- compositeReader: tries hwmon first, falls back to IIO, combining zones
from all available readers
IIO power sensors report milliwatts while hwmon uses microwatts. The
iioPowerZone.Power() method handles this conversion transparently.
Tested on real hardware:
- Jetson Nano (L4T R32): IIO fallback discovers 3 zones (POM_5V_IN,
POM_5V_GPU, POM_5V_CPU), reads power correctly
- Jetson AGX Orin (L4T R35): hwmon path unchanged, no regression
- Jetson Xavier NX (L4T R35): hwmon path unchanged, no regression
Signed-off-by: noFlowWater <noyusu98@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2438 +/- ##
==========================================
- Coverage 91.83% 91.51% -0.33%
==========================================
Files 55 56 +1
Lines 5857 5984 +127
==========================================
+ Hits 5379 5476 +97
- Misses 343 363 +20
- Partials 135 145 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
📊 Profiling reports are ready to be viewed
💻 CPU Comparison with base Kepler💾 Memory Comparison with base Kepler (Inuse)💾 Memory Comparison with base Kepler (Alloc)⬇️ Download the Profiling artifacts from the Actions Summary page 📦 Artifact name: 🔧 Or use GitHub CLI to download artifacts: gh run download 23001898484 -n profile-artifacts-2438 |
Pre-commit end-of-file-fixer requires all files to end with a newline. Signed-off-by: noFlowWater <noyusu98@gmail.com>
|
📊 Profiling reports are ready to be viewed
💻 CPU Comparison with base Kepler💾 Memory Comparison with base Kepler (Inuse)💾 Memory Comparison with base Kepler (Alloc)⬇️ Download the Profiling artifacts from the Actions Summary page 📦 Artifact name: 🔧 Or use GitHub CLI to download artifacts: gh run download 23058951663 -n profile-artifacts-2438 |
|
@vimalk78 are you able to see if this works on your nvidia jetson machine? - specifically this: Jetson Nano (L4T R32) |
Summary
Add Linux IIO subsystem support as a fallback power data source when hwmon sensors are unavailable. This enables Kepler to monitor power on NVIDIA Jetson Nano (L4T R32) where the INA3221 chip uses the
ina3221xIIO driver instead of theina3221hwmon driver.Problem
Kepler's hwmon power meter scans
/sys/class/hwmon/for power sensors. On Jetson Nano (L4T R32, kernel 4.9), the INA3221 power monitor is bound to NVIDIA's custom IIO driver (ina3221x) rather than the upstream hwmon driver (ina3221). This means Kepler finds no power zones and cannot attribute energy to containers.ina3221(hwmon)ina3221(hwmon)ina3221x(IIO)Solution
sysfsIIOReader: ImplementshwmonReaderinterface, scans/sys/bus/iio/devices/forin_power{N}_inputsensorsiioPowerZone: ImplementsEnergyZoneinterface with mW→µW conversion (IIO reports milliwatts, hwmon uses microwatts)compositeReader: Wraps both hwmon and IIO readers; tries hwmon first, falls back to IIO, combines zones from all available sourcesNo API changes —
NewHwmonPowerMeter()signature and behavior are unchanged for existing hwmon-only systems.IIO Sensor Layout (Jetson Nano)
Downstream Compatibility
IIO zones only support
Power()(notEnergy()). This works becauseinternal/monitor/node.goalready handles power-only zones:MaxEnergy() > 0 || energyReading > 0E = P × Δtover collection intervalsNo code path requires
Energy()to succeed.Hardware Testing
Verified on 3 Jetson devices with cross-compiled arm64 binary:
Changes
internal/device/iio_power_meter.gosysfsIIOReader+iioPowerZone(~205 LOC)internal/device/iio_power_meter_test.gointernal/device/hwmon_power_meter.gocompositeReader, updateNewHwmonPowerMeterto use it (~80 LOC changed)internal/device/hwmon_power_meter_test.goiioPowerZonecase toTestHwmonPowerMeter_ZoneDetailsinternal/device/testdata/sys/bus/iio/Test Plan
internal/device/tests pass with-racego build ./...succeeds