sys_madvise  [mm/madvise.c]


Advises the kernel about how to handle paging I/O in the specified VM area.

It allows an application to tell the kernel how it expects to use some mapped or shared memory areas, so that the kernel can choose appropriate read-ahead and caching techniques. This call does not influence the semantics of the application (except in the case of MADV_DONTNEED), but may influence its performance. The kernel is free to ignore the advice.

Arguments

eax 219
ebx Pointer to an integer value specifying the beginning of the address range.
ecx Size of the range in bytes.
edx Advice. It may be one of the following values:
MADV_NORMAL No special treatment. This is the default.
MADV_RANDOM Expect page references in random order. (Hence, read ahead may be less useful than normally.)
MADV_SEQUENTIAL Expect page references in sequential order. (Hence, pages in the given range can be aggressively read ahead, and may be freed soon after they are accessed.)
MADV_WILLNEED Expect access in the near future. (Hence, it might be a good idea to read some pages ahead.)
MADV_DONTNEED Do not expect access in the near future. (For the time being, the application is finished with the given range, so the kernel can free resources associated with it.) Subsequent accesses of pages in this range will succeed, but will result either in reloading of the memory contents from the underlying mapped file or zero-fill-on-demand pages for mappings without an underlying file.
MADV_REMOVE Expect the given range of pages to be freed soon.

Return values

If the system call succeeds the return value is 0.
If the system call fails the return value is one of the following errno values:

-EAGAIN A kernel resource was temporarily unavailable.
-EBADF The map exists, but the area maps something that isn't a file.
-EINVAL The range (ebx+ecx) is negative, integer pointed by ebx is not page-aligned, edx is not a valid value, or the application is attempting to release locked or shared pages (with MADV_DONTNEED).
-EIO (for MADV_WILLNEED) Paging in this area would exceed the process's maximum resident set size.
-ENOMEM (for MADV_WILLNEED) Not enough memory: paging in failed.
-or-
Addresses in the specified range are not currently mapped, or are outside the address space of the process.

Remarks

n/a

Compatibility

n/a