1 .\" Copyright (C) 2021 Suren Baghdasaryan <surenb@google.com>
2 .\" and Copyright (C) 2021 Minchan Kim <minchan@kernel.org>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" Commit ecb8ac8b1f146915aa6b96449b66dd48984caacc
8 .TH PROCESS_MADVISE 2 2021-06-20 "Linux" "Linux Programmer's Manual"
10 process_madvise \- give advice about use of memory to a process
13 .RI ( libc ", " \-lc )
16 .BR "#include <sys/mman.h>" " /* Definition of " MADV_* " constants */"
17 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
18 .BR "#include <sys/uio.h>" " /* Definition of " "struct iovec" " type */"
19 .B #include <unistd.h>
21 .BI "ssize_t syscall(SYS_process_madvise, int " pidfd ,
22 .BI " const struct iovec *" iovec ", size_t " vlen \
24 .BI " unsigned int " flags ");"
28 glibc provides no wrapper for
29 .BR process_madvise (),
30 necessitating the use of
32 .\" FIXME: See <https://sourceware.org/bugzilla/show_bug.cgi?id=27380>
35 .BR process_madvise ()
36 system call is used to give advice or directions to the kernel about the
37 address ranges of another process or of the calling process.
38 It provides the advice for the address ranges described by
42 The goal of such advice is to improve system or application performance.
46 argument is a PID file descriptor (see
48 that specifies the process to which the advice is to be applied.
54 structures, described in
58 specifies the number of elements in the array of
61 This value must be less than or equal to
65 or accessible via the call
66 .IR sysconf(_SC_IOV_MAX) ).
70 argument is one of the following values:
86 argument is reserved for future use; currently, this argument must be
93 arguments are checked before applying any advice.
99 then an error will be returned immediately and no advice will be applied.
101 The advice might be applied to only a part of
103 if one of its elements points to an invalid memory region in the
105 No further elements will be processed beyond that point.
106 (See the discussion regarding partial advice in RETURN VALUE.)
108 Permission to apply advice to another process is governed by a
110 .B PTRACE_MODE_READ_REALCREDS
114 because of the performance implications of applying the advice,
115 the caller must have the
120 .BR process_madvise ()
121 returns the number of bytes advised.
122 This return value may be less than the total number of requested bytes,
123 if an error occurred after some
125 elements were already processed.
126 The caller should check the return value to determine whether a partial
129 On error, \-1 is returned and
131 is set to indicate the error.
136 is not a valid PID file descriptor.
139 The memory described by
141 is outside the accessible address space of the process referred to by
162 Could not allocate memory for internal copies of the
167 The caller does not have permission to access the address space of the process
171 The target process does not exist (i.e., it has terminated and been waited on).
173 This system call first appeared in Linux 5.10.
174 .\" commit ecb8ac8b1f146915aa6b96449b66dd48984caacc
175 Support for this system call is optional,
176 depending on the setting of the
177 .B CONFIG_ADVISE_SYSCALLS
178 configuration option.
181 .BR process_madvise ()
182 system call is Linux-specific.
186 .BR process_vm_readv (2),
187 .BR process_vm_write (2)