Created
August 25, 2011 16:11
-
-
Save pietern/1171054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/deps/jemalloc/src/chunk_mmap.c b/deps/jemalloc/src/chunk_mmap.c | |
index 164e86e..c2ce465 100644 | |
--- a/deps/jemalloc/src/chunk_mmap.c | |
+++ b/deps/jemalloc/src/chunk_mmap.c | |
@@ -48,9 +48,25 @@ pages_map(void *addr, size_t size, bool noreserve) | |
if (noreserve) | |
flags |= MAP_NORESERVE; | |
#endif | |
+ | |
+#ifdef MAP_HUGETLB | |
+ flags |= MAP_HUGETLB; | |
+#endif | |
ret = mmap(addr, size, PROT_READ | PROT_WRITE, flags, -1, 0); | |
assert(ret != NULL); | |
+#ifdef MAP_HUGETLB | |
+ /* | |
+ * Retry on ENOMEM when we tried to map using huge pages. | |
+ * This strategy is far from optimal, needs way more heuristics... | |
+ */ | |
+ if (ret == MAP_FAILED && errno == ENOMEM) { | |
+ flags &= ~MAP_HUGETLB; | |
+ ret = mmap(addr, size, PROT_READ | PROT_WRITE, flags, -1, 0); | |
+ assert(ret != NULL); | |
+ } | |
+#endif | |
+ | |
if (ret == MAP_FAILED) | |
ret = NULL; | |
else if (addr != NULL && ret != addr) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment