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-01-12 "Linux" "Linux Programmer's Manual"
30 process_madvise \- give advice about use of memory to a process
33 .B #include <sys/uio.h>
35 .BI "ssize_t process_madvise(int " pidfd ", const struct iovec *" iovec ,
36 .BI " size_t " vlen ", int " advice ,
37 .BI " unsigned int " flags ");"
41 There is no glibc wrapper for this system call; see NOTES.
42 .\" FIXME: See <https://sourceware.org/bugzilla/show_bug.cgi?id=27380>
46 system call is used to give advice or directions to the kernel about the
47 address ranges of another process or of the calling process.
48 It provides the advice for the address ranges described by
52 The goal of such advice is to improve system or application performance.
56 argument is a PID file descriptor (see
58 that specifies the process to which the advice is to be applied.
64 structures, defined in
71 void *iov_base; /* Starting address */
72 size_t iov_len; /* Length of region */
79 structure describes address ranges beginning at
81 address and with the size of
87 specifies the number of elements in the
90 This value must be less than or equal to
94 or accessible via the call
95 .IR sysconf(_SC_IOV_MAX) ).
99 argument is one of the following values:
111 argument is reserved for future use; currently, this argument must be
118 arguments are checked before applying any advice.
124 then an error will be returned immediately and no advice will be applied.
126 The advice might be applied to only a part of
128 if one of its elements points to an invalid memory region in the
130 No further elements will be processed beyond that point.
131 (See the discussion regarding partial advice in RETURN VALUE.)
133 Permission to apply advice to another process is governed by a
135 .B PTRACE_MODE_READ_REALCREDS
139 because of the performance implications of applying the advice,
140 the caller must have the
145 .BR process_madvise ()
146 returns the number of bytes advised.
147 This return value may be less than the total number of requested bytes,
148 if an error occurred after some
150 elements were already processed.
151 The caller should check the return value to determine whether a partial
154 On error, \-1 is returned and
156 is set to indicate the error.
161 is not a valid PID file descriptor.
164 The memory described by
166 is outside the accessible address space of the process referred to by
187 Could not allocate memory for internal copies of the
192 The caller does not have permission to access the address space of the process
196 The target process does not exist (i.e., it has terminated and been waited on).
198 This system call first appeared in Linux 5.10.
199 .\" commit ecb8ac8b1f146915aa6b96449b66dd48984caacc
200 Support for this system call is optional,
201 depending on the setting of the
202 .B CONFIG_ADVISE_SYSCALLS
203 configuration option.
206 .BR process_madvise ()
207 system call is Linux-specific.
209 Glibc does not provide a wrapper for this system call; call it using
214 .BR process_vm_readv (2),
215 .BR process_vm_write (2)