Skip to content

Commit

Permalink
Always write to *error from PerfCounters::stop() if error is no…
Browse files Browse the repository at this point in the history
…n-null
  • Loading branch information
rocallahan committed Mar 17, 2024
1 parent a923064 commit dbaa5b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/PerfCounters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,9 @@ void PerfCounters::close() {

Ticks PerfCounters::stop(Task* t, Error* error) {
if (!counting) {
if (error) {
*error = Error::None;
}
return 0;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
13 changes: 10 additions & 3 deletions src/PerfCounters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dbaa5b9

Please sign in to comment.