mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
Kernel: Make purgeable memory a VMObject level concept (again)
This patch changes the semantics of purgeable memory. - AnonymousVMObject now has a "purgeable" flag. It can only be set when constructing the object. (Previously, all anonymous memory was effectively purgeable.) - AnonymousVMObject now has a "volatile" flag. It covers the entire range of physical pages. (Previously, we tracked ranges of volatile pages, effectively making it a page-level concept.) - Non-volatile objects maintain a physical page reservation via the committed pages mechanism, to ensure full coverage for page faults. - When an object is made volatile, it relinquishes any unused committed pages immediately. If later made non-volatile again, we then attempt to make a new committed pages reservation. If this fails, we return ENOMEM to userspace. mmap() now creates purgeable objects if passed the MAP_PURGEABLE option together with MAP_ANONYMOUS. anon_create() memory is always purgeable.
This commit is contained in:
parent
6bb53d6a80
commit
2d1a651e0a
17 changed files with 189 additions and 1004 deletions
|
@ -544,11 +544,11 @@ void Bitmap::set_volatile()
|
|||
int rc = madvise(m_data, size_in_bytes(), MADV_SET_NONVOLATILE);
|
||||
if (rc < 0) {
|
||||
if (errno == ENOMEM) {
|
||||
was_purged = was_purged_int;
|
||||
was_purged = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
perror("madvise(MADV_SET_NONVOLATILE)");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
was_purged = rc != 0;
|
||||
#endif
|
||||
|
@ -574,6 +574,7 @@ Optional<BackingStore> Bitmap::try_allocate_backing_store(BitmapFormat format, I
|
|||
|
||||
int map_flags = MAP_ANONYMOUS | MAP_PRIVATE;
|
||||
#ifdef __serenity__
|
||||
map_flags |= MAP_PURGEABLE;
|
||||
void* data = mmap_with_name(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0, String::formatted("GraphicsBitmap [{}]", size).characters());
|
||||
#else
|
||||
void* data = mmap(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue