Tell a restarted energy counter from one that wrapped - #519
Open
fvaleye wants to merge 1 commit into
Open
Conversation
fvaleye
force-pushed
the
fl/read-the-cumulative-energy-counters
branch
17 times, most recently
from
August 31, 2026 12:00
6792061 to
15503ff
Compare
A RAPL counter reads lower than it did before both when it rolls over and when a module reload restarts it. Correcting either as a roll credits the zone a whole range it never drew: on the fixture hardware one 60 s interval reports 498 W and 8.3 Wh that never happened, which reaches the exporters as carbon. The most power a zone can reach tells the two apart. A zone reporting more than that across the interval was restarted rather than wrapped, and is left out of that measurement rather than reported. Powercap answers the second constraint with that maximum and the first with the thermal spec, which a host holding a turbo or raising its long term limit sustains right past, so the second is asked first. Neither can be written, so the answer is read once per zone and kept. A zone nested inside another is bounded by it, so one publishing no maximum of its own takes the one enclosing it. Without that the dram zone stayed uncorrected while the package around it was skipped, and dram feeds the same host figure. This bounds what a restart can invent to the maximum across one interval rather than removing it. A restart implying a draw the hardware could have reached is still read as a roll, and a gap long enough to allow a whole range, such as a resume from a long suspend, allows it again. The domains are read through one table rather than four accumulators, which also keeps a usage type totalling below zero from reaching the exporters.
fvaleye
force-pushed
the
fl/read-the-cumulative-energy-counters
branch
from
August 31, 2026 12:06
15503ff to
5a97d7f
Compare
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.
Description
A RAPL counter can move backward when it wraps or when a powercap module reload resets it.
Tracarbon treats both as wraparound.
With the fixture values, a reset converts one 60-second sample from 498 W to 498 W and adds 8.3 Wh, which exporters then convert to carbon.
This change compares the wrap-adjusted delta with the zone's published maximum power over the actual elapsed time. When the delta is higher, Tracarbon skips the sample and uses the current reading as the next baseline. A package reset also skips its child zones for that sample, without borrowing the package limit for the separate DRAM power plane. Published limits are read once per zone. Zones that publish none keep the existing wraparound behavior.