summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2017-11-03 23:31:00 +0000
committerAlex Shlyapnikov <alekseys@google.com>2017-11-03 23:31:00 +0000
commit5167a32ff3c3f9c0d99df348610b8e4aaf707be2 (patch)
treeb60c389839c1968cb79041312276bd2045defd8b
parentef40253e3d57a0398fa52dc371c11f383192235f (diff)
downloadcompiler-rt-5167a32ff3c3f9c0d99df348610b8e4aaf707be2.tar.gz
[Sanitizers] Call NanoTime() conditionally.
Summary: Call NanoTime() in primary 64 bit allocator only when necessary, otherwise the unwarranted syscall causes problems in sandbox environments. ReleaseToOSIntervalMs() conditional allows them to turn the feature off with allocator_release_to_os_interval_ms=-1 flag. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D39624 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317386 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_primary64.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_primary64.h b/lib/sanitizer_common/sanitizer_allocator_primary64.h
index b22f3aba9..630ae358e 100644
--- a/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -677,7 +677,10 @@ class SizeClassAllocator64 {
// preventing just allocated memory from being released sooner than
// necessary and also preventing extraneous ReleaseMemoryPagesToOS calls
// for short lived processes.
- region->rtoi.last_release_at_ns = NanoTime();
+ // Do it only when the feature is turned on, to avoid a potentially
+ // extraneous syscall.
+ if (ReleaseToOSIntervalMs() >= 0)
+ region->rtoi.last_release_at_ns = NanoTime();
}
// Do the mmap for the user memory.
uptr map_size = kUserMapSize;