[compiler-rt] r339869 - [XRay][compiler-rt] Remove MAP_NORESERVE from XRay allocations
Dean Michael Berris via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 16 05:19:04 PDT 2018
Author: dberris
Date: Thu Aug 16 05:19:03 2018
New Revision: 339869
URL: http://llvm.org/viewvc/llvm-project?rev=339869&view=rev
Log:
[XRay][compiler-rt] Remove MAP_NORESERVE from XRay allocations
Summary:
This reverses an earlier decision to allow seg-faulting from the
XRay-allocated memory if it turns out that the system cannot provide
physical memory backing that cannot be swapped in/out on Linux.
This addresses http://llvm.org/PR38588.
Reviewers: eizan
Reviewed By: eizan
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D50831
Modified:
compiler-rt/trunk/lib/xray/xray_allocator.h
compiler-rt/trunk/lib/xray/xray_buffer_queue.cc
Modified: compiler-rt/trunk/lib/xray/xray_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_allocator.h?rev=339869&r1=339868&r2=339869&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_allocator.h (original)
+++ compiler-rt/trunk/lib/xray/xray_allocator.h Thu Aug 16 05:19:03 2018
@@ -21,14 +21,9 @@
#include "sanitizer_common/sanitizer_mutex.h"
#include "sanitizer_common/sanitizer_posix.h"
#include "xray_utils.h"
-#include <sys/mman.h>
#include <cstddef>
#include <cstdint>
-
-#ifndef MAP_NORESERVE
-// no-op on NetBSD (at least), unsupported flag on FreeBSD basically because unneeded
-#define MAP_NORESERVE 0
-#endif
+#include <sys/mman.h>
namespace __xray {
@@ -69,7 +64,7 @@ private:
if (UNLIKELY(BackingStore == nullptr)) {
BackingStore = reinterpret_cast<void *>(
internal_mmap(NULL, MaxMemory, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, 0, 0));
+ MAP_PRIVATE | MAP_ANONYMOUS, 0, 0));
if (BackingStore == MAP_FAILED) {
BackingStore = nullptr;
if (Verbosity())
Modified: compiler-rt/trunk/lib/xray/xray_buffer_queue.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_buffer_queue.cc?rev=339869&r1=339868&r2=339869&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_buffer_queue.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_buffer_queue.cc Thu Aug 16 05:19:03 2018
@@ -19,33 +19,14 @@
#include <memory>
#include <sys/mman.h>
-#ifndef MAP_NORESERVE
-// no-op on NetBSD (at least), unsupported flag on FreeBSD
-#define MAP_NORESERVE 0
-#endif
-
using namespace __xray;
using namespace __sanitizer;
template <class T> static T *allocRaw(size_t N) {
// TODO: Report errors?
- // We use MAP_NORESERVE on platforms where it's supported to ensure that the
- // pages we're allocating for XRay never end up in pages that can be swapped
- // in/out. We're doing this because for FDR mode, we want to ensure that
- // writes to the buffers stay resident in memory to prevent XRay itself from
- // causing swapping/thrashing.
- //
- // In the case when XRay pages cannot be swapped in/out or there's not enough
- // RAM to back these pages, we're willing to cause a segmentation fault
- // instead of introducing latency in the measurement. We assume here that
- // there are enough pages that are swappable in/out outside of the buffers
- // being used by FDR mode (which are bounded and configurable anyway) to allow
- // us to keep using always-resident memory.
- //
- // TODO: Make this configurable?
void *A = reinterpret_cast<void *>(
internal_mmap(NULL, N * sizeof(T), PROT_WRITE | PROT_READ,
- MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0));
+ MAP_ANONYMOUS | MAP_PRIVATE, -1, 0));
return (A == MAP_FAILED) ? nullptr : reinterpret_cast<T *>(A);
}
More information about the llvm-commits
mailing list