1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH UFFDIO_MOVE 2const 2025-05-17 "Linux man-pages (unreleased)"
.SH NAME
UFFDIO_MOVE
\-
atomically move a continuous memory chunk into the userfault registered range
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
.BR "#include <linux/userfaultfd.h>" " /* Definition of " UFFD* " constants */"
.B #include <sys/ioctl.h>
.P
.BI "int ioctl(int " fd ", UFFDIO_MOVE, struct uffdio_move *" argp );
.P
.B #include <linux/userfaultfd.h>
.P
.fi
.EX
.B struct uffdio_move {
.BR " __u64 dst;" " /* Destination of move */"
.BR " __u64 src;" " /* Source of move */"
.BR " __u64 len;" " /* Number of bytes to move */"
.BR " __u64 mode;" " /* Flags controlling behavior of move */"
.BR " __s64 move;" " /* Number of bytes moved, or negated error */"
.B };
.EE
.SH DESCRIPTION
Atomically move a continuous memory chunk
into the userfault registered range
and optionally wake up the blocked thread.
.P
The following value may be bitwise ORed in
.I .mode
to change the behavior of the
.B UFFDIO_MOVE
operation:
.TP
.B UFFDIO_MOVE_MODE_DONTWAKE
Do not wake up the thread that waits for page-fault resolution
.TP
.B UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES
Allow holes in the source virtual range that is being moved.
When not specified, the holes will result in
.B ENOENT
error.
When specified,
the holes will be accounted as successfully moved memory.
This is mostly useful
to move hugepage aligned virtual regions
without knowing if there are transparent hugepages in the regions or not,
but preventing the risk of
having to split the hugepage during the operation.
.P
The
.I .move
field is used by the kernel
to return the number of bytes that was actually moved,
or an error
(a negated
.IR errno -style
value).
The
.I .move
field is output-only;
it is not read by the
.B UFFDIO_MOVE
operation.
.SH RETURN VALUE
On success,
0 is returned.
In this case, the entire area was moved.
.P
On error, \-1 is returned and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EAGAIN
The number of bytes moved (i.e., the value returned in the
.I .move
field)
does not equal the value that was specified in the
.I .len
field.
.TP
.B EINVAL
Either
.I .dst
or
.I .len
was not a multiple of the system page size, or the range specified by
.I .src
and
.I .len
or
.I .dst
and
.I .len
was invalid.
.TP
.B EINVAL
An invalid bit was specified in the
.I .mode
field.
.TP
.B ENOENT
The source virtual memory range has unmapped holes and
.B UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES
is not set.
.TP
.B EEXIST
The destination virtual memory range is fully or partially
mapped.
.TP
.B EBUSY
The pages in the source virtual memory range are either
pinned or not exclusive to the process.
Once KSM deduplicates pages
or
.BR fork (2)
COW-shares pages during
.BR fork (2)
with child processes,
they are no longer exclusive.
The kernel might only perform lightweight checks
for detecting whether the pages are exclusive.
To make the operation more likely to succeed,
KSM should be disabled,
.BR fork (2)
should be avoided
or
.B MADV_DONTFORK
should be configured
for the source virtual memory area
before
.BR fork (2).
.TP
.B ENOMEM
Allocating memory needed for the operation failed.
.TP
.B ESRCH
The target process has exited at the time of a
.B UFFDIO_MOVE
operation.
.SH STANDARDS
Linux.
.SH HISTORY
Linux 6.8.
.SH SEE ALSO
.BR ioctl (2),
.BR ioctl_userfaultfd (2),
.BR userfaultfd (2)
.P
.I linux.git/\:Documentation/\:admin\-guide/\:mm/\:userfaultfd.rst
|