Changeset 221548 in webkit


Ignore:
Timestamp:
Sep 3, 2017 3:31:29 AM (7 years ago)
Author:
Yusuke Suzuki
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):

Location:
trunk/Source/bmalloc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r221422 r221548  
     12017-09-03  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Large virtual memory region allocation requires MMAP_NORESERVE in Linux
     4        https://bugs.webkit.org/show_bug.cgi?id=176211
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        In Linux, we cannot allocate very large memory region without MMAP_NORESERVE.
     9        Linux kernel needs to reserve swap area for allocated memory region. If the
     10        swap area is exhausted, kernel fails to allocate the memory region with ENOMEM.
     11
     12        This patch adds MMAP_NORESERVE to mmap flags in Linux. By adding this flag,
     13        mmap does not need to reserve swap area for the reserved memory region.
     14        This allows us to reserve very large memory region that is necessary for Gigacage.
     15
     16        * bmalloc/BPlatform.h:
     17        * bmalloc/VMAllocate.h:
     18        (bmalloc::tryVMAllocate):
     19
    1202017-08-22  Filip Pizlo  <fpizlo@apple.com>
    221
  • trunk/Source/bmalloc/bmalloc/BPlatform.h

    r221213 r221548  
    4343#endif
    4444
     45#ifdef __linux__
     46#define BOS_LINUX 1
     47#endif
     48
    4549#if defined(WIN32) || defined(_WIN32)
    4650#define BOS_WINDOWS 1
  • trunk/Source/bmalloc/bmalloc/VMAllocate.h

    r219055 r221548  
    4545#if BOS(DARWIN)
    4646#define BMALLOC_VM_TAG VM_MAKE_TAG(VM_MEMORY_TCMALLOC)
    47 #else
     47#define BMALLOC_NORESERVE 0
     48#elif BOS(LINUX)
    4849#define BMALLOC_VM_TAG -1
     50#define BMALLOC_NORESERVE MAP_NORESERVE
     51#else
     52#define BMALLOC_VM_TAG -1
     53#define BMALLOC_NORESERVE 0
    4954#endif
    5055
     
    117122{
    118123    vmValidate(vmSize);
    119     void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, BMALLOC_VM_TAG, 0);
     124    void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
    120125    if (result == MAP_FAILED) {
    121126        logVMFailure();
Note: See TracChangeset for help on using the changeset viewer.