Title: [221548] trunk/Source/bmalloc
- Revision
- 221548
- Author
- [email protected]
- Date
- 2017-09-03 03:31:29 -0700 (Sun, 03 Sep 2017)
Log Message
Large virtual memory region allocation requires MMAP_NORESERVE in Linux
https://bugs.webkit.org/show_bug.cgi?id=176211
Reviewed by Geoffrey Garen.
In Linux, we cannot allocate very large memory region without MMAP_NORESERVE.
Linux kernel needs to reserve swap area for allocated memory region. If the
swap area is exhausted, kernel fails to allocate the memory region with ENOMEM.
This patch adds MMAP_NORESERVE to mmap flags in Linux. By adding this flag,
mmap does not need to reserve swap area for the reserved memory region.
This allows us to reserve very large memory region that is necessary for Gigacage.
* bmalloc/BPlatform.h:
* bmalloc/VMAllocate.h:
(bmalloc::tryVMAllocate):
Modified Paths
Diff
Modified: trunk/Source/bmalloc/ChangeLog (221547 => 221548)
--- trunk/Source/bmalloc/ChangeLog 2017-09-03 08:42:11 UTC (rev 221547)
+++ trunk/Source/bmalloc/ChangeLog 2017-09-03 10:31:29 UTC (rev 221548)
@@ -1,3 +1,22 @@
+2017-09-03 Yusuke Suzuki <[email protected]>
+
+ Large virtual memory region allocation requires MMAP_NORESERVE in Linux
+ https://bugs.webkit.org/show_bug.cgi?id=176211
+
+ Reviewed by Geoffrey Garen.
+
+ In Linux, we cannot allocate very large memory region without MMAP_NORESERVE.
+ Linux kernel needs to reserve swap area for allocated memory region. If the
+ swap area is exhausted, kernel fails to allocate the memory region with ENOMEM.
+
+ This patch adds MMAP_NORESERVE to mmap flags in Linux. By adding this flag,
+ mmap does not need to reserve swap area for the reserved memory region.
+ This allows us to reserve very large memory region that is necessary for Gigacage.
+
+ * bmalloc/BPlatform.h:
+ * bmalloc/VMAllocate.h:
+ (bmalloc::tryVMAllocate):
+
2017-08-22 Filip Pizlo <[email protected]>
Strings need to be in some kind of gigacage
Modified: trunk/Source/bmalloc/bmalloc/BPlatform.h (221547 => 221548)
--- trunk/Source/bmalloc/bmalloc/BPlatform.h 2017-09-03 08:42:11 UTC (rev 221547)
+++ trunk/Source/bmalloc/bmalloc/BPlatform.h 2017-09-03 10:31:29 UTC (rev 221548)
@@ -42,6 +42,10 @@
#define BOS_UNIX 1
#endif
+#ifdef __linux__
+#define BOS_LINUX 1
+#endif
+
#if defined(WIN32) || defined(_WIN32)
#define BOS_WINDOWS 1
#endif
Modified: trunk/Source/bmalloc/bmalloc/VMAllocate.h (221547 => 221548)
--- trunk/Source/bmalloc/bmalloc/VMAllocate.h 2017-09-03 08:42:11 UTC (rev 221547)
+++ trunk/Source/bmalloc/bmalloc/VMAllocate.h 2017-09-03 10:31:29 UTC (rev 221548)
@@ -44,8 +44,13 @@
#if BOS(DARWIN)
#define BMALLOC_VM_TAG VM_MAKE_TAG(VM_MEMORY_TCMALLOC)
+#define BMALLOC_NORESERVE 0
+#elif BOS(LINUX)
+#define BMALLOC_VM_TAG -1
+#define BMALLOC_NORESERVE MAP_NORESERVE
#else
#define BMALLOC_VM_TAG -1
+#define BMALLOC_NORESERVE 0
#endif
inline size_t vmPageSize()
@@ -116,7 +121,7 @@
inline void* tryVMAllocate(size_t vmSize)
{
vmValidate(vmSize);
- void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, BMALLOC_VM_TAG, 0);
+ void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
if (result == MAP_FAILED) {
logVMFailure();
return nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes