1 .\" Copyright (C) 2021 Suren Baghdasaryan <surenb@google.com>
2 .\" and Copyright (C) 2021 Minchan Kim <minchan@kernel.org>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Commit ecb8ac8b1f146915aa6b96449b66dd48984caacc
28 .TH PROCESS_MADVISE 2 2021-06-20 "Linux" "Linux Programmer's Manual"
30 process_madvise \- give advice about use of memory to a process
33 .BR "#include <sys/mman.h>" " /* Definition of " MADV_* " constants */"
34 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
35 .BR "#include <sys/uio.h>" " /* Definition of " "struct iovec" " type */"
36 .B #include <unistd.h>
38 .BI "ssize_t syscall(SYS_process_madvise, int " pidfd ,
39 .BI " const struct iovec *" iovec ", size_t " vlen \
41 .BI " unsigned int " flags ");"
45 glibc provides no wrapper for
46 .BR process_madvise (),
47 necessitating the use of
49 .\" FIXME: See <https://sourceware.org/bugzilla/show_bug.cgi?id=27380>
53 system call is used to give advice or directions to the kernel about the
54 address ranges of another process or of the calling process.
55 It provides the advice for the address ranges described by
59 The goal of such advice is to improve system or application performance.
63 argument is a PID file descriptor (see
65 that specifies the process to which the advice is to be applied.
71 structures, defined in
78 void *iov_base; /* Starting address */
79 size_t iov_len; /* Length of region */
86 structure describes address ranges beginning at
88 address and with the size of
94 specifies the number of elements in the
97 This value must be less than or equal to
101 or accessible via the call
102 .IR sysconf(_SC_IOV_MAX) ).
106 argument is one of the following values:
118 argument is reserved for future use; currently, this argument must be
125 arguments are checked before applying any advice.
131 then an error will be returned immediately and no advice will be applied.
133 The advice might be applied to only a part of
135 if one of its elements points to an invalid memory region in the
137 No further elements will be processed beyond that point.
138 (See the discussion regarding partial advice in RETURN VALUE.)
140 Permission to apply advice to another process is governed by a
142 .B PTRACE_MODE_READ_REALCREDS
146 because of the performance implications of applying the advice,
147 the caller must have the
152 .BR process_madvise ()
153 returns the number of bytes advised.
154 This return value may be less than the total number of requested bytes,
155 if an error occurred after some
157 elements were already processed.
158 The caller should check the return value to determine whether a partial
161 On error, \-1 is returned and
163 is set to indicate the error.
168 is not a valid PID file descriptor.
171 The memory described by
173 is outside the accessible address space of the process referred to by
194 Could not allocate memory for internal copies of the
199 The caller does not have permission to access the address space of the process
203 The target process does not exist (i.e., it has terminated and been waited on).
205 This system call first appeared in Linux 5.10.
206 .\" commit ecb8ac8b1f146915aa6b96449b66dd48984caacc
207 Support for this system call is optional,
208 depending on the setting of the
209 .B CONFIG_ADVISE_SYSCALLS
210 configuration option.
213 .BR process_madvise ()
214 system call is Linux-specific.
218 .BR process_vm_readv (2),
219 .BR process_vm_write (2)