Repository navigation
fix(sensors): handle RAPL energy counter wraparound - #445
Open
manunicholasjacob wants to merge 1 commit into
Open
manunicholasjacob wants to merge 1 commit into
manunicholasjacob wants to merge 1 commit into
Conversation
powercap energy_uj counters wrap to 0 after max_energy_range_uj. Read that range for socket, domain and psys zones in generate_topology, and use a counter_delta helper in the power and energy diff functions so a wrap gives the real delta. When the range is unknown, the socket path now returns None instead of reporting 0 W. Fixes hubblo-org#280 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: manunicholasjacob <manunicholasjacob@gmail.com>
This branch has not been deployed
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.
Fixes #280
What: powercap
energy_ujcounters wrap to 0 aftermax_energy_range_uj, which scaphandre never read. On a wrap, socket power showed 0 W and domain and host power returned nothing.How:
generate_topologystores each zone'smax_energy_range_uj(socket, domain, psys). A purecounter_delta(prev, last, max)returns(max - prev) + laston a wrap andNoneif the range is unknown; it is used in the threeget_records_diff_power_microwattsandTopology::get_records_diff. A host sum of PKG + DRAM has no single range, so it still returnsNoneon a drop; that sum is also whatscaph_host_energy_microjoulesexports, maybe related to #324 (unchanged).Tests: 5 new unit tests, including a fake powercap tree via
SCAPHANDRE_POWERCAP_PATH(--vm). fmt and the CI clippy command pass. In WSL2 (no powercap), the same 5 hardware tests fail on dev and on this branch. No real RAPL wrap reproduced.AI-assisted: written with Claude (Anthropic); tests run locally.