diff --git a/src/PerfCounters.cc b/src/PerfCounters.cc index d49a419640d..0f77a20085b 100644 --- a/src/PerfCounters.cc +++ b/src/PerfCounters.cc @@ -956,6 +956,9 @@ void PerfCounters::close() { Ticks PerfCounters::stop(Task* t, Error* error) { if (!counting) { + if (error) { + *error = Error::None; + } return 0; } @@ -996,6 +999,10 @@ Ticks PerfCounters::ticks_for_direct_call(Task*) { } Ticks PerfCounters::read_ticks(Task* t, Error* error) { + if (error) { + *error = Error::None; + } + ASSERT(t, opened); ASSERT(t, counting); ASSERT(t, counting_period > 0); @@ -1077,10 +1084,6 @@ Ticks PerfCounters::read_ticks(Task* t, Error* error) { ASSERT(t, false) << "Detected " << ret << " ticks, expected no more than " << adjusted_counting_period; } - } else { - if (error) { - *error = Error::None; - } } return ret; } diff --git a/src/PerfCounters.h b/src/PerfCounters.h index 7bbbe9ef43b..744c9d6daad 100644 --- a/src/PerfCounters.h +++ b/src/PerfCounters.h @@ -105,9 +105,10 @@ class PerfCounters { * Suspend counting until the next start. * Returns the current value of the ticks counter. * `t` is used for debugging purposes. - * If `error` is non-null and a transient error is detected, - * `*error` will be set to `Error::Transient`. If `error` is null - * and a transient error is detected, it will be treated as fatal. + * If `error` is non-null,`*error` will be set to `Error::Transient` + * if a transient error is detected, otherwise `Error::None`. + * If `error` is null and a transient error is detected, it will be + * treated as fatal. */ Ticks stop(Task* t, Error* error = nullptr); @@ -184,6 +185,12 @@ class PerfCounters { */ uint32_t recording_skid_size() { return skid_size() * 5; } + /** + * If `error` is non-null,`*error` will be set to `Error::Transient` + * if a transient error is detected, otherwise `Error::None`. + * If `error` is null and a transient error is detected, it will be + * treated as fatal. + */ Ticks read_ticks(Task* t, Error* error); // Only valid while 'counting' is true