summaryrefslogtreecommitdiff
path: root/Libraries/LibC/mman.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-09 19:12:38 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-09 19:12:38 +0100
commitdbb644f20cc12104a60474953c68e2bcff78b316 (patch)
tree38b745ea52f352b3ea7edacd5b10b0c9e2a45752 /Libraries/LibC/mman.cpp
parent7248c34e358da73d100f61df906d828f1ce97aa5 (diff)
downloadserenity-dbb644f20cc12104a60474953c68e2bcff78b316.zip
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.
Diffstat (limited to 'Libraries/LibC/mman.cpp')
-rw-r--r--Libraries/LibC/mman.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibC/mman.cpp b/Libraries/LibC/mman.cpp
index 65c4371ca7..8ee60929e9 100644
--- a/Libraries/LibC/mman.cpp
+++ b/Libraries/LibC/mman.cpp
@@ -56,4 +56,11 @@ int shm_unlink(const char* name)
int rc = syscall(SC_shm_unlink, name);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
+
+int madvise(void* address, size_t size, int advice)
+{
+ int rc = syscall(SC_madvise, address, size, advice);
+ __RETURN_WITH_ERRNO(rc, rc, -1);
+}
+
}