diff options
author | Alex Shlyapnikov <alekseys@google.com> | 2017-11-03 23:31:00 +0000 |
---|---|---|
committer | Alex Shlyapnikov <alekseys@google.com> | 2017-11-03 23:31:00 +0000 |
commit | 32224fe842a61b490080c2ecdaf655881b1f6a99 (patch) | |
tree | 0dfb92f12e44ebf4c450c1ea1c63cbb36b23cc9d | |
parent | 91b4790b33eb0f484bf3f7c07fb4f6e24d9fd098 (diff) | |
download | bcm5719-llvm-32224fe842a61b490080c2ecdaf655881b1f6a99.tar.gz bcm5719-llvm-32224fe842a61b490080c2ecdaf655881b1f6a99.zip |
[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
llvm-svn: 317386
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h index b22f3aba9ca..630ae358e99 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h +++ b/compiler-rt/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; |