mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
Kernel: Remove MAP_PURGEABLE from mmap
This brings mmap more in line with other operating systems. Prior to this, it was impossible to request memory that was definitely committed, instead MAP_PURGEABLE would provide a region that was not actually purgeable, but also not fully committed, which meant that using such memory still could cause crashes when the underlying pages could no longer be allocated. This fixes some random crashes in low-memory situations where non-volatile memory is mapped (e.g. malloc, tls, Gfx::Bitmap, etc) but when a page in these regions is first accessed, there is insufficient physical memory available to commit a new page.
This commit is contained in:
parent
c3451899bc
commit
e21cc4cff6
6 changed files with 12 additions and 20 deletions
|
@ -437,13 +437,13 @@ Optional<BackingStore> Bitmap::allocate_backing_store(BitmapFormat format, const
|
|||
const auto pitch = minimum_pitch(size.width(), format);
|
||||
const auto data_size_in_bytes = size_in_bytes(pitch, size.height());
|
||||
|
||||
void* data = nullptr;
|
||||
int map_flags = MAP_ANONYMOUS | MAP_PRIVATE;
|
||||
if (purgeable == Purgeable::Yes)
|
||||
map_flags |= MAP_NORESERVE;
|
||||
#ifdef __serenity__
|
||||
int map_flags = purgeable == Purgeable::Yes ? (MAP_PURGEABLE | MAP_PRIVATE) : (MAP_ANONYMOUS | MAP_PRIVATE);
|
||||
data = mmap_with_name(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0, String::format("GraphicsBitmap [%dx%d]", size.width(), size.height()).characters());
|
||||
void* data = mmap_with_name(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0, String::format("GraphicsBitmap [%dx%d]", size.width(), size.height()).characters());
|
||||
#else
|
||||
int map_flags = (MAP_ANONYMOUS | MAP_PRIVATE);
|
||||
data = mmap(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0);
|
||||
void* data = mmap(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0);
|
||||
#endif
|
||||
if (data == MAP_FAILED) {
|
||||
perror("mmap");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue