[haiku-commits] haiku: hrev54152 - src/system/libroot/posix/sys headers/posix/sys

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 8 May 2020 22:57:51 -0400 (EDT)

hrev54152 adds 1 changeset to branch 'master'
old head: 7362b02b0eb5e0e01476ab478120c38fb3996574
new head: b94221f3b29c00321e4fe15fcdf499b7275a389c
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b94221f3b29c+%5E7362b02b0eb5

----------------------------------------------------------------------------

b94221f3b29c: mmap: Use MAP_NORESERVE to request overcommit, not PROT_NONE.
  
  This reverts hrev54120 and instead adds the commonly supported
  MAP_NORESERVE flag to request overcommit.
  
  Using PROT_NONE for overcommit is problematic as the protection of
  individual pages can still be changed via mprotect to make them
  accessible, but that won't change the commitment. An application
  using such a pattern may then unexpectedly run into out of memory
  conditions on random writes into the address space.
  
  With MAP_NORESERVE the overcommit can explicitly be requested by
  applications that want to reserve address space without producing
  memory pressure.
  
  Change-Id: Id213d2245c5e23103e8e0857f7902e0cd8a2c65d
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2611
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
  Reviewed-by: Jérôme Duval <jerome.duval@xxxxxxxxx>

                                            [ Michael Lotz <mmlr@xxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev54152
Commit:      b94221f3b29c00321e4fe15fcdf499b7275a389c
URL:         https://git.haiku-os.org/haiku/commit/?id=b94221f3b29c
Author:      Michael Lotz <mmlr@xxxxxxxx>
Date:        Fri May  8 20:57:07 2020 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat May  9 02:57:48 2020 UTC

----------------------------------------------------------------------------

2 files changed, 4 insertions(+), 2 deletions(-)
headers/posix/sys/mman.h              | 1 +
src/system/libroot/posix/sys/mman.cpp | 5 +++--

----------------------------------------------------------------------------

diff --git a/headers/posix/sys/mman.h b/headers/posix/sys/mman.h
index a69991ac05..40c49c7b5d 100644
--- a/headers/posix/sys/mman.h
+++ b/headers/posix/sys/mman.h
@@ -23,6 +23,7 @@
 #define MAP_FIXED              0x04                    /* require mapping to 
specified addr */
 #define MAP_ANONYMOUS  0x08                    /* no underlying object */
 #define MAP_ANON               MAP_ANONYMOUS
+#define MAP_NORESERVE  0x10                    /* don't commit memory */
 
 /* mmap() error return code */
 #define MAP_FAILED             ((void*)-1)
diff --git a/src/system/libroot/posix/sys/mman.cpp 
b/src/system/libroot/posix/sys/mman.cpp
index 8de57a3dd7..3944538ef9 100644
--- a/src/system/libroot/posix/sys/mman.cpp
+++ b/src/system/libroot/posix/sys/mman.cpp
@@ -131,8 +131,9 @@ mmap(void* address, size_t length, int protection, int 
flags, int fd,
                areaProtection |= B_WRITE_AREA;
        if ((protection & PROT_EXEC) != 0)
                areaProtection |= B_EXECUTE_AREA;
-       if (protection == PROT_NONE)
-               areaProtection = B_OVERCOMMITTING_AREA;
+
+       if ((flags & MAP_NORESERVE) != 0)
+               areaProtection |= B_OVERCOMMITTING_AREA;
 
        // create a name for this area based on calling image
        void* addr = __builtin_return_address(0);


Other related posts:

  • » [haiku-commits] haiku: hrev54152 - src/system/libroot/posix/sys headers/posix/sys - waddlesplash