b3bd66961a
It allows an application to signal that it no longer needs the data in the given address range and the underlying pages can be discarded and reused elsewhere. This is finer grained than working with full areas or mappings at a time and enables unmapping sections of partially used mappings without giving up its address space. Compared with punching holes into a mapping by "mapping over" with PROT_NONE and MAP_NORESERVE, this has the obvious advantage of not producing a lot of unused extra areas and saves the corresponding resources. It is also a lot "lighter" of an operation than cutting existing areas. This introduces madvise() alongside the existing posix_madvise() to allow for OS specific extensions. The constants for both functions are aliased, the POSIX_MADV_* being a subset of the MADV_* ones without the non-POSIX extensions. Internally posix_madvise() simply calls madvise(). MADV_FREE is commonly supported in other OSes with various subtle semantic differences as to when pages are actually freed/cleared and how or whether the pages are counted against the memory use of a process. In the variant implemented here, pages are always immediately discarded and memory counting is not altered. This behaviour should be considered an implementation detail and may be altered later. The actual unmap and discard could for example be delayed until pages are needed elsewhere to reduce overhead in case of repeated discarding and remapping. Note that MADV_FREE doesn't really align with the rest of the madvise() API as it works like a command (i.e. discard these pages) and does not add an attribute to the pages in the given range (i.e. mark these pages for quick access from now on). As such, an MADV_FREE does not need to be undone by setting a different advice later on, unlike how the other flags work. This discrepancy may be the reason why it is not part of POSIX. Change-Id: Icc093379125a43e465dc4409d8f5ae0f64e107e0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2844 Reviewed-by: waddlesplash <waddlesplash@gmail.com> |
||
---|---|---|
.. | ||
arch | ||
arpa | ||
compat/sys | ||
net | ||
netinet | ||
netinet6 | ||
sys | ||
alloca.h | ||
assert.h | ||
bsd_mem.h | ||
complex.h | ||
ctype.h | ||
dirent.h | ||
div_t.h | ||
dlfcn.h | ||
endian.h | ||
errno.h | ||
fcntl.h | ||
fenv.h | ||
fnmatch.h | ||
fts.h | ||
ftw.h | ||
getopt.h | ||
glob.h | ||
grp.h | ||
inttypes.h | ||
iovec.h | ||
langinfo.h | ||
libgen.h | ||
libio.h | ||
limits.h | ||
locale.h | ||
malloc_debug.h | ||
malloc.h | ||
math.h | ||
memory.h | ||
monetary.h | ||
netdb.h | ||
nl_types.h | ||
null.h | ||
poll.h | ||
pthread.h | ||
pwd.h | ||
regex.h | ||
resolv.h | ||
sched.h | ||
search.h | ||
semaphore.h | ||
setjmp.h | ||
shadow.h | ||
signal.h | ||
size_t.h | ||
spawn.h | ||
stdint.h | ||
stdio_ext.h | ||
stdio_post.h | ||
stdio_pre.h | ||
stdio.h | ||
stdlib.h | ||
string.h | ||
strings.h | ||
syslog.h | ||
tar.h | ||
termios.h | ||
time.h | ||
uchar.h | ||
unistd.h | ||
utime.h | ||
wchar_t.h | ||
wchar.h | ||
wctype.h |