process_madvise - Online Linux Manual PageSection : 2
Updated : 2022-11-01
Source : Linux man-pages 6.03
NAMEprocess_madvise − give advice about use of memory to a process
LIBRARYStandard C library (libc, −lc)
SYNOPSIS#include <sys/mman.h> /* Definition of MADV_* constants */
#include <sys/syscall.h> /* Definition of SYS_* constants */
#include <sys/uio.h> /* Definition of struct iovec type */
#include <unistd.h>ssize_t syscall(SYS_process_madvise, int pidfd,
const struct iovec *iovec, size_t vlen, int advice,
unsigned int flags);Note: glibc provides no wrapper for process_madvise(), necessitating the use of syscall(2).
DESCRIPTIONThe 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, described in iovec(3type). vlen specifies the number of elements in the array of iovec structures. 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_COLD See madvise(2). MADV_COLLAPSE See madvise(2). MADV_PAGEOUT See madvise(2). MADV_WILLNEED See 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.) Starting in Linux 5.12, permission to apply advice to another process is governed by ptrace access mode PTRACE_MODE_READ_FSCREDS check (see ptrace(2)); in addition, because of the performance implications of applying the advice, the caller must have the CAP_SYS_NICE capability (see capabilities(7)).
RETURN VALUEOn 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.
ERRORSEBADF pidfd is not a valid PID file descriptor. EFAULT The memory described by iovec is outside the accessible address space of the process referred to by pidfd. EINVAL flags is not 0. EINVAL The sum of the iov_len values of iovec overflows a ssize_t value. EINVAL vlen is too large. ENOMEM Could not allocate memory for internal copies of the iovec structures. EPERM The caller does not have permission to access the address space of the process pidfd. ESRCH The target process does not exist (i.e., it has terminated and been waited on). See madvise(2) for advice-specific errors.
VERSIONSThis 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.
STANDARDSThe process_madvise() system call is Linux-specific.
NOTESWhen this system call first appeared in Linux 5.10, permission to apply advice to another process was entirely governed by ptrace access mode PTRACE_MODE_ATTACH_FSCREDS check (see ptrace(2)). This requirement was relaxed in Linux 5.12 so that the caller didn't require full control over the target process.
SEE ALSOmadvise(2), pidfd_open(2), process_vm_readv(2), process_vm_write(2) 0
Johanes Gumabo
Data Size : 15,138 byte
man-process_madvise.2Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 4 / 182,568
Visitor ID : :
Visitor IP : 3.149.255.239 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.