haiku/headers/posix/sys
Michael Lotz b3bd66961a libroot/kernel: Implement MADV_FREE madvise() extension.
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>
2020-08-01 19:23:27 +00:00
..
cdefs.h x86_64: fenv.c needs __weak_reference() 2015-03-27 20:16:57 +01:00
file.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
ioctl.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
ipc.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
mman.h libroot/kernel: Implement MADV_FREE madvise() extension. 2020-08-01 19:23:27 +00:00
msg.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
param.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
poll.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
resource.h libroot: add [gs]etpriority implementation 2019-01-19 18:31:58 +00:00
select.h <langinfo.h>/<select.h>: don't use C++ comments 2013-06-12 14:55:16 +02:00
sem.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
socket.h Implement MSG_NOSIGNAL 2015-06-10 17:39:53 +02:00
sockio.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
stat.h mknod[at](): moves from unistd.h to sys/stat.h 2014-08-04 19:03:08 +02:00
statvfs.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
time.h libbsd: Move lutimes to bsd compat 2017-11-17 14:27:26 -06:00
timeb.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
times.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
types.h build fixes. 2019-08-27 20:51:51 +02:00
uio.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
un.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
utsname.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
wait.h Merged signals-merge branch into trunk with the following changes: 2011-06-12 00:00:23 +00:00