[llvm] b785e03 - Support: mapped_file_region: Pass MAP_NORESERVE to mmap
Joseph Tremoulet via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 8 06:07:38 PDT 2021
Author: Joseph Tremoulet
Date: 2021-04-08T09:07:25-04:00
New Revision: b785e03612d76145c58cb31b6fd6911a5e41e8e3
URL: https://github.com/llvm/llvm-project/commit/b785e03612d76145c58cb31b6fd6911a5e41e8e3
DIFF: https://github.com/llvm/llvm-project/commit/b785e03612d76145c58cb31b6fd6911a5e41e8e3.diff
LOG: Support: mapped_file_region: Pass MAP_NORESERVE to mmap
This allows mapping larger files, delaying OOM failures until too many
pages of them are accessed. This is makes the behavior of the
mapped_file_region in this regard consistent between its "Unix" and
"Windows" implementations.
Guard the code witih #if defined(MAP_NORESERVE), consistent with other
uses of MAP_NORESERVE in llvm-project, because some FreeBSD versions do
not provide this flag.
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D96626
Added:
Modified:
llvm/lib/Support/Unix/Path.inc
Removed:
################################################################################
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index bbac8a5b37332..a7e47840078e6 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -815,6 +815,9 @@ std::error_code mapped_file_region::init(int FD, uint64_t Offset,
int flags = (Mode == readwrite) ? MAP_SHARED : MAP_PRIVATE;
int prot = (Mode == readonly) ? PROT_READ : (PROT_READ | PROT_WRITE);
+#if defined(MAP_NORESERVE)
+ flags |= MAP_NORESERVE;
+#endif
#if defined(__APPLE__)
//----------------------------------------------------------------------
// Newer versions of MacOSX have a flag that will allow us to read from
More information about the llvm-commits
mailing list