process_madvise — give advice about use of memory to a process
#include <sys/uio.h>
ssize_t
process_madvise( |
int pidfd, |
| const struct iovec *iovec, | |
| size_t vlen, | |
| int advice, | |
unsigned int flags); |
![]() |
Note |
|---|---|
| There is no glibc wrapper for this system call; see NOTES. |
The process_madvise() system
call is used to give advice or directions to the kernel about
the address ranges of another process or of the calling
process. It provides the advice for the address ranges
described by iovec
and vlen. The goal of
such advice is to improve system or application
performance.
The pidfd argument
is a PID file descriptor (see pidfd_open(2)) that
specifies the process to which the advice is to be
applied.
The pointer iovec
points to an array of iovec structures, defined in
<sys/uio.h>
as:
struct iovec { void * iov_base; /* Starting address */size_t iov_len; /* Length of region */};
The iovec
structure describes address ranges beginning at iov_base address and with the
size of iov_len
bytes.
The vlen specifies
the number of elements in the iovec structure. This value
must be less than or equal to IOV_MAX (defined in <limits.h>
or accessible via the call sysconf(_SC_IOV_MAX)).
The advice
argument is one of the following values:
MADV_COLDSee madvise(2).
MADV_PAGEOUTSee madvise(2).
The flags argument
is reserved for future use; currently, this argument must be
specified as 0.
The vlen and
iovec arguments are
checked before applying any advice. If vlen is too big, or iovec is invalid, then an error
will be returned immediately and no advice will be
applied.
The advice might be applied to only a part of iovec if one of its elements
points to an invalid memory region in the remote process. No
further elements will be processed beyond that point. (See
the discussion regarding partial advice in RETURN VALUE.)
Permission to apply advice to another process is governed
by a ptrace access mode PTRACE_MODE_READ_REALCREDS check (see
ptrace(2)); in addition,
because of the performance implications of applying the
advice, the caller must have the CAP_SYS_ADMIN capability.
On success, process_madvise() returns the number of
bytes advised. This return value may be less than the total
number of requested bytes, if an error occurred after some
iovec elements were
already processed. The caller should check the return value
to determine whether a partial advice occurred.
On error, −1 is returned and errno is set to indicate the error.
pidfd is not
a valid PID file descriptor.
The memory described by iovec is outside the
accessible address space of the process referred to by
pidfd.
flags is not
0.
The sum of the iov_len values of
iovec overflows
a ssize_t value.
vlen is too
large.
Could not allocate memory for internal copies of the
iovec
structures.
The caller does not have permission to access the
address space of the process pidfd.
The target process does not exist (i.e., it has terminated and been waited on).
This system call first appeared in Linux 5.10. Support for
this system call is optional, depending on the setting of the
CONFIG_ADVISE_SYSCALLS
configuration option.
This page is part of release 5.11 of the Linux man-pages project. A
description of the project, information about reporting bugs,
and the latest version of this page, can be found at
https://www.kernel.org/doc/man−pages/.
|
Copyright (C) 2021 Suren Baghdasaryan <surenbgoogle.com> and Copyright (C) 2021 Minchan Kim <minchankernel.org> %%%LICENSE_START(VERBATIM) Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Since the Linux kernel and libraries are constantly changing, this manual page may be incorrect or out-of-date. The author(s) assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. The author(s) may not have taken the same level of care in the production of this manual, which is licensed free of charge, as they might when working professionally. Formatted or processed versions of this manual, if unaccompanied by the source, must acknowledge the copyright and authors of this work. %%%LICENSE_END Commit ecb8ac8b1f146915aa6b96449b66dd48984caacc |