This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Use fast get time in secondary.
ClosedPublic

Authored by cferris on Jun 28 2023, 2:40 PM.

Details

Summary

When I moved the primary to use the faster get time syscall, I missed
the secondary use. Now fix the secondary to use this function too.

Diff Detail

Event Timeline

cferris created this revision.Jun 28 2023, 2:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 2:40 PM
Herald added subscribers: yaneury, Enna1. · View Herald Transcript
cferris requested review of this revision.Jun 28 2023, 2:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 2:40 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
Chia-hungDuan accepted this revision.Jun 28 2023, 2:56 PM

Just did a quick glance in the use of getMonotonicTime(). There is one place I think we may want to evaluate switching to getMonotonicTimeFast() too. Which is in tsd.h

inline bool tryLock() NO_THREAD_SAFETY_ANALYSIS {
  if (Mutex.tryLock()) {
    atomic_store_relaxed(&Precedence, 0);
    return true;
  }
  if (atomic_load_relaxed(&Precedence) == 0)
    atomic_store_relaxed(
        &Precedence,
        static_cast<uptr>(getMonotonicTime() >> FIRST_32_SECOND_64(16, 0)));
  return false;
}

https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/scudo/standalone/tsd.h#L46

(In timing.h, it may be also a candidate, but it's minor)

It's not necessary to be included in this change anyway, LGTM!

This revision is now accepted and ready to land.Jun 28 2023, 2:56 PM
This revision was automatically updated to reflect the committed changes.