1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:17:35 +00:00

Kernel: Add MAP_NORESERVE support to mmap

Rather than lazily committing regions by default, we now commit
the entire region unless MAP_NORESERVE is specified.

This solves random crashes in low-memory situations where e.g. the
malloc heap allocated memory, but using pages that haven't been
used before triggers a crash when no more physical memory is available.

Use this flag to create large regions without actually committing
the backing memory. madvise() can be used to commit arbitrary areas
of such regions after creating them.
This commit is contained in:
Tom 2020-09-03 15:06:25 -06:00 committed by Andreas Kling
parent bc5d6992a4
commit c3451899bc
7 changed files with 30 additions and 15 deletions

View file

@ -93,6 +93,7 @@ enum {
#define MAP_ANON MAP_ANONYMOUS
#define MAP_STACK 0x40
#define MAP_PURGEABLE 0x80
#define MAP_NORESERVE 0x100
#define PROT_READ 0x1
#define PROT_WRITE 0x2