mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 07:24:58 +00:00
Kernel: Start implementing purgeable memory support
It's now possible to get purgeable memory by using mmap(MAP_PURGEABLE). Purgeable memory has a "volatile" flag that can be set using madvise(): - madvise(..., MADV_SET_VOLATILE) - madvise(..., MADV_SET_NONVOLATILE) When in the "volatile" state, the kernel may take away the underlying physical memory pages at any time, without notifying the owner. This gives you a guilt discount when caching very large things. :^) Setting a purgeable region to non-volatile will return whether or not the memory has been taken away by the kernel while being volatile. Basically, if madvise(..., MADV_SET_NONVOLATILE) returns 1, that means the memory was purged while volatile, and whatever was in that piece of memory needs to be reconstructed before use.
This commit is contained in:
parent
7248c34e35
commit
dbb644f20c
13 changed files with 196 additions and 9 deletions
|
@ -24,6 +24,7 @@
|
|||
#include <Kernel/Net/UDPSocket.h>
|
||||
#include <Kernel/PCI.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <Kernel/VM/PurgeableVMObject.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
enum ProcParentDirectory {
|
||||
|
@ -262,6 +263,11 @@ Optional<KBuffer> procfs$pid_vm(InodeIdentifier identifier)
|
|||
region_object.add("writable", region.is_writable());
|
||||
region_object.add("stack", region.is_stack());
|
||||
region_object.add("shared", region.is_shared());
|
||||
region_object.add("purgeable", region.vmobject().is_purgeable());
|
||||
if (region.vmobject().is_purgeable()) {
|
||||
region_object.add("volatile", static_cast<const PurgeableVMObject&>(region.vmobject()).is_volatile());
|
||||
}
|
||||
region_object.add("purgeable", region.vmobject().is_purgeable());
|
||||
region_object.add("address", region.vaddr().get());
|
||||
region_object.add("size", (u32)region.size());
|
||||
region_object.add("amount_resident", (u32)region.amount_resident());
|
||||
|
@ -716,6 +722,8 @@ Optional<KBuffer> procfs$all(InodeIdentifier)
|
|||
process_object.add("amount_virtual", (u32)process.amount_virtual());
|
||||
process_object.add("amount_resident", (u32)process.amount_resident());
|
||||
process_object.add("amount_shared", (u32)process.amount_shared());
|
||||
process_object.add("amount_purgeable_volatile", (u32)process.amount_purgeable_volatile());
|
||||
process_object.add("amount_purgeable_nonvolatile", (u32)process.amount_purgeable_nonvolatile());
|
||||
process_object.add("icon_id", process.icon_id());
|
||||
auto thread_array = process_object.add_array("threads");
|
||||
process.for_each_thread([&](const Thread& thread) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue