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