[compiler-rt] r317386 - [Sanitizers] Call NanoTime() conditionally.

Alex Shlyapnikov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 16:31:00 PDT 2017


Author: alekseyshl
Date: Fri Nov  3 16:31:00 2017
New Revision: 317386

URL: http://llvm.org/viewvc/llvm-project?rev=317386&view=rev
Log:
[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

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h?rev=317386&r1=317385&r2=317386&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h Fri Nov  3 16:31:00 2017
@@ -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;




More information about the llvm-commits mailing list