Frank Ch. Eigler wrote:
cycles_t interval = (cycles_atend > c->cycles_base)
? (cycles_atend - c->cycles_base)
: (STP_OVERLOAD_INTERVAL + 1);
BTW right here is where it will break if the actual hardware counter
is narrower than cycles_t. If cycles_base was set near its overflow
point (which may be much less than 2**63), then even a brief probe
will end up with a cycles_atend < cycles_base. That in turn would
lead to an erroneous overload indication.
It will generate an extra threshold comparison, but the error indication
only occurs if cycles_sum is more than THRESHOLD. This "quick-wrap"
scenario will be a wasted check, since the sum won't have accumulated
much. However, if there's a real problem, it will be caught on the
following interval.