diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2017-12-13 16:23:54 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2017-12-13 16:23:54 +0000 |
commit | ad977cc9521dd2e264a2cdcbba3b2afc5084d0d3 (patch) | |
tree | 58bcbf560f646e8ee54971713dbd3ffa0cad8312 /lib/scudo/scudo_allocator.cpp | |
parent | 51bfa63ac5b93a2dedd68044f32ded4cfb0594f9 (diff) |
[sanitizer] Introduce a vDSO aware timing function
Summary:
See D40657 & D40679 for previous versions of this patch & description.
A couple of things were fixed here to have it not break some bots.
Weak symbols can't be used with `SANITIZER_GO` so the previous version was
breakin TsanGo. I set up some additional local tests and those pass now.
I changed the workaround for the glibc vDSO issue: `__progname` is initialized
after the vDSO and is actually public and of known type, unlike
`__vdso_clock_gettime`. This works better, and with all compilers.
The rest is the same.
Reviewers: alekseyshl
Reviewed By: alekseyshl
Subscribers: srhines, kubamracek, krytarowski, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D41121
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320594 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/scudo/scudo_allocator.cpp')
-rw-r--r-- | lib/scudo/scudo_allocator.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/scudo/scudo_allocator.cpp b/lib/scudo/scudo_allocator.cpp index d7df317ff..47804c44c 100644 --- a/lib/scudo/scudo_allocator.cpp +++ b/lib/scudo/scudo_allocator.cpp @@ -301,7 +301,7 @@ struct ScudoAllocator { CheckRssLimit = HardRssLimitMb || SoftRssLimitMb; if (CheckRssLimit) - atomic_store_relaxed(&RssLastCheckedAtNS, NanoTime()); + atomic_store_relaxed(&RssLastCheckedAtNS, MonotonicNanoTime()); } // Helper function that checks for a valid Scudo chunk. nullptr isn't. @@ -319,7 +319,7 @@ struct ScudoAllocator { // it can, every 100ms, otherwise it will just return the current one. bool isRssLimitExceeded() { u64 LastCheck = atomic_load_relaxed(&RssLastCheckedAtNS); - const u64 CurrentCheck = NanoTime(); + const u64 CurrentCheck = MonotonicNanoTime(); if (LIKELY(CurrentCheck < LastCheck + (100ULL * 1000000ULL))) return atomic_load_relaxed(&RssLimitExceeded); if (!atomic_compare_exchange_weak(&RssLastCheckedAtNS, &LastCheck, |