Debian Codegraph @

po/ru/man2/userfaultfd.2.po

raw
1 # Russian translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 # Azamat Hackimov <[email protected]>, 2013, 2016.
5 # Dmitriy Ovchinnikov <[email protected]>, 2012.
6 # Dmitry Bolkhovskikh <[email protected]>, 2017.
7 # Katrin Kutepova <[email protected]>, 2018.
8 # Yuri Kozlov <[email protected]>, 2011-2019.
9 # Иван Павлов <[email protected]>, 2017.
10 msgid ""
11 msgstr ""
12 "Project-Id-Version: manpages-l10n\n"
13 "POT-Creation-Date: 2026-06-05 06:50+0200\n"
14 "PO-Revision-Date: 2024-12-21 19:49+0300\n"
15 "Last-Translator: Yuri Kozlov <[email protected]>\n"
16 "Language-Team: Russian <[email protected]>\n"
17 "Language: ru\n"
18 "MIME-Version: 1.0\n"
19 "Content-Type: text/plain; charset=UTF-8\n"
20 "Content-Transfer-Encoding: 8bit\n"
21 "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
22 "n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || "
23 "(n%100>=11 && n%100<=14)? 2 : 3);\n"
24 "X-Generator: Lokalize 2.0\n"
25
26 #. type: TH
27 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
28 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
29 #, no-wrap
30 msgid "userfaultfd"
31 msgstr "userfaultfd"
32
33 #. type: TH
34 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
35 #, no-wrap
36 msgid "2026-02-16"
37 msgstr "16 февраля 2026 г."
38
39 #. type: TH
40 #: archlinux debian-unstable
41 #, fuzzy, no-wrap
42 #| msgid "Linux man-pages 6.17"
43 msgid "Linux man-pages 6.18"
44 msgstr "Справочные страницы Linux 6.17"
45
46 #. type: SH
47 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
48 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
49 #, no-wrap
50 msgid "NAME"
51 msgstr "НАИМЕНОВАНИЕ"
52
53 #. type: Plain text
54 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
55 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
56 msgid ""
57 "userfaultfd - create a file descriptor for handling page faults in user space"
58 msgstr ""
59 "userfaultfd - создаёт файловый дескриптор для обработки страничных ошибок в "
60 "пользовательском пространстве"
61
62 #. type: SH
63 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
64 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
65 #, no-wrap
66 msgid "LIBRARY"
67 msgstr "БИБЛИОТЕКА"
68
69 #. type: Plain text
70 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
71 #: opensuse-leap-16-1 opensuse-tumbleweed
72 msgid "Standard C library (I<libc>,\\ I<-lc>)"
73 msgstr "Стандартная библиотека языка C (I<libc>,\\ I<-lc>)"
74
75 #. type: SH
76 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
77 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
78 #, no-wrap
79 msgid "SYNOPSIS"
80 msgstr "СИНТАКСИС"
81
82 #. type: Plain text
83 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
84 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
85 #, no-wrap
86 msgid ""
87 "B<#include E<lt>fcntl.hE<gt>> /* Definition of B<O_*> constants */\n"
88 "B<#include E<lt>sys/syscall.hE<gt>> /* Definition of B<SYS_*> constants */\n"
89 "B<#include E<lt>linux/userfaultfd.hE<gt>> /* Definition of B<UFFD_*> constants */\n"
90 "B<#include E<lt>unistd.hE<gt>>\n"
91 msgstr ""
92 "B<#include E<lt>fcntl.hE<gt>> /* определения констант B<O_*> */\n"
93 "B<#include E<lt>sys/syscall.hE<gt>> /* определения констант B<SYS_*> */\n"
94 "B<#include E<lt>linux/userfaultfd.hE<gt>> /* определения констант B<UFFD_*> */\n"
95 "B<#include E<lt>unistd.hE<gt>>\n"
96
97 #. type: Plain text
98 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
99 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
100 #, no-wrap
101 msgid "B<int syscall(SYS_userfaultfd, int >I<flags>B<);>\n"
102 msgstr "B<int syscall(SYS_userfaultfd, int >I<flags>B<);>\n"
103
104 #. type: Plain text
105 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
106 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
107 msgid ""
108 "I<Note>: glibc provides no wrapper for B<userfaultfd>(), necessitating the "
109 "use of B<syscall>(2)."
110 msgstr ""
111
112 #. type: SH
113 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
114 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
115 #, no-wrap
116 msgid "DESCRIPTION"
117 msgstr "ОПИСАНИЕ"
118
119 #. type: Plain text
120 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
121 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
122 msgid ""
123 "B<userfaultfd>() creates a new userfaultfd object that can be used for "
124 "delegation of page-fault handling to a user-space application, and returns a "
125 "file descriptor that refers to the new object. The new userfaultfd object "
126 "is configured using B<ioctl>(2)."
127 msgstr ""
128 "Вызов B<userfaultfd>() создаёт новый объект userfaultfd, который можно "
129 "использовать для передачи обработки страничных ошибок приложению "
130 "пользовательского пространства, и возвращает файловый дескриптор, "
131 "ссылающийся на новый объект. Новый объект userfaultfd настраивается с "
132 "помощью B<ioctl>(2)."
133
134 #. type: Plain text
135 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
136 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
137 msgid ""
138 "Once the userfaultfd object is configured, the application can use "
139 "B<read>(2) to receive userfaultfd notifications. The reads from "
140 "userfaultfd may be blocking or non-blocking, depending on the value of "
141 "I<flags> used for the creation of the userfaultfd or subsequent calls to "
142 "B<fcntl>(2)."
143 msgstr ""
144 "После настройки объекта userfaultfd приложение может использовать вызов "
145 "B<read>(2) для получения уведомлений userfaultfd. Чтение из userfaultfd "
146 "может быть блокирующим и не блокирующим, в зависимости от использованного "
147 "при создании userfaultfd значения I<flags> или последующих вызовов "
148 "B<fcntl>(2)."
149
150 #. type: Plain text
151 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
152 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
153 msgid ""
154 "The following values may be bitwise ORed in I<flags> to change the behavior "
155 "of B<userfaultfd>():"
156 msgstr ""
157 "Для изменения поведения B<userfaultfd>() можно использовать следующие "
158 "значения I<flags> (через OR):"
159
160 #. type: TP
161 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
162 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
163 #, no-wrap
164 msgid "B<O_CLOEXEC>"
165 msgstr "B<O_CLOEXEC>"
166
167 #. type: Plain text
168 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
169 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
170 msgid ""
171 "Enable the close-on-exec flag for the new userfaultfd file descriptor. See "
172 "the description of the B<O_CLOEXEC> flag in B<open>(2)."
173 msgstr ""
174 "Включить флаг close-on-exec для нового открытого файлового дескриптора "
175 "userfaultfd. Смотрите описание флага B<O_CLOEXEC> в B<open>(2)."
176
177 #. type: TP
178 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
179 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
180 #, no-wrap
181 msgid "B<O_NONBLOCK>"
182 msgstr "B<O_NONBLOCK>"
183
184 #. type: Plain text
185 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
186 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
187 msgid ""
188 "Enables non-blocking operation for the userfaultfd object. See the "
189 "description of the B<O_NONBLOCK> flag in B<open>(2)."
190 msgstr ""
191 "Включить не блокирующую работу с объектом userfaultfd. Смотрите описание "
192 "флага B<O_NONBLOCK> в B<open>(2)."
193
194 #. type: TP
195 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
196 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
197 #, no-wrap
198 msgid "B<UFFD_USER_MODE_ONLY>"
199 msgstr "B<UFFD_USER_MODE_ONLY>"
200
201 #. type: Plain text
202 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
203 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
204 msgid ""
205 "This is an userfaultfd-specific flag that was introduced in Linux 5.11. "
206 "When set, the userfaultfd object will only be able to handle page faults "
207 "originated from the user space on the registered regions. When a kernel-"
208 "originated fault was triggered on the registered range with this "
209 "userfaultfd, a B<SIGBUS> signal will be delivered."
210 msgstr ""
211
212 #. type: Plain text
213 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
214 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
215 msgid ""
216 "When the last file descriptor referring to a userfaultfd object is closed, "
217 "all memory ranges that were registered with the object are unregistered and "
218 "unread events are flushed."
219 msgstr ""
220 "Когда закрывается последний ссылающийся на объект userfaultfd файловый "
221 "дескриптор, для всех диапазонов памяти, зарегистрированных в этом объекте, "
222 "снимается регистрация, а все непрочитанные события очищаются."
223
224 #. type: Plain text
225 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
226 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
227 msgid "Userfaultfd supports three modes of registration:"
228 msgstr ""
229
230 #. type: TP
231 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
232 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
233 #, fuzzy, no-wrap
234 #| msgid "B<UFFDIO_REGISTER_MODE_MISSING> (since 4.10)"
235 msgid "B<UFFDIO_REGISTER_MODE_MISSING> (since Linux 4.10)"
236 msgstr "B<UFFDIO_REGISTER_MODE_MISSING> (начиная с Linux 4.10)"
237
238 #. type: Plain text
239 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
240 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
241 msgid ""
242 "When registered with B<UFFDIO_REGISTER_MODE_MISSING> mode, user-space will "
243 "receive a page-fault notification when a missing page is accessed. The "
244 "faulted thread will be stopped from execution until the page fault is "
245 "resolved from user-space by either an B<UFFDIO_COPY> or an "
246 "B<UFFDIO_ZEROPAGE> ioctl."
247 msgstr ""
248
249 #. type: TP
250 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
251 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
252 #, fuzzy, no-wrap
253 #| msgid "B<UFFDIO_REGISTER_MODE_MINOR> (since 5.13)"
254 msgid "B<UFFDIO_REGISTER_MODE_MINOR> (since Linux 5.13)"
255 msgstr "B<UFFDIO_REGISTER_MODE_MINOR> (начиная с Linux 5.13)"
256
257 #. type: Plain text
258 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
259 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
260 msgid ""
261 "When registered with B<UFFDIO_REGISTER_MODE_MINOR> mode, user-space will "
262 "receive a page-fault notification when a minor page fault occurs. That is, "
263 "when a backing page is in the page cache, but page table entries don't yet "
264 "exist. The faulted thread will be stopped from execution until the page "
265 "fault is resolved from user-space by an B<UFFDIO_CONTINUE> ioctl."
266 msgstr ""
267
268 #. type: TP
269 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
270 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
271 #, fuzzy, no-wrap
272 #| msgid "B<UFFDIO_REGISTER_MODE_WP> (since 5.7)"
273 msgid "B<UFFDIO_REGISTER_MODE_WP> (since Linux 5.7)"
274 msgstr "B<UFFDIO_REGISTER_MODE_WP> (начиная с Linux 5.7)"
275
276 #. type: Plain text
277 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
278 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
279 msgid ""
280 "When registered with B<UFFDIO_REGISTER_MODE_WP> mode, user-space will "
281 "receive a page-fault notification when a write-protected page is written. "
282 "The faulted thread will be stopped from execution until user-space write-"
283 "unprotects the page using an B<UFFDIO_WRITEPROTECT> ioctl."
284 msgstr ""
285
286 #. type: Plain text
287 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
288 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
289 msgid ""
290 "Multiple modes can be enabled at the same time for the same memory range."
291 msgstr ""
292
293 #. type: Plain text
294 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
295 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
296 msgid ""
297 "Since Linux 4.14, a userfaultfd page-fault notification can selectively "
298 "embed faulting thread ID information into the notification. One needs to "
299 "enable this feature explicitly using the B<UFFD_FEATURE_THREAD_ID> feature "
300 "bit when initializing the userfaultfd context. By default, thread ID "
301 "reporting is disabled."
302 msgstr ""
303
304 #. type: SS
305 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
306 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
307 #, no-wrap
308 msgid "Usage"
309 msgstr "Использование"
310
311 #. type: Plain text
312 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
313 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
314 msgid ""
315 "The userfaultfd mechanism is designed to allow a thread in a multithreaded "
316 "program to perform user-space paging for the other threads in the process. "
317 "When a page fault occurs for one of the regions registered to the "
318 "userfaultfd object, the faulting thread is put to sleep and an event is "
319 "generated that can be read via the userfaultfd file descriptor. The fault-"
320 "handling thread reads events from this file descriptor and services them "
321 "using the operations described in B<ioctl_userfaultfd>(2). When servicing "
322 "the page fault events, the fault-handling thread can trigger a wake-up for "
323 "the sleeping thread."
324 msgstr ""
325 "Механизм userfaultfd разработан для того, чтобы позволить нити в "
326 "многонитевой программе выполнять деление на страницы пользовательского "
327 "пространства других нитей процесса. При возникновении страничной ошибки в "
328 "одной из зарегистрированных в объекте userfaultfd областей нить с ошибкой "
329 "засыпает и генерируется событие, которое можно прочитать через файловый "
330 "дескриптор userfaultfd. Нить обработки страничных ошибок читает сообщения из "
331 "этого файлового дескриптора и обслуживает из с помощью операций, описанных в "
332 "B<ioctl_userfaultfd>(2). В время этого нить обработки страничных ошибок "
333 "может привести в действие механизм пробуждения спящей нити."
334
335 #. type: Plain text
336 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
337 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
338 msgid ""
339 "It is possible for the faulting threads and the fault-handling threads to "
340 "run in the context of different processes. In this case, these threads may "
341 "belong to different programs, and the program that executes the faulting "
342 "threads will not necessarily cooperate with the program that handles the "
343 "page faults. In such non-cooperative mode, the process that monitors "
344 "userfaultfd and handles page faults needs to be aware of the changes in the "
345 "virtual memory layout of the faulting process to avoid memory corruption."
346 msgstr ""
347 "Нити с ошибкой и нити обработки страничных ошибок могут быть запущены в "
348 "контексте различных процессов. В этом случае данные нити могут принадлежать "
349 "разным программам, а программам, выполняющим нити с ошибкой, не обязательно "
350 "взаимодействовать с программой, обрабатывающей страничные ошибки. В таком "
351 "разобщённом режиме процессу, следящему за userfaultfd и обрабатывающему "
352 "страничные ошибки, необходимо знать об изменениях в раскладке виртуальной "
353 "памяти процесса с ошибкой, чтобы не допустить повреждение памяти."
354
355 #. type: Plain text
356 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
357 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
358 msgid ""
359 "Since Linux 4.11, userfaultfd can also notify the fault-handling threads "
360 "about changes in the virtual memory layout of the faulting process. In "
361 "addition, if the faulting process invokes B<fork>(2), the userfaultfd "
362 "objects associated with the parent may be duplicated into the child process "
363 "and the userfaultfd monitor will be notified (via the B<UFFD_EVENT_FORK> "
364 "described below) about the file descriptor associated with the userfault "
365 "objects created for the child process, which allows the userfaultfd monitor "
366 "to perform user-space paging for the child process. Unlike page faults "
367 "which have to be synchronous and require an explicit or implicit wakeup, all "
368 "other events are delivered asynchronously and the non-cooperative process "
369 "resumes execution as soon as the userfaultfd manager executes B<read>(2). "
370 "The userfaultfd manager should carefully synchronize calls to B<UFFDIO_COPY> "
371 "with the processing of events."
372 msgstr ""
373 "Начиная с Linux 4.11, userfaultfd также уведомляет нити обработки страничных "
374 "ошибок об изменениях в раскладке виртуальной памяти процесса с ошибкой. "
375 "Также, если процесс с ошибкой вызывает B<fork>(2), то для объекта "
376 "userfaultfd, связанного с родителем, в дочернем процессе может быть создать "
377 "дубликат, и отслеживающий userfaultfd также будет уведомлён (смотрите "
378 "описание B<UFFD_EVENT_FORK> ниже) о файловом дескрипторе, связанном с "
379 "объектом userfault, который был создан для дочернего процесса, что позволяет "
380 "отслеживающему userfaultfd выполнять деление на страницы пользовательское "
381 "пространство дочернего процесса. В отличие от страничных ошибок, которые "
382 "происходят синхронно и требуют явного или неявного пробуждения, все "
383 "остальные события доставляются асинхронно и не взаимодействующий процесс "
384 "возобновляет выполнение сразу же после того как отслеживающий userfaultfd "
385 "выполняет B<read>(2). Отслеживающий userfaultfd должен корректно "
386 "синхронизировать вызовы B<UFFDIO_COPY> при обработке событий."
387
388 #. #-#-#-#-# archlinux: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
389 #. Regarding the preceding sentence, Mike Rapoport says:
390 #. The major point here is that current events delivery model could be
391 #. problematic for multi-threaded monitor. I even suspect that it would be
392 #. impossible to ensure synchronization between page faults and non-page
393 #. fault events in multi-threaded monitor.
394 #. .P
395 #. FIXME elaborate about non-cooperating mode, describe its limitations
396 #. for kernels before Linux 4.11, features added in Linux 4.11
397 #. and limitations remaining in Linux 4.11
398 #. Maybe it's worth adding a dedicated sub-section...
399 #. type: Plain text
400 #. #-#-#-#-# debian-trixie: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
401 #. Regarding the preceding sentence, Mike Rapoport says:
402 #. The major point here is that current events delivery model could be
403 #. problematic for multi-threaded monitor. I even suspect that it would be
404 #. impossible to ensure synchronization between page faults and non-page
405 #. fault events in multi-threaded monitor.
406 #. .P
407 #. FIXME elaborate about non-cooperating mode, describe its limitations
408 #. for kernels before Linux 4.11, features added in Linux 4.11
409 #. and limitations remaining in Linux 4.11
410 #. Maybe it's worth adding a dedicated sub-section...
411 #. type: Plain text
412 #. #-#-#-#-# debian-unstable: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
413 #. Regarding the preceding sentence, Mike Rapoport says:
414 #. The major point here is that current events delivery model could be
415 #. problematic for multi-threaded monitor. I even suspect that it would be
416 #. impossible to ensure synchronization between page faults and non-page
417 #. fault events in multi-threaded monitor.
418 #. .P
419 #. FIXME elaborate about non-cooperating mode, describe its limitations
420 #. for kernels before Linux 4.11, features added in Linux 4.11
421 #. and limitations remaining in Linux 4.11
422 #. Maybe it's worth adding a dedicated sub-section...
423 #. type: Plain text
424 #. #-#-#-#-# fedora-44: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
425 #. Regarding the preceding sentence, Mike Rapoport says:
426 #. The major point here is that current events delivery model could be
427 #. problematic for multi-threaded monitor. I even suspect that it would be
428 #. impossible to ensure synchronization between page faults and non-page
429 #. fault events in multi-threaded monitor.
430 #. .P
431 #. FIXME elaborate about non-cooperating mode, describe its limitations
432 #. for kernels before Linux 4.11, features added in Linux 4.11
433 #. and limitations remaining in Linux 4.11
434 #. Maybe it's worth adding a dedicated sub-section...
435 #. type: Plain text
436 #. #-#-#-#-# fedora-rawhide: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
437 #. Regarding the preceding sentence, Mike Rapoport says:
438 #. The major point here is that current events delivery model could be
439 #. problematic for multi-threaded monitor. I even suspect that it would be
440 #. impossible to ensure synchronization between page faults and non-page
441 #. fault events in multi-threaded monitor.
442 #. .P
443 #. FIXME elaborate about non-cooperating mode, describe its limitations
444 #. for kernels before Linux 4.11, features added in Linux 4.11
445 #. and limitations remaining in Linux 4.11
446 #. Maybe it's worth adding a dedicated sub-section...
447 #. type: Plain text
448 #. #-#-#-#-# mageia-cauldron: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
449 #. Regarding the preceding sentence, Mike Rapoport says:
450 #. The major point here is that current events delivery model could be
451 #. problematic for multi-threaded monitor. I even suspect that it would be
452 #. impossible to ensure synchronization between page faults and non-page
453 #. fault events in multi-threaded monitor.
454 #. .P
455 #. FIXME elaborate about non-cooperating mode, describe its limitations
456 #. for kernels before Linux 4.11, features added in Linux 4.11
457 #. and limitations remaining in Linux 4.11
458 #. Maybe it's worth adding a dedicated sub-section...
459 #. type: Plain text
460 #. #-#-#-#-# opensuse-leap-16-1: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
461 #. Regarding the preceding sentence, Mike Rapoport says:
462 #. The major point here is that current events delivery model could be
463 #. problematic for multi-threaded monitor. I even suspect that it would be
464 #. impossible to ensure synchronization between page faults and non-page
465 #. fault events in multi-threaded monitor.
466 #. .P
467 #. FIXME elaborate about non-cooperating mode, describe its limitations
468 #. for kernels before Linux 4.11, features added in Linux 4.11
469 #. and limitations remaining in Linux 4.11
470 #. Maybe it's worth adding a dedicated sub-section...
471 #. type: Plain text
472 #. #-#-#-#-# opensuse-tumbleweed: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
473 #. Regarding the preceding sentence, Mike Rapoport says:
474 #. The major point here is that current events delivery model could be
475 #. problematic for multi-threaded monitor. I even suspect that it would be
476 #. impossible to ensure synchronization between page faults and non-page
477 #. fault events in multi-threaded monitor.
478 #. .P
479 #. FIXME elaborate about non-cooperating mode, describe its limitations
480 #. for kernels before Linux 4.11, features added in Linux 4.11
481 #. and limitations remaining in Linux 4.11
482 #. Maybe it's worth adding a dedicated sub-section...
483 #. type: Plain text
484 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
485 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
486 msgid ""
487 "The current asynchronous model of the event delivery is optimal for single "
488 "threaded non-cooperative userfaultfd manager implementations."
489 msgstr ""
490 "Имеющаяся асинхронная модель доставки событий оптимальна для реализации "
491 "однонитевой не взаимодействующей отслеживающей userfaultfd программы."
492
493 #. type: Plain text
494 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
495 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
496 msgid ""
497 "Since Linux 5.7, userfaultfd is able to do synchronous page dirty tracking "
498 "using the new write-protect register mode. One should check against the "
499 "feature bit B<UFFD_FEATURE_PAGEFAULT_FLAG_WP> before using this feature. "
500 "Similar to the original userfaultfd missing mode, the write-protect mode "
501 "will generate a userfaultfd notification when the protected page is "
502 "written. The user needs to resolve the page fault by unprotecting the "
503 "faulted page and kicking the faulted thread to continue. For more "
504 "information, please refer to the \"Userfaultfd write-protect mode\" section."
505 msgstr ""
506
507 #. type: SS
508 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
509 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
510 #, no-wrap
511 msgid "Userfaultfd operation"
512 msgstr "Работа с userfaultfd"
513
514 #. type: Plain text
515 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
516 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
517 #, fuzzy
518 #| msgid ""
519 #| "After the userfaultfd object is created with B<userfaultfd>(), the "
520 #| "application must enable it using the B<UFFDIO_API> B<ioctl>(2) "
521 #| "operation. This operation allows a handshake between the kernel and user "
522 #| "space to determine the API version and supported features. This "
523 #| "operation must be performed before any of the other B<ioctl>(2) "
524 #| "operations described below (or those operations fail with the B<EINVAL> "
525 #| "error)."
526 msgid ""
527 "After the userfaultfd object is created with B<userfaultfd>(), the "
528 "application must enable it using the B<UFFDIO_API> B<ioctl>(2) operation. "
529 "This operation allows a two-step handshake between the kernel and user space "
530 "to determine what API version and features the kernel supports, and then to "
531 "enable those features user space wants. This operation must be performed "
532 "before any of the other B<ioctl>(2) operations described below (or those "
533 "operations fail with the B<EINVAL> error)."
534 msgstr ""
535 "После создания объекта userfaultfd с помощью B<userfaultfd>() приложение "
536 "должно включить его с помощью операции B<UFFDIO_API> вызова B<ioctl>(2). "
537 "Данная операция позволяет согласовать между ядром и пользовательским "
538 "пространством версию программного интерфейса поддерживаемых свойств. Эта "
539 "операция должна быть выполнено самой первой среди других операций "
540 "B<ioctl>(2), описываемых ниже (в противном случае эти операции завершаются "
541 "ошибкой B<EINVAL>)."
542
543 #. type: Plain text
544 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
545 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
546 #, fuzzy
547 #| msgid ""
548 #| "After a successful B<UFFDIO_API> operation, the application then "
549 #| "registers memory address ranges using the B<UFFDIO_REGISTER> B<ioctl>(2) "
550 #| "operation. After successful completion of a B<UFFDIO_REGISTER> "
551 #| "operation, a page fault occurring in the requested memory range, and "
552 #| "satisfying the mode defined at the registration time, will be forwarded "
553 #| "by the kernel to the user-space application. The application can then "
554 #| "use the B<UFFDIO_COPY ,> B<UFFDIO_ZEROPAGE ,> or B<UFFDIO_CONTINUE> "
555 #| "B<ioctl>(2) operations to resolve the page fault."
556 msgid ""
557 "After a successful B<UFFDIO_API> operation, the application then registers "
558 "memory address ranges using the B<UFFDIO_REGISTER> B<ioctl>(2) operation. "
559 "After successful completion of a B<UFFDIO_REGISTER> operation, a page fault "
560 "occurring in the requested memory range, and satisfying the mode defined at "
561 "the registration time, will be forwarded by the kernel to the user-space "
562 "application. The application can then use various (e.g., B<UFFDIO_COPY>, "
563 "B<UFFDIO_ZEROPAGE>, or B<UFFDIO_CONTINUE>) B<ioctl>(2) operations to "
564 "resolve the page fault."
565 msgstr ""
566 "После успешного выполнения B<UFFDIO_API> приложение должно зарегистрировать "
567 "диапазоны адресов памяти с помощью операции B<UFFDIO_REGISTER> вызова "
568 "B<ioctl>(2). После успешного выполнения B<UFFDIO_REGISTER> страничная "
569 "ошибка, возникающая в запрошенном диапазоне и удовлетворяющая режиму, "
570 "определённому в момент регистрации, будет переслана ядром приложению в "
571 "пользовательском пространстве. Для решения страничной ошибки приложение "
572 "может использовать операцию B<UFFDIO_COPY>, B<UFFDIO_ZEROPAGE> или "
573 "B<UFFDIO_CONTINUE> вызова B<ioctl>(2)."
574
575 #. type: Plain text
576 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
577 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
578 msgid ""
579 "Since Linux 4.14, if the application sets the B<UFFD_FEATURE_SIGBUS> feature "
580 "bit using the B<UFFDIO_API> B<ioctl>(2), no page-fault notification will be "
581 "forwarded to user space. Instead a B<SIGBUS> signal is delivered to the "
582 "faulting process. With this feature, userfaultfd can be used for robustness "
583 "purposes to simply catch any access to areas within the registered address "
584 "range that do not have pages allocated, without having to listen to "
585 "userfaultfd events. No userfaultfd monitor will be required for dealing "
586 "with such memory accesses. For example, this feature can be useful for "
587 "applications that want to prevent the kernel from automatically allocating "
588 "pages and filling holes in sparse files when the hole is accessed through a "
589 "memory mapping."
590 msgstr ""
591 "Начиная с Linux 4.14, если приложение устанавливает бит свойства "
592 "B<UFFD_FEATURE_SIGBUS> с помощью B<UFFDIO_API> B<ioctl>(2), то уведомления о "
593 "страничных ошибках не пересылаются в пользовательское пространство. Вместо "
594 "этого в ошибшийся процесс посылается сигнал B<SIGBUS>. С данным свойством "
595 "userfaultfd можно использовать в целях надёжности, просто ловя все попытки "
596 "доступа к областях внутри зарегистрированного адресного диапазона, в котором "
597 "нет выделенных страниц, не слушая при этом события userfaultfd. При таком "
598 "доступе к памяти не потребуется процесс слежения за userfaultfd. Например, "
599 "данное свойство может оказаться полезным приложениям, которые хотят не "
600 "давать ядру выполнять автоматическое выделение страниц и заполнение дыр в "
601 "разреженных файлах при обращении к дыре через отображение в памяти."
602
603 #. type: Plain text
604 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
605 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
606 msgid ""
607 "The B<UFFD_FEATURE_SIGBUS> feature is implicitly inherited through "
608 "B<fork>(2) if used in combination with B<UFFD_FEATURE_FORK>."
609 msgstr ""
610 "Свойство B<UFFD_FEATURE_SIGBUS> неявно наследуется при B<fork>(2), если "
611 "используется вместе с B<UFFD_FEATURE_FORK>."
612
613 #. type: Plain text
614 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
615 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
616 msgid ""
617 "Details of the various B<ioctl>(2) operations can be found in "
618 "B<ioctl_userfaultfd>(2)."
619 msgstr ""
620 "Подробности о различных операциях B<ioctl>(2) можно найти в "
621 "B<ioctl_userfaultfd>(2)."
622
623 #. type: Plain text
624 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
625 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
626 msgid ""
627 "Since Linux 4.11, events other than page-fault may enabled during "
628 "B<UFFDIO_API> operation."
629 msgstr ""
630 "Начиная с Linux 4.11 при операции B<UFFDIO_API> можно включить не только "
631 "события страничной ошибки."
632
633 #. type: Plain text
634 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
635 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
636 msgid ""
637 "Up to Linux 4.11, userfaultfd can be used only with anonymous private memory "
638 "mappings. Since Linux 4.11, userfaultfd can be also used with hugetlbfs and "
639 "shared memory mappings."
640 msgstr ""
641 "До Linux 4.11 объект userfaultfd мог быть использован только с анонимными "
642 "частными отображениями памяти. Начиная с Linux 4.11 объект userfaultfd может "
643 "также использоваться с отображениями общей памяти и hugetlbfs."
644
645 #. type: SS
646 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
647 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
648 #, no-wrap
649 msgid "Userfaultfd write-protect mode (since Linux 5.7)"
650 msgstr ""
651
652 #. type: Plain text
653 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
654 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
655 msgid ""
656 "Since Linux 5.7, userfaultfd supports write-protect mode for anonymous "
657 "memory. The user needs to first check availability of this feature using "
658 "B<UFFDIO_API> ioctl against the feature bit "
659 "B<UFFD_FEATURE_PAGEFAULT_FLAG_WP> before using this feature."
660 msgstr ""
661
662 #. type: Plain text
663 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
664 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
665 msgid ""
666 "Since Linux 5.19, the write-protection mode was also supported on shmem and "
667 "hugetlbfs memory types. It can be detected with the feature bit "
668 "B<UFFD_FEATURE_WP_HUGETLBFS_SHMEM>."
669 msgstr ""
670
671 #. type: Plain text
672 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
673 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
674 msgid ""
675 "To register with userfaultfd write-protect mode, the user needs to initiate "
676 "the B<UFFDIO_REGISTER> ioctl with mode B<UFFDIO_REGISTER_MODE_WP> set. Note "
677 "that it is legal to monitor the same memory range with multiple modes. For "
678 "example, the user can do B<UFFDIO_REGISTER> with the mode set to "
679 "B<UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP>. When there is "
680 "only B<UFFDIO_REGISTER_MODE_WP> registered, user-space will I<not> receive "
681 "any notification when a missing page is written. Instead, user-space will "
682 "receive a write-protect page-fault notification only when an existing but "
683 "write-protected page got written."
684 msgstr ""
685
686 #. type: Plain text
687 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
688 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
689 msgid ""
690 "After the B<UFFDIO_REGISTER> ioctl completed with B<UFFDIO_REGISTER_MODE_WP> "
691 "mode set, the user can write-protect any existing memory within the range "
692 "using the ioctl B<UFFDIO_WRITEPROTECT> where I<uffdio_writeprotect.mode> "
693 "should be set to B<UFFDIO_WRITEPROTECT_MODE_WP>."
694 msgstr ""
695
696 #. type: Plain text
697 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
698 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
699 msgid ""
700 "When a write-protect event happens, user-space will receive a page-fault "
701 "notification whose I<uffd_msg.pagefault.flags> will be with "
702 "B<UFFD_PAGEFAULT_FLAG_WP> flag set. Note: since only writes can trigger "
703 "this kind of fault, write-protect notifications will always have the "
704 "B<UFFD_PAGEFAULT_FLAG_WRITE> bit set along with the "
705 "B<UFFD_PAGEFAULT_FLAG_WP> bit."
706 msgstr ""
707
708 #. type: Plain text
709 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
710 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
711 msgid ""
712 "To resolve a write-protection page fault, the user should initiate another "
713 "B<UFFDIO_WRITEPROTECT> ioctl, whose I<uffd_msg.pagefault.flags> should have "
714 "the flag B<UFFDIO_WRITEPROTECT_MODE_WP> cleared upon the faulted page or "
715 "range."
716 msgstr ""
717
718 #. type: SS
719 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
720 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
721 #, no-wrap
722 msgid "Userfaultfd minor fault mode (since Linux 5.13)"
723 msgstr ""
724
725 #. type: Plain text
726 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
727 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
728 msgid ""
729 "Since Linux 5.13, userfaultfd supports minor fault mode. In this mode, "
730 "fault messages are produced not for major faults (where the page was "
731 "missing), but rather for minor faults, where a page exists in the page "
732 "cache, but the page table entries are not yet present. The user needs to "
733 "first check availability of this feature using the B<UFFDIO_API> ioctl with "
734 "the appropriate feature bits set before using this feature: "
735 "B<UFFD_FEATURE_MINOR_HUGETLBFS> since Linux 5.13, or "
736 "B<UFFD_FEATURE_MINOR_SHMEM> since Linux 5.14."
737 msgstr ""
738
739 #. type: Plain text
740 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
741 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
742 msgid ""
743 "To register with userfaultfd minor fault mode, the user needs to initiate "
744 "the B<UFFDIO_REGISTER> ioctl with mode B<UFFD_REGISTER_MODE_MINOR> set."
745 msgstr ""
746
747 #. type: Plain text
748 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
749 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
750 msgid ""
751 "When a minor fault occurs, user-space will receive a page-fault notification "
752 "whose I<uffd_msg.pagefault.flags> will have the B<UFFD_PAGEFAULT_FLAG_MINOR> "
753 "flag set."
754 msgstr ""
755
756 #. type: Plain text
757 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
758 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
759 msgid ""
760 "To resolve a minor page fault, the handler should decide whether or not the "
761 "existing page contents need to be modified first. If so, this should be "
762 "done in-place via a second, non-userfaultfd-registered mapping to the same "
763 "backing page (e.g., by mapping the shmem or hugetlbfs file twice). Once the "
764 "page is considered \"up to date\", the fault can be resolved by initiating "
765 "an B<UFFDIO_CONTINUE> ioctl, which installs the page table entries and (by "
766 "default) wakes up the faulting thread(s)."
767 msgstr ""
768
769 #. type: Plain text
770 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
771 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
772 msgid ""
773 "Minor fault mode supports only hugetlbfs-backed (since Linux 5.13) and "
774 "shmem-backed (since Linux 5.14) memory."
775 msgstr ""
776
777 #. type: SS
778 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
779 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
780 #, no-wrap
781 msgid "Reading from the userfaultfd structure"
782 msgstr "Чтение из структуры userfaultfd"
783
784 #. type: Plain text
785 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
786 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
787 msgid ""
788 "Each B<read>(2) from the userfaultfd file descriptor returns one or more "
789 "I<uffd_msg> structures, each of which describes a page-fault event or an "
790 "event required for the non-cooperative userfaultfd usage:"
791 msgstr ""
792 "Каждый вызов B<read>(2) из файлового дескриптора userfaultfd возвращает одну "
793 "или более структур I<uffd_msg>, каждая из которых описывает событие "
794 "страничной ошибки или событие, требуемое для использования userfaultfd в "
795 "разобщённом режиме:"
796
797 #. type: Plain text
798 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
799 #: opensuse-leap-16-1 opensuse-tumbleweed
800 #, no-wrap
801 msgid ""
802 "struct uffd_msg {\n"
803 " __u8 event; /* Type of event */\n"
804 " ...\n"
805 " union {\n"
806 " struct {\n"
807 " __u64 flags; /* Flags describing fault */\n"
808 " __u64 address; /* Faulting address */\n"
809 " union {\n"
810 " __u32 ptid; /* Thread ID of the fault */\n"
811 " } feat;\n"
812 " } pagefault;\n"
813 "\\&\n"
814 " struct { /* Since Linux 4.11 */\n"
815 " __u32 ufd; /* Userfault file descriptor\n"
816 " of the child process */\n"
817 " } fork;\n"
818 "\\&\n"
819 " struct { /* Since Linux 4.11 */\n"
820 " __u64 from; /* Old address of remapped area */\n"
821 " __u64 to; /* New address of remapped area */\n"
822 " __u64 len; /* Original mapping size */\n"
823 " } remap;\n"
824 "\\&\n"
825 " struct { /* Since Linux 4.11 */\n"
826 " __u64 start; /* Start address of removed area */\n"
827 " __u64 end; /* End address of removed area */\n"
828 " } remove;\n"
829 " ...\n"
830 " } arg;\n"
831 "\\&\n"
832 " /* Padding fields omitted */\n"
833 "} __packed;\n"
834 msgstr ""
835
836 #. type: Plain text
837 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
838 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
839 msgid ""
840 "If multiple events are available and the supplied buffer is large enough, "
841 "B<read>(2) returns as many events as will fit in the supplied buffer. If "
842 "the buffer supplied to B<read>(2) is smaller than the size of the "
843 "I<uffd_msg> structure, the B<read>(2) fails with the error B<EINVAL>."
844 msgstr ""
845 "Если доступно несколько событий и переданный буфер достаточного размера, то "
846 "B<read>(2) возвращает столько событий сколько влезает в буфер. Если буфер, "
847 "указанный B<read>(2), меньше размера структуры I<uffd_msg>, то B<read>(2) "
848 "завершается ошибкой B<EINVAL>."
849
850 #. type: Plain text
851 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
852 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
853 msgid "The fields set in the I<uffd_msg> structure are as follows:"
854 msgstr "Поля структуры I<uffd_msg>:"
855
856 #. type: TP
857 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
858 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
859 #, no-wrap
860 msgid "I<event>"
861 msgstr "I<event>"
862
863 #. type: Plain text
864 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
865 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
866 msgid ""
867 "The type of event. Depending of the event type, different fields of the "
868 "I<arg> union represent details required for the event processing. The non-"
869 "page-fault events are generated only when appropriate feature is enabled "
870 "during API handshake with B<UFFDIO_API> B<ioctl>(2)."
871 msgstr ""
872 "Тип события. Тип события влияет на заполняемые поля объединения I<arg>, "
873 "представляющего детали, требуемые для обработки события. События, не "
874 "относящиеся к страничным ошибкам, генерируются только когда включено "
875 "соответствующее свойство при согласовании программного интерфейса с помощью "
876 "операции B<UFFDIO_API> вызова B<ioctl>(2)."
877
878 #. type: Plain text
879 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
880 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
881 msgid "The following values can appear in the I<event> field:"
882 msgstr "В поле I<event> могут появляться следующие значения:"
883
884 #. type: TP
885 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
886 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
887 #, no-wrap
888 msgid "B<UFFD_EVENT_PAGEFAULT> (since Linux 4.3)"
889 msgstr "B<UFFD_EVENT_PAGEFAULT> (начиная с Linux 4.3)"
890
891 #. type: Plain text
892 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
893 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
894 msgid ""
895 "A page-fault event. The page-fault details are available in the "
896 "I<pagefault> field."
897 msgstr "Событие страничной ошибки. Детали ошибки доступны в поле I<pagefault>."
898
899 #. type: TP
900 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
901 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
902 #, no-wrap
903 msgid "B<UFFD_EVENT_FORK> (since Linux 4.11)"
904 msgstr "B<UFFD_EVENT_FORK> (начиная с Linux 4.11)"
905
906 #. FIXME describe duplication of userfault file descriptor during fork
907 #. type: Plain text
908 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
909 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
910 msgid ""
911 "Generated when the faulting process invokes B<fork>(2) (or B<clone>(2) "
912 "without the B<CLONE_VM> flag). The event details are available in the "
913 "I<fork> field."
914 msgstr ""
915 "Генерируется, когда процесс с ошибкой вызывает B<fork>(2) (или B<clone>(2) "
916 "без флага B<CLONE_VM>). Детали ошибки доступны в поле I<fork>."
917
918 #. type: TP
919 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
920 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
921 #, no-wrap
922 msgid "B<UFFD_EVENT_REMAP> (since Linux 4.11)"
923 msgstr "B<UFFD_EVENT_REMAP> (начиная с Linux 4.11)"
924
925 #. type: Plain text
926 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
927 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
928 msgid ""
929 "Generated when the faulting process invokes B<mremap>(2). The event details "
930 "are available in the I<remap> field."
931 msgstr ""
932 "Генерируется, когда процесс с ошибкой вызывает B<mremap>(2). Детали ошибки "
933 "доступны в поле I<remap>."
934
935 #. type: TP
936 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
937 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
938 #, no-wrap
939 msgid "B<UFFD_EVENT_REMOVE> (since Linux 4.11)"
940 msgstr "B<UFFD_EVENT_REMOVE> (начиная с Linux 4.11)"
941
942 #. type: Plain text
943 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
944 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
945 msgid ""
946 "Generated when the faulting process invokes B<madvise>(2) with "
947 "B<MADV_DONTNEED> or B<MADV_REMOVE> advice. The event details are available "
948 "in the I<remove> field."
949 msgstr ""
950 "Генерируется, когда процесс с ошибкой вызывает B<madvise>(2) с советом "
951 "B<MADV_DONTNEED> или B<MADV_REMOVE>. Детали ошибки доступны в поле I<remove>."
952
953 #. type: TP
954 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
955 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
956 #, no-wrap
957 msgid "B<UFFD_EVENT_UNMAP> (since Linux 4.11)"
958 msgstr "B<UFFD_EVENT_UNMAP> (начиная с Linux 4.11)"
959
960 #. type: Plain text
961 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
962 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
963 msgid ""
964 "Generated when the faulting process unmaps a memory range, either explicitly "
965 "using B<munmap>(2) or implicitly during B<mmap>(2) or B<mremap>(2). The "
966 "event details are available in the I<remove> field."
967 msgstr ""
968 "Генерируется, когда процесс с ошибкой отменяет проецирование диапазона "
969 "памяти явным образом с помощью B<munmap>(2) или неявно при вызове B<mmap>(2) "
970 "или B<mremap>(2). Детали ошибки доступны в поле I<remove>."
971
972 #. type: TP
973 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
974 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
975 #, no-wrap
976 msgid "I<pagefault.address>"
977 msgstr "I<pagefault.address>"
978
979 #. type: Plain text
980 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
981 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
982 msgid "The address that triggered the page fault."
983 msgstr "Адрес, из-за которого возникла страничная ошибка."
984
985 #. type: TP
986 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
987 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
988 #, no-wrap
989 msgid "I<pagefault.flags>"
990 msgstr "I<pagefault.flags>"
991
992 #. type: Plain text
993 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
994 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
995 msgid ""
996 "A bit mask of flags that describe the event. For B<UFFD_EVENT_PAGEFAULT>, "
997 "the following flag may appear:"
998 msgstr ""
999 "Битовая маска флагов, описывающих событие. Для B<UFFD_EVENT_PAGEFAULT> может "
1000 "появляться следующий флаг:"
1001
1002 #. type: TP
1003 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1004 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1005 #, no-wrap
1006 msgid "B<UFFD_PAGEFAULT_FLAG_WP>"
1007 msgstr "B<UFFD_PAGEFAULT_FLAG_WP>"
1008
1009 #. type: Plain text
1010 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1011 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1012 msgid "If this flag is set, then the fault was a write-protect fault."
1013 msgstr ""
1014
1015 #. type: TP
1016 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1017 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1018 #, no-wrap
1019 msgid "B<UFFD_PAGEFAULT_FLAG_MINOR>"
1020 msgstr "B<UFFD_PAGEFAULT_FLAG_MINOR>"
1021
1022 #. type: Plain text
1023 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1024 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1025 msgid "If this flag is set, then the fault was a minor fault."
1026 msgstr ""
1027
1028 #. type: TP
1029 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1030 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1031 #, no-wrap
1032 msgid "B<UFFD_PAGEFAULT_FLAG_WRITE>"
1033 msgstr "B<UFFD_PAGEFAULT_FLAG_WRITE>"
1034
1035 #. type: Plain text
1036 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1037 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1038 msgid "If this flag is set, then the fault was a write fault."
1039 msgstr ""
1040
1041 #. type: Plain text
1042 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1043 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1044 msgid ""
1045 "If neither B<UFFD_PAGEFAULT_FLAG_WP> nor B<UFFD_PAGEFAULT_FLAG_MINOR> are "
1046 "set, then the fault was a missing fault."
1047 msgstr ""
1048
1049 #. type: TP
1050 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1051 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1052 #, no-wrap
1053 msgid "I<pagefault.feat.pid>"
1054 msgstr "I<pagefault.feat.pid>"
1055
1056 #. type: Plain text
1057 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1058 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1059 #, fuzzy
1060 #| msgid "The address that triggered the page fault."
1061 msgid "The thread ID that triggered the page fault."
1062 msgstr "Адрес, из-за которого возникла страничная ошибка."
1063
1064 #. type: TP
1065 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1066 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1067 #, no-wrap
1068 msgid "I<fork.ufd>"
1069 msgstr "I<fork.ufd>"
1070
1071 #. type: Plain text
1072 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1073 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1074 msgid ""
1075 "The file descriptor associated with the userfault object created for the "
1076 "child created by B<fork>(2)."
1077 msgstr ""
1078 "С помощью B<fork>(2) был создан потомок, для которого был создан файловый "
1079 "дескриптор, связанный с объектом userfault."
1080
1081 #. type: TP
1082 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1083 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1084 #, no-wrap
1085 msgid "I<remap.from>"
1086 msgstr "I<remap.from>"
1087
1088 #. type: Plain text
1089 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1090 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1091 msgid ""
1092 "The original address of the memory range that was remapped using "
1093 "B<mremap>(2)."
1094 msgstr ""
1095 "Первоначальный адрес диапазона памяти, который был переотображён с помощью "
1096 "B<mremap>(2)."
1097
1098 #. type: TP
1099 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1100 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1101 #, no-wrap
1102 msgid "I<remap.to>"
1103 msgstr "I<remap.to>"
1104
1105 #. type: Plain text
1106 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1107 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1108 msgid ""
1109 "The new address of the memory range that was remapped using B<mremap>(2)."
1110 msgstr ""
1111 "Новый адрес диапазона памяти, который был переотображён с помощью "
1112 "B<mremap>(2)."
1113
1114 #. type: TP
1115 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1116 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1117 #, no-wrap
1118 msgid "I<remap.len>"
1119 msgstr "I<remap.len>"
1120
1121 #. type: Plain text
1122 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1123 #: opensuse-leap-16-1 opensuse-tumbleweed
1124 #, fuzzy
1125 #| msgid ""
1126 #| "The original length of the memory range that was remapped using "
1127 #| "B<mremap>(2)."
1128 msgid ""
1129 "The original size of the memory range that was remapped using B<mremap>(2)."
1130 msgstr ""
1131 "Первоначальный размер диапазона памяти, который был переотображён с помощью "
1132 "B<mremap>(2)."
1133
1134 #. type: TP
1135 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1136 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1137 #, no-wrap
1138 msgid "I<remove.start>"
1139 msgstr "I<remove.start>"
1140
1141 #. type: Plain text
1142 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1143 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1144 msgid ""
1145 "The start address of the memory range that was freed using B<madvise>(2) or "
1146 "unmapped"
1147 msgstr ""
1148 "Начальный адрес диапазона памяти, который был освобождён с помощью "
1149 "B<madvise>(2) или было отменено проецирование."
1150
1151 #. type: TP
1152 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1153 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1154 #, no-wrap
1155 msgid "I<remove.end>"
1156 msgstr "I<remove.end>"
1157
1158 #. type: Plain text
1159 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1160 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1161 msgid ""
1162 "The end address of the memory range that was freed using B<madvise>(2) or "
1163 "unmapped"
1164 msgstr ""
1165 "Конечный адрес диапазона памяти, который был освобождён с помощью "
1166 "B<madvise>(2) или было отменено проецирование."
1167
1168 #. type: Plain text
1169 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1170 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1171 msgid ""
1172 "A B<read>(2) on a userfaultfd file descriptor can fail with the following "
1173 "errors:"
1174 msgstr ""
1175 "Вызов B<read>(2) с файловым дескриптором userfaultfd может завершиться "
1176 "следующими ошибками:"
1177
1178 #. type: TP
1179 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1180 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1181 #, no-wrap
1182 msgid "B<EINVAL>"
1183 msgstr "B<EINVAL>"
1184
1185 #. type: Plain text
1186 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1187 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1188 msgid ""
1189 "The userfaultfd object has not yet been enabled using the B<UFFDIO_API> "
1190 "B<ioctl>(2) operation"
1191 msgstr ""
1192 "Объект userfaultfd не был включён с помощью операции B<UFFDIO_API> вызова "
1193 "B<ioctl>(2)."
1194
1195 #. FIXME What is the reason for this seemingly odd behavior with respect
1196 #. to the O_NONBLOCK flag? (see userfaultfd_poll() in fs/userfaultfd.c).
1197 #. Something needs to be said about this.
1198 #. type: Plain text
1199 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1200 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1201 msgid ""
1202 "If the B<O_NONBLOCK> flag is enabled in the associated open file "
1203 "description, the userfaultfd file descriptor can be monitored with "
1204 "B<poll>(2), B<select>(2), and B<epoll>(7). When events are available, the "
1205 "file descriptor indicates as readable. If the B<O_NONBLOCK> flag is not "
1206 "enabled, then B<poll>(2) (always) indicates the file as having a B<POLLERR> "
1207 "condition, and B<select>(2) indicates the file descriptor as both readable "
1208 "and writable."
1209 msgstr ""
1210 "Если в связанном открытом файловом описании указан флаг B<O_NONBLOCK>, то "
1211 "файловый дескриптор userfaultfd можно отслеживать с помощью B<poll>(2), "
1212 "B<select>(2) и B<epoll>(7). При возникновении событий, файловый дескриптор "
1213 "помечается как доступный на чтение. Если флаг B<O_NONBLOCK> не задан, то "
1214 "B<poll>(2) (всегда) показывает, что файл находится в состоянии B<POLLERR>, а "
1215 "B<select>(2) показывает, что файловый дескриптор доступен на чтение и запись."
1216
1217 #. type: SH
1218 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1219 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1220 #, no-wrap
1221 msgid "RETURN VALUE"
1222 msgstr "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ"
1223
1224 #. type: Plain text
1225 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1226 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1227 #, fuzzy
1228 #| msgid ""
1229 #| "On success, B<userfaultfd>() returns a new file descriptor that refers "
1230 #| "to the userfaultfd object. On error, -1 is returned, and I<errno> is set "
1231 #| "appropriately."
1232 msgid ""
1233 "On success, B<userfaultfd>() returns a new file descriptor that refers to "
1234 "the userfaultfd object. On error, -1 is returned, and I<errno> is set to "
1235 "indicate the error."
1236 msgstr ""
1237 "При успешном выполнении B<userfaultfd>() возвращает новый файловый "
1238 "дескриптор, который ссылается на объект userfaultfd. При ошибке возвращается "
1239 "-1, и I<errno> изменяется соответствующим образом."
1240
1241 #. type: SH
1242 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1243 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1244 #, no-wrap
1245 msgid "ERRORS"
1246 msgstr "ОШИБКИ"
1247
1248 #. type: Plain text
1249 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1250 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1251 msgid "An unsupported value was specified in I<flags>."
1252 msgstr "В I<flags> указано неподдерживаемое значение."
1253
1254 #. type: TP
1255 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1256 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1257 #, no-wrap
1258 msgid "B<EMFILE>"
1259 msgstr "B<EMFILE>"
1260
1261 #. type: Plain text
1262 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1263 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1264 msgid ""
1265 "The per-process limit on the number of open file descriptors has been reached"
1266 msgstr ""
1267 "Было достигнуто ограничение по количеству открытых файловых дескрипторов на "
1268 "процесс."
1269
1270 #. type: TP
1271 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1272 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1273 #, no-wrap
1274 msgid "B<ENFILE>"
1275 msgstr "B<ENFILE>"
1276
1277 #. type: Plain text
1278 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1279 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1280 msgid ""
1281 "The system-wide limit on the total number of open files has been reached."
1282 msgstr "Достигнуто максимальное количество открытых файлов в системе."
1283
1284 #. type: TP
1285 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1286 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1287 #, no-wrap
1288 msgid "B<ENOMEM>"
1289 msgstr "B<ENOMEM>"
1290
1291 #. type: Plain text
1292 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1293 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1294 msgid "Insufficient kernel memory was available."
1295 msgstr "Недостаточное количество памяти ядра."
1296
1297 #. type: TP
1298 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1299 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1300 #, no-wrap
1301 msgid "B<EPERM> (since Linux 5.2)"
1302 msgstr "B<EPERM> (начиная с Linux 5.2)"
1303
1304 #. cefdca0a86be517bc390fc4541e3674b8e7803b0
1305 #. type: Plain text
1306 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1307 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1308 msgid ""
1309 "The caller is not privileged (does not have the B<CAP_SYS_PTRACE> capability "
1310 "in the initial user namespace), and I</proc/sys/vm/unprivileged_userfaultfd> "
1311 "has the value 0."
1312 msgstr ""
1313
1314 #. type: SH
1315 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1316 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1317 #, no-wrap
1318 msgid "STANDARDS"
1319 msgstr "СТАНДАРТЫ"
1320
1321 #. type: Plain text
1322 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1323 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1324 msgid "Linux."
1325 msgstr "Linux."
1326
1327 #. type: SH
1328 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1329 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1330 #, no-wrap
1331 msgid "HISTORY"
1332 msgstr "ИСТОРИЯ"
1333
1334 #. type: Plain text
1335 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1336 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1337 msgid "Linux 4.3."
1338 msgstr "Linux 4.3."
1339
1340 #. type: Plain text
1341 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1342 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1343 #, fuzzy
1344 #| msgid ""
1345 #| "The support for hugetlbfs and shared memory areas and non-page-fault "
1346 #| "events was added in Linux 4.11"
1347 msgid ""
1348 "Support for hugetlbfs and shared memory areas and non-page-fault events was "
1349 "added in Linux 4.11"
1350 msgstr ""
1351 "Поддержка hugetlbfs и общих областей памяти, а также событий, не относящихся "
1352 "к страничным ошибкам, была добавлена в Linux 4.11."
1353
1354 #. type: SH
1355 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1356 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1357 #, no-wrap
1358 msgid "NOTES"
1359 msgstr "ПРИМЕЧАНИЯ"
1360
1361 #. type: Plain text
1362 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1363 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1364 msgid ""
1365 "The userfaultfd mechanism can be used as an alternative to traditional user-"
1366 "space paging techniques based on the use of the B<SIGSEGV> signal and "
1367 "B<mmap>(2). It can also be used to implement lazy restore for checkpoint/"
1368 "restore mechanisms, as well as post-copy migration to allow (nearly) "
1369 "uninterrupted execution when transferring virtual machines and Linux "
1370 "containers from one host to another."
1371 msgstr ""
1372 "Механизм userfaultfd может быть использован как альтернатива обычному "
1373 "страничному делению пользовательского пространства на основе использования "
1374 "сигнала B<SIGSEGV> и B<mmap>(2). Также он может быть использован для "
1375 "реализации отложенного (lazy) восстановления checkpoint/restore mechanisms, "
1376 "as well as post-copy migration to allow (почти) не прерываемого выполнения "
1377 "при переносе виртуальных машин и контейнеров Linux с одного узла на другой."
1378
1379 #. type: SH
1380 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1381 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1382 #, no-wrap
1383 msgid "BUGS"
1384 msgstr "ПРОГРАММНЫЕ ОШИБКИ"
1385
1386 #. type: Plain text
1387 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1388 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1389 msgid ""
1390 "If the B<UFFD_FEATURE_EVENT_FORK> is enabled and a system call from the "
1391 "B<fork>(2) family is interrupted by a signal or failed, a stale userfaultfd "
1392 "descriptor might be created. In this case, a spurious B<UFFD_EVENT_FORK> "
1393 "will be delivered to the userfaultfd monitor."
1394 msgstr ""
1395 "Если указано B<UFFD_FEATURE_EVENT_FORK> и системный вызов из семейства "
1396 "B<fork>(2) прерывается по сигналу или завершается ошибкой, то может быть "
1397 "создан повисший дескриптор userfaultfd. В этом случае программе слежения за "
1398 "userfaultfd может быть доставлен ложный B<UFFD_EVENT_FORK>."
1399
1400 #. type: SH
1401 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1402 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1403 #, no-wrap
1404 msgid "EXAMPLES"
1405 msgstr "ПРИМЕРЫ"
1406
1407 #. type: Plain text
1408 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1409 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1410 msgid ""
1411 "The program below demonstrates the use of the userfaultfd mechanism. The "
1412 "program creates two threads, one of which acts as the page-fault handler for "
1413 "the process, for the pages in a demand-page zero region created using "
1414 "B<mmap>(2)."
1415 msgstr ""
1416 "Программа, представленная далее, показывает использование механизма "
1417 "userfaultfd. Она создаёт две нити, одна служит обработчиком страничных "
1418 "ошибок процесса для страниц в режиме выделения при необходимости, созданных "
1419 "B<mmap>(2)."
1420
1421 #. type: Plain text
1422 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1423 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1424 msgid ""
1425 "The program takes one command-line argument, which is the number of pages "
1426 "that will be created in a mapping whose page faults will be handled via "
1427 "userfaultfd. After creating a userfaultfd object, the program then creates "
1428 "an anonymous private mapping of the specified size and registers the address "
1429 "range of that mapping using the B<UFFDIO_REGISTER> B<ioctl>(2) operation. "
1430 "The program then creates a second thread that will perform the task of "
1431 "handling page faults."
1432 msgstr ""
1433 "Программа имеет один параметр командной строки, определяющий количество "
1434 "страниц, которые будут созданы в отображении, чьи страничные ошибки будут "
1435 "обработаны userfaultfd. После создания объекта userfaultfd программа создаёт "
1436 "анонимное частное отображение указанного размера и регистрирует адресный "
1437 "диапазон отображения с помощью операции B<UFFDIO_REGISTER> вызовом "
1438 "B<ioctl>(2). После этого программа создаёт вторую нить, которая будет "
1439 "выполнять задачу по обработке страничных ошибок."
1440
1441 #. type: Plain text
1442 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1443 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1444 msgid ""
1445 "The main thread then walks through the pages of the mapping fetching bytes "
1446 "from successive pages. Because the pages have not yet been accessed, the "
1447 "first access of a byte in each page will trigger a page-fault event on the "
1448 "userfaultfd file descriptor."
1449 msgstr ""
1450 "После этого главная нить обходит страницы отображения запрашивая байты "
1451 "следующей страницы. Так как к страницам ещё не обращались, первый доступ к "
1452 "байту в каждой странице будет вызывать событие страничной ошибки в файловом "
1453 "дескрипторе userfaultfd."
1454
1455 #. type: Plain text
1456 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1457 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1458 msgid ""
1459 "Each of the page-fault events is handled by the second thread, which sits in "
1460 "a loop processing input from the userfaultfd file descriptor. In each loop "
1461 "iteration, the second thread first calls B<poll>(2) to check the state of "
1462 "the file descriptor, and then reads an event from the file descriptor. All "
1463 "such events should be B<UFFD_EVENT_PAGEFAULT> events, which the thread "
1464 "handles by copying a page of data into the faulting region using the "
1465 "B<UFFDIO_COPY> B<ioctl>(2) operation."
1466 msgstr ""
1467 "Каждое событие страничной ошибки обрабатывается второй нитью, которая "
1468 "выполняет цикл обработки ввода из файлового дескриптора userfaultfd. При "
1469 "каждом проходе цикла вторая нить сначала вызывает B<poll>(2) для проверки "
1470 "состояния файлового дескриптора, затем читает событие из файлового "
1471 "дескриптора. Все события должны быть B<UFFD_EVENT_PAGEFAULT>, для их "
1472 "обработки нить копирует страницу данных в ошибочную область с помощью "
1473 "операции B<UFFDIO_COPY> вызова B<ioctl>(2)."
1474
1475 #. type: Plain text
1476 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1477 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1478 msgid "The following is an example of what we see when running the program:"
1479 msgstr "Результат работы программы:"
1480
1481 #. type: Plain text
1482 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1483 #: opensuse-tumbleweed
1484 #, no-wrap
1485 msgid ""
1486 "$B< ./userfaultfd_demo 3>;\n"
1487 "Address returned by mmap() = 0x7fd30106c000\n"
1488 "\\&\n"
1489 "fault_handler_thread():\n"
1490 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1491 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n"
1492 " (uffdio_copy.copy returned 4096)\n"
1493 "Read address 0x7fd30106c00f in main(): A\n"
1494 "Read address 0x7fd30106c40f in main(): A\n"
1495 "Read address 0x7fd30106c80f in main(): A\n"
1496 "Read address 0x7fd30106cc0f in main(): A\n"
1497 "\\&\n"
1498 "fault_handler_thread():\n"
1499 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1500 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n"
1501 " (uffdio_copy.copy returned 4096)\n"
1502 "Read address 0x7fd30106d00f in main(): B\n"
1503 "Read address 0x7fd30106d40f in main(): B\n"
1504 "Read address 0x7fd30106d80f in main(): B\n"
1505 "Read address 0x7fd30106dc0f in main(): B\n"
1506 "\\&\n"
1507 "fault_handler_thread():\n"
1508 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1509 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n"
1510 " (uffdio_copy.copy returned 4096)\n"
1511 "Read address 0x7fd30106e00f in main(): C\n"
1512 "Read address 0x7fd30106e40f in main(): C\n"
1513 "Read address 0x7fd30106e80f in main(): C\n"
1514 "Read address 0x7fd30106ec0f in main(): C\n"
1515 msgstr ""
1516
1517 #. type: SS
1518 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1519 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1520 #, no-wrap
1521 msgid "Program source"
1522 msgstr "Исходный код программы"
1523
1524 #. type: Plain text
1525 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
1526 #, no-wrap
1527 msgid ""
1528 "/* userfaultfd_demo.c\n"
1529 "\\&\n"
1530 " Licensed under the GNU General Public License version 2 or later.\n"
1531 "*/\n"
1532 "#define _GNU_SOURCE\n"
1533 "#include E<lt>err.hE<gt>\n"
1534 "#include E<lt>errno.hE<gt>\n"
1535 "#include E<lt>fcntl.hE<gt>\n"
1536 "#include E<lt>inttypes.hE<gt>\n"
1537 "#include E<lt>linux/userfaultfd.hE<gt>\n"
1538 "#include E<lt>poll.hE<gt>\n"
1539 "#include E<lt>pthread.hE<gt>\n"
1540 "#include E<lt>stdio.hE<gt>\n"
1541 "#include E<lt>stdlib.hE<gt>\n"
1542 "#include E<lt>string.hE<gt>\n"
1543 "#include E<lt>sys/ioctl.hE<gt>\n"
1544 "#include E<lt>sys/mman.hE<gt>\n"
1545 "#include E<lt>sys/syscall.hE<gt>\n"
1546 "#include E<lt>unistd.hE<gt>\n"
1547 "\\&\n"
1548 "static int page_size;\n"
1549 "\\&\n"
1550 "static void *\n"
1551 "fault_handler_thread(void *arg)\n"
1552 "{\n"
1553 " long uffd; /* userfaultfd file descriptor */\n"
1554 "\\&\n"
1555 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
1556 " static char *page = NULL;\n"
1557 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
1558 "\\&\n"
1559 " uffd = (long) arg;\n"
1560 "\\&\n"
1561 " /* Create a page that will be copied into the faulting region. */\n"
1562 "\\&\n"
1563 " if (page == NULL) {\n"
1564 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
1565 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
1566 " if (page == MAP_FAILED)\n"
1567 " err(EXIT_FAILURE, \"mmap\");\n"
1568 " }\n"
1569 "\\&\n"
1570 " /* Loop, handling incoming events on the userfaultfd\n"
1571 " file descriptor. */\n"
1572 "\\&\n"
1573 " for (;;) {\n"
1574 " int nready;\n"
1575 " ssize_t nread;\n"
1576 " struct pollfd pollfd;\n"
1577 " struct uffdio_copy uffdio_copy;\n"
1578 "\\&\n"
1579 " /* See what poll() tells us about the userfaultfd. */\n"
1580 "\\&\n"
1581 " pollfd.fd = uffd;\n"
1582 " pollfd.events = POLLIN;\n"
1583 " nready = poll(&pollfd, 1, -1);\n"
1584 " if (nready == -1)\n"
1585 " err(EXIT_FAILURE, \"poll\");\n"
1586 "\\&\n"
1587 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
1588 " printf(\" poll() returns: nready = %d; \"\n"
1589 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
1590 " (pollfd.revents & POLLIN) != 0,\n"
1591 " (pollfd.revents & POLLERR) != 0);\n"
1592 "\\&\n"
1593 " /* Read an event from the userfaultfd. */\n"
1594 "\\&\n"
1595 " nread = read(uffd, &msg, sizeof(msg));\n"
1596 " if (nread == 0) {\n"
1597 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
1598 " exit(EXIT_FAILURE);\n"
1599 " }\n"
1600 "\\&\n"
1601 " if (nread == -1)\n"
1602 " err(EXIT_FAILURE, \"read\");\n"
1603 "\\&\n"
1604 " /* We expect only one kind of event; verify that assumption. */\n"
1605 "\\&\n"
1606 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
1607 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
1608 " exit(EXIT_FAILURE);\n"
1609 " }\n"
1610 "\\&\n"
1611 " /* Display info about the page-fault event. */\n"
1612 "\\&\n"
1613 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
1614 " printf(\"flags = %w64x; \", msg.arg.pagefault.flags);\n"
1615 " printf(\"address = %w64x\\[rs]n\", msg.arg.pagefault.address);\n"
1616 "\\&\n"
1617 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
1618 " region. Vary the contents that are copied in, so that it\n"
1619 " is more obvious that each fault is handled separately. */\n"
1620 "\\&\n"
1621 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
1622 " fault_cnt++;\n"
1623 "\\&\n"
1624 " uffdio_copy.src = (unsigned long) page;\n"
1625 "\\&\n"
1626 " /* We need to handle page faults in units of pages(!).\n"
1627 " So, round faulting address down to page boundary. */\n"
1628 "\\&\n"
1629 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
1630 " \\[ti](page_size - 1);\n"
1631 " uffdio_copy.len = page_size;\n"
1632 " uffdio_copy.mode = 0;\n"
1633 " uffdio_copy.copy = 0;\n"
1634 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
1635 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
1636 "\\&\n"
1637 " printf(\" (uffdio_copy.copy returned %w64d)\\[rs]n\",\n"
1638 " uffdio_copy.copy);\n"
1639 " }\n"
1640 "}\n"
1641 "\\&\n"
1642 "int\n"
1643 "main(int argc, char *argv[])\n"
1644 "{\n"
1645 " int s;\n"
1646 " char *addr; /* Start of region handled by userfaultfd */\n"
1647 " long uffd; /* userfaultfd file descriptor */\n"
1648 " size_t size, i; /* Size of region handled by userfaultfd */\n"
1649 " pthread_t thr; /* ID of thread that handles page faults */\n"
1650 " struct uffdio_api uffdio_api;\n"
1651 " struct uffdio_register uffdio_register;\n"
1652 "\\&\n"
1653 " if (argc != 2) {\n"
1654 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
1655 " exit(EXIT_FAILURE);\n"
1656 " }\n"
1657 "\\&\n"
1658 " page_size = sysconf(_SC_PAGE_SIZE);\n"
1659 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
1660 "\\&\n"
1661 " /* Create and enable userfaultfd object. */\n"
1662 "\\&\n"
1663 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
1664 " if (uffd == -1)\n"
1665 " err(EXIT_FAILURE, \"userfaultfd\");\n"
1666 "\\&\n"
1667 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
1668 " example doesn't require any specific features.\n"
1669 "\\&\n"
1670 " Programs that *do* should call UFFDIO_API twice: once with\n"
1671 " `features = 0` to detect features supported by this kernel, and\n"
1672 " again with the subset of features the program actually wants to\n"
1673 " enable. */\n"
1674 " uffdio_api.api = UFFD_API;\n"
1675 " uffdio_api.features = 0;\n"
1676 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
1677 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
1678 "\\&\n"
1679 " /* Create a private anonymous mapping. The memory will be\n"
1680 " demand-zero paged--that is, not yet allocated. When we\n"
1681 " actually touch the memory, it will be allocated via\n"
1682 " the userfaultfd. */\n"
1683 "\\&\n"
1684 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
1685 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
1686 " if (addr == MAP_FAILED)\n"
1687 " err(EXIT_FAILURE, \"mmap\");\n"
1688 "\\&\n"
1689 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
1690 "\\&\n"
1691 " /* Register the memory range of the mapping we just created for\n"
1692 " handling by the userfaultfd object. In mode, we request to track\n"
1693 " missing pages (i.e., pages that have not yet been faulted in). */\n"
1694 "\\&\n"
1695 " uffdio_register.range.start = (unsigned long) addr;\n"
1696 " uffdio_register.range.len = size;\n"
1697 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
1698 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
1699 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
1700 "\\&\n"
1701 " /* Create a thread that will process the userfaultfd events. */\n"
1702 "\\&\n"
1703 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
1704 " if (s != 0) {\n"
1705 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
1706 " }\n"
1707 "\\&\n"
1708 " /* Main thread now touches memory in the mapping, touching\n"
1709 " locations 1024 bytes apart. This will trigger userfaultfd\n"
1710 " events for all pages in the region. */\n"
1711 "\\&\n"
1712 " i = 0xf; /* Ensure that faulting address is not on a page\n"
1713 " boundary, in order to test that we correctly\n"
1714 " handle that case in fault_handling_thread(). */\n"
1715 " while (i E<lt> size) {\n"
1716 " char c;\n"
1717 "\\&\n"
1718 " c = addr[i];\n"
1719 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
1720 " printf(\"%c\\[rs]n\", c);\n"
1721 " i += 1024;\n"
1722 " usleep(100000); /* Slow things down a little */\n"
1723 " }\n"
1724 "\\&\n"
1725 " exit(EXIT_SUCCESS);\n"
1726 "}\n"
1727 msgstr ""
1728
1729 #. SRC END
1730 #. type: SH
1731 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1732 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1733 #, no-wrap
1734 msgid "SEE ALSO"
1735 msgstr "СМОТРИТЕ ТАКЖЕ"
1736
1737 #. type: Plain text
1738 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1739 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1740 msgid ""
1741 "B<fcntl>(2), B<ioctl>(2), B<ioctl_userfaultfd>(2), B<madvise>(2), B<mmap>(2)"
1742 msgstr ""
1743 "B<fcntl>(2), B<ioctl>(2), B<ioctl_userfaultfd>(2), B<madvise>(2), B<mmap>(2)"
1744
1745 #. type: Plain text
1746 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1747 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1748 msgid ""
1749 "I<Documentation/admin-guide/mm/userfaultfd.rst> in the Linux kernel source "
1750 "tree"
1751 msgstr ""
1752 "Файл I<Documentation/admin-guide/mm/userfaultfd.rst> из дерева исходного "
1753 "кода ядра Linux"
1754
1755 #. type: TH
1756 #: debian-trixie
1757 #, no-wrap
1758 msgid "2024-06-15"
1759 msgstr "15 июня 2024 г."
1760
1761 #. type: TH
1762 #: debian-trixie
1763 #, no-wrap
1764 msgid "Linux man-pages 6.9.1"
1765 msgstr "Страницы руководства Linux 6.9.1"
1766
1767 #. type: Plain text
1768 #: debian-trixie
1769 msgid "Standard C library (I<libc>, I<-lc>)"
1770 msgstr "Стандартная библиотека языка C (I<libc>, I<-lc>)"
1771
1772 #. type: Plain text
1773 #: debian-trixie
1774 #, no-wrap
1775 msgid ""
1776 "struct uffd_msg {\n"
1777 " __u8 event; /* Type of event */\n"
1778 " ...\n"
1779 " union {\n"
1780 " struct {\n"
1781 " __u64 flags; /* Flags describing fault */\n"
1782 " __u64 address; /* Faulting address */\n"
1783 " union {\n"
1784 " __u32 ptid; /* Thread ID of the fault */\n"
1785 " } feat;\n"
1786 " } pagefault;\n"
1787 "\\&\n"
1788 " struct { /* Since Linux 4.11 */\n"
1789 " __u32 ufd; /* Userfault file descriptor\n"
1790 " of the child process */\n"
1791 " } fork;\n"
1792 "\\&\n"
1793 " struct { /* Since Linux 4.11 */\n"
1794 " __u64 from; /* Old address of remapped area */\n"
1795 " __u64 to; /* New address of remapped area */\n"
1796 " __u64 len; /* Original mapping length */\n"
1797 " } remap;\n"
1798 "\\&\n"
1799 " struct { /* Since Linux 4.11 */\n"
1800 " __u64 start; /* Start address of removed area */\n"
1801 " __u64 end; /* End address of removed area */\n"
1802 " } remove;\n"
1803 " ...\n"
1804 " } arg;\n"
1805 "\\&\n"
1806 " /* Padding fields omitted */\n"
1807 "} __packed;\n"
1808 msgstr ""
1809
1810 #. type: Plain text
1811 #: debian-trixie
1812 msgid ""
1813 "The original length of the memory range that was remapped using B<mremap>(2)."
1814 msgstr ""
1815 "Первоначальный размер диапазона памяти, который был переотображён с помощью "
1816 "B<mremap>(2)."
1817
1818 #. type: Plain text
1819 #: debian-trixie fedora-44 fedora-rawhide
1820 #, no-wrap
1821 msgid ""
1822 "$ B<./userfaultfd_demo 3>\n"
1823 "Address returned by mmap() = 0x7fd30106c000\n"
1824 "\\&\n"
1825 "fault_handler_thread():\n"
1826 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1827 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n"
1828 " (uffdio_copy.copy returned 4096)\n"
1829 "Read address 0x7fd30106c00f in main(): A\n"
1830 "Read address 0x7fd30106c40f in main(): A\n"
1831 "Read address 0x7fd30106c80f in main(): A\n"
1832 "Read address 0x7fd30106cc0f in main(): A\n"
1833 "\\&\n"
1834 "fault_handler_thread():\n"
1835 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1836 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n"
1837 " (uffdio_copy.copy returned 4096)\n"
1838 "Read address 0x7fd30106d00f in main(): B\n"
1839 "Read address 0x7fd30106d40f in main(): B\n"
1840 "Read address 0x7fd30106d80f in main(): B\n"
1841 "Read address 0x7fd30106dc0f in main(): B\n"
1842 "\\&\n"
1843 "fault_handler_thread():\n"
1844 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1845 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n"
1846 " (uffdio_copy.copy returned 4096)\n"
1847 "Read address 0x7fd30106e00f in main(): C\n"
1848 "Read address 0x7fd30106e40f in main(): C\n"
1849 "Read address 0x7fd30106e80f in main(): C\n"
1850 "Read address 0x7fd30106ec0f in main(): C\n"
1851 msgstr ""
1852
1853 #. type: Plain text
1854 #: debian-trixie
1855 #, no-wrap
1856 msgid ""
1857 "/* userfaultfd_demo.c\n"
1858 "\\&\n"
1859 " Licensed under the GNU General Public License version 2 or later.\n"
1860 "*/\n"
1861 "#define _GNU_SOURCE\n"
1862 "#include E<lt>err.hE<gt>\n"
1863 "#include E<lt>errno.hE<gt>\n"
1864 "#include E<lt>fcntl.hE<gt>\n"
1865 "#include E<lt>inttypes.hE<gt>\n"
1866 "#include E<lt>linux/userfaultfd.hE<gt>\n"
1867 "#include E<lt>poll.hE<gt>\n"
1868 "#include E<lt>pthread.hE<gt>\n"
1869 "#include E<lt>stdio.hE<gt>\n"
1870 "#include E<lt>stdlib.hE<gt>\n"
1871 "#include E<lt>string.hE<gt>\n"
1872 "#include E<lt>sys/ioctl.hE<gt>\n"
1873 "#include E<lt>sys/mman.hE<gt>\n"
1874 "#include E<lt>sys/syscall.hE<gt>\n"
1875 "#include E<lt>unistd.hE<gt>\n"
1876 "\\&\n"
1877 "static int page_size;\n"
1878 "\\&\n"
1879 "static void *\n"
1880 "fault_handler_thread(void *arg)\n"
1881 "{\n"
1882 " int nready;\n"
1883 " long uffd; /* userfaultfd file descriptor */\n"
1884 " ssize_t nread;\n"
1885 " struct pollfd pollfd;\n"
1886 " struct uffdio_copy uffdio_copy;\n"
1887 "\\&\n"
1888 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
1889 " static char *page = NULL;\n"
1890 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
1891 "\\&\n"
1892 " uffd = (long) arg;\n"
1893 "\\&\n"
1894 " /* Create a page that will be copied into the faulting region. */\n"
1895 "\\&\n"
1896 " if (page == NULL) {\n"
1897 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
1898 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
1899 " if (page == MAP_FAILED)\n"
1900 " err(EXIT_FAILURE, \"mmap\");\n"
1901 " }\n"
1902 "\\&\n"
1903 " /* Loop, handling incoming events on the userfaultfd\n"
1904 " file descriptor. */\n"
1905 "\\&\n"
1906 " for (;;) {\n"
1907 "\\&\n"
1908 " /* See what poll() tells us about the userfaultfd. */\n"
1909 "\\&\n"
1910 " pollfd.fd = uffd;\n"
1911 " pollfd.events = POLLIN;\n"
1912 " nready = poll(&pollfd, 1, -1);\n"
1913 " if (nready == -1)\n"
1914 " err(EXIT_FAILURE, \"poll\");\n"
1915 "\\&\n"
1916 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
1917 " printf(\" poll() returns: nready = %d; \"\n"
1918 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
1919 " (pollfd.revents & POLLIN) != 0,\n"
1920 " (pollfd.revents & POLLERR) != 0);\n"
1921 "\\&\n"
1922 " /* Read an event from the userfaultfd. */\n"
1923 "\\&\n"
1924 " nread = read(uffd, &msg, sizeof(msg));\n"
1925 " if (nread == 0) {\n"
1926 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
1927 " exit(EXIT_FAILURE);\n"
1928 " }\n"
1929 "\\&\n"
1930 " if (nread == -1)\n"
1931 " err(EXIT_FAILURE, \"read\");\n"
1932 "\\&\n"
1933 " /* We expect only one kind of event; verify that assumption. */\n"
1934 "\\&\n"
1935 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
1936 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
1937 " exit(EXIT_FAILURE);\n"
1938 " }\n"
1939 "\\&\n"
1940 " /* Display info about the page-fault event. */\n"
1941 "\\&\n"
1942 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
1943 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
1944 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
1945 "\\&\n"
1946 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
1947 " region. Vary the contents that are copied in, so that it\n"
1948 " is more obvious that each fault is handled separately. */\n"
1949 "\\&\n"
1950 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
1951 " fault_cnt++;\n"
1952 "\\&\n"
1953 " uffdio_copy.src = (unsigned long) page;\n"
1954 "\\&\n"
1955 " /* We need to handle page faults in units of pages(!).\n"
1956 " So, round faulting address down to page boundary. */\n"
1957 "\\&\n"
1958 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
1959 " \\[ti](page_size - 1);\n"
1960 " uffdio_copy.len = page_size;\n"
1961 " uffdio_copy.mode = 0;\n"
1962 " uffdio_copy.copy = 0;\n"
1963 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
1964 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
1965 "\\&\n"
1966 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
1967 " uffdio_copy.copy);\n"
1968 " }\n"
1969 "}\n"
1970 "\\&\n"
1971 "int\n"
1972 "main(int argc, char *argv[])\n"
1973 "{\n"
1974 " int s;\n"
1975 " char c;\n"
1976 " char *addr; /* Start of region handled by userfaultfd */\n"
1977 " long uffd; /* userfaultfd file descriptor */\n"
1978 " size_t len, l; /* Length of region handled by userfaultfd */\n"
1979 " pthread_t thr; /* ID of thread that handles page faults */\n"
1980 " struct uffdio_api uffdio_api;\n"
1981 " struct uffdio_register uffdio_register;\n"
1982 "\\&\n"
1983 " if (argc != 2) {\n"
1984 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
1985 " exit(EXIT_FAILURE);\n"
1986 " }\n"
1987 "\\&\n"
1988 " page_size = sysconf(_SC_PAGE_SIZE);\n"
1989 " len = strtoull(argv[1], NULL, 0) * page_size;\n"
1990 "\\&\n"
1991 " /* Create and enable userfaultfd object. */\n"
1992 "\\&\n"
1993 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
1994 " if (uffd == -1)\n"
1995 " err(EXIT_FAILURE, \"userfaultfd\");\n"
1996 "\\&\n"
1997 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
1998 " example doesn't require any specific features.\n"
1999 "\\&\n"
2000 " Programs that *do* should call UFFDIO_API twice: once with\n"
2001 " `features = 0` to detect features supported by this kernel, and\n"
2002 " again with the subset of features the program actually wants to\n"
2003 " enable. */\n"
2004 " uffdio_api.api = UFFD_API;\n"
2005 " uffdio_api.features = 0;\n"
2006 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
2007 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
2008 "\\&\n"
2009 " /* Create a private anonymous mapping. The memory will be\n"
2010 " demand-zero paged--that is, not yet allocated. When we\n"
2011 " actually touch the memory, it will be allocated via\n"
2012 " the userfaultfd. */\n"
2013 "\\&\n"
2014 " addr = mmap(NULL, len, PROT_READ | PROT_WRITE,\n"
2015 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2016 " if (addr == MAP_FAILED)\n"
2017 " err(EXIT_FAILURE, \"mmap\");\n"
2018 "\\&\n"
2019 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
2020 "\\&\n"
2021 " /* Register the memory range of the mapping we just created for\n"
2022 " handling by the userfaultfd object. In mode, we request to track\n"
2023 " missing pages (i.e., pages that have not yet been faulted in). */\n"
2024 "\\&\n"
2025 " uffdio_register.range.start = (unsigned long) addr;\n"
2026 " uffdio_register.range.len = len;\n"
2027 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
2028 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
2029 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
2030 "\\&\n"
2031 " /* Create a thread that will process the userfaultfd events. */\n"
2032 "\\&\n"
2033 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
2034 " if (s != 0) {\n"
2035 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
2036 " }\n"
2037 "\\&\n"
2038 " /* Main thread now touches memory in the mapping, touching\n"
2039 " locations 1024 bytes apart. This will trigger userfaultfd\n"
2040 " events for all pages in the region. */\n"
2041 "\\&\n"
2042 " l = 0xf; /* Ensure that faulting address is not on a page\n"
2043 " boundary, in order to test that we correctly\n"
2044 " handle that case in fault_handling_thread(). */\n"
2045 " while (l E<lt> len) {\n"
2046 " c = addr[l];\n"
2047 " printf(\"Read address %p in %s(): \", addr + l, __func__);\n"
2048 " printf(\"%c\\[rs]n\", c);\n"
2049 " l += 1024;\n"
2050 " usleep(100000); /* Slow things down a little */\n"
2051 " }\n"
2052 "\\&\n"
2053 " exit(EXIT_SUCCESS);\n"
2054 "}\n"
2055 msgstr ""
2056
2057 #. type: TH
2058 #: fedora-44 fedora-rawhide
2059 #, no-wrap
2060 msgid "2024-11-17"
2061 msgstr "17 ноября 2024 г."
2062
2063 #. type: TH
2064 #: fedora-44 fedora-rawhide
2065 #, no-wrap
2066 msgid "Linux man-pages 6.13"
2067 msgstr "Страницы руководства Linux 6.13"
2068
2069 #. type: Plain text
2070 #: fedora-44 fedora-rawhide
2071 #, no-wrap
2072 msgid ""
2073 "/* userfaultfd_demo.c\n"
2074 "\\&\n"
2075 " Licensed under the GNU General Public License version 2 or later.\n"
2076 "*/\n"
2077 "#define _GNU_SOURCE\n"
2078 "#include E<lt>err.hE<gt>\n"
2079 "#include E<lt>errno.hE<gt>\n"
2080 "#include E<lt>fcntl.hE<gt>\n"
2081 "#include E<lt>inttypes.hE<gt>\n"
2082 "#include E<lt>linux/userfaultfd.hE<gt>\n"
2083 "#include E<lt>poll.hE<gt>\n"
2084 "#include E<lt>pthread.hE<gt>\n"
2085 "#include E<lt>stdio.hE<gt>\n"
2086 "#include E<lt>stdlib.hE<gt>\n"
2087 "#include E<lt>string.hE<gt>\n"
2088 "#include E<lt>sys/ioctl.hE<gt>\n"
2089 "#include E<lt>sys/mman.hE<gt>\n"
2090 "#include E<lt>sys/syscall.hE<gt>\n"
2091 "#include E<lt>unistd.hE<gt>\n"
2092 "\\&\n"
2093 "static int page_size;\n"
2094 "\\&\n"
2095 "static void *\n"
2096 "fault_handler_thread(void *arg)\n"
2097 "{\n"
2098 " int nready;\n"
2099 " long uffd; /* userfaultfd file descriptor */\n"
2100 " ssize_t nread;\n"
2101 " struct pollfd pollfd;\n"
2102 " struct uffdio_copy uffdio_copy;\n"
2103 "\\&\n"
2104 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
2105 " static char *page = NULL;\n"
2106 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
2107 "\\&\n"
2108 " uffd = (long) arg;\n"
2109 "\\&\n"
2110 " /* Create a page that will be copied into the faulting region. */\n"
2111 "\\&\n"
2112 " if (page == NULL) {\n"
2113 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
2114 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2115 " if (page == MAP_FAILED)\n"
2116 " err(EXIT_FAILURE, \"mmap\");\n"
2117 " }\n"
2118 "\\&\n"
2119 " /* Loop, handling incoming events on the userfaultfd\n"
2120 " file descriptor. */\n"
2121 "\\&\n"
2122 " for (;;) {\n"
2123 "\\&\n"
2124 " /* See what poll() tells us about the userfaultfd. */\n"
2125 "\\&\n"
2126 " pollfd.fd = uffd;\n"
2127 " pollfd.events = POLLIN;\n"
2128 " nready = poll(&pollfd, 1, -1);\n"
2129 " if (nready == -1)\n"
2130 " err(EXIT_FAILURE, \"poll\");\n"
2131 "\\&\n"
2132 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
2133 " printf(\" poll() returns: nready = %d; \"\n"
2134 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
2135 " (pollfd.revents & POLLIN) != 0,\n"
2136 " (pollfd.revents & POLLERR) != 0);\n"
2137 "\\&\n"
2138 " /* Read an event from the userfaultfd. */\n"
2139 "\\&\n"
2140 " nread = read(uffd, &msg, sizeof(msg));\n"
2141 " if (nread == 0) {\n"
2142 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
2143 " exit(EXIT_FAILURE);\n"
2144 " }\n"
2145 "\\&\n"
2146 " if (nread == -1)\n"
2147 " err(EXIT_FAILURE, \"read\");\n"
2148 "\\&\n"
2149 " /* We expect only one kind of event; verify that assumption. */\n"
2150 "\\&\n"
2151 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
2152 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
2153 " exit(EXIT_FAILURE);\n"
2154 " }\n"
2155 "\\&\n"
2156 " /* Display info about the page-fault event. */\n"
2157 "\\&\n"
2158 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
2159 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
2160 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
2161 "\\&\n"
2162 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
2163 " region. Vary the contents that are copied in, so that it\n"
2164 " is more obvious that each fault is handled separately. */\n"
2165 "\\&\n"
2166 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
2167 " fault_cnt++;\n"
2168 "\\&\n"
2169 " uffdio_copy.src = (unsigned long) page;\n"
2170 "\\&\n"
2171 " /* We need to handle page faults in units of pages(!).\n"
2172 " So, round faulting address down to page boundary. */\n"
2173 "\\&\n"
2174 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
2175 " \\[ti](page_size - 1);\n"
2176 " uffdio_copy.len = page_size;\n"
2177 " uffdio_copy.mode = 0;\n"
2178 " uffdio_copy.copy = 0;\n"
2179 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
2180 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
2181 "\\&\n"
2182 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
2183 " uffdio_copy.copy);\n"
2184 " }\n"
2185 "}\n"
2186 "\\&\n"
2187 "int\n"
2188 "main(int argc, char *argv[])\n"
2189 "{\n"
2190 " int s;\n"
2191 " char c;\n"
2192 " char *addr; /* Start of region handled by userfaultfd */\n"
2193 " long uffd; /* userfaultfd file descriptor */\n"
2194 " size_t size, i; /* Size of region handled by userfaultfd */\n"
2195 " pthread_t thr; /* ID of thread that handles page faults */\n"
2196 " struct uffdio_api uffdio_api;\n"
2197 " struct uffdio_register uffdio_register;\n"
2198 "\\&\n"
2199 " if (argc != 2) {\n"
2200 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
2201 " exit(EXIT_FAILURE);\n"
2202 " }\n"
2203 "\\&\n"
2204 " page_size = sysconf(_SC_PAGE_SIZE);\n"
2205 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
2206 "\\&\n"
2207 " /* Create and enable userfaultfd object. */\n"
2208 "\\&\n"
2209 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
2210 " if (uffd == -1)\n"
2211 " err(EXIT_FAILURE, \"userfaultfd\");\n"
2212 "\\&\n"
2213 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
2214 " example doesn't require any specific features.\n"
2215 "\\&\n"
2216 " Programs that *do* should call UFFDIO_API twice: once with\n"
2217 " `features = 0` to detect features supported by this kernel, and\n"
2218 " again with the subset of features the program actually wants to\n"
2219 " enable. */\n"
2220 " uffdio_api.api = UFFD_API;\n"
2221 " uffdio_api.features = 0;\n"
2222 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
2223 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
2224 "\\&\n"
2225 " /* Create a private anonymous mapping. The memory will be\n"
2226 " demand-zero paged--that is, not yet allocated. When we\n"
2227 " actually touch the memory, it will be allocated via\n"
2228 " the userfaultfd. */\n"
2229 "\\&\n"
2230 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
2231 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2232 " if (addr == MAP_FAILED)\n"
2233 " err(EXIT_FAILURE, \"mmap\");\n"
2234 "\\&\n"
2235 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
2236 "\\&\n"
2237 " /* Register the memory range of the mapping we just created for\n"
2238 " handling by the userfaultfd object. In mode, we request to track\n"
2239 " missing pages (i.e., pages that have not yet been faulted in). */\n"
2240 "\\&\n"
2241 " uffdio_register.range.start = (unsigned long) addr;\n"
2242 " uffdio_register.range.len = size;\n"
2243 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
2244 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
2245 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
2246 "\\&\n"
2247 " /* Create a thread that will process the userfaultfd events. */\n"
2248 "\\&\n"
2249 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
2250 " if (s != 0) {\n"
2251 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
2252 " }\n"
2253 "\\&\n"
2254 " /* Main thread now touches memory in the mapping, touching\n"
2255 " locations 1024 bytes apart. This will trigger userfaultfd\n"
2256 " events for all pages in the region. */\n"
2257 "\\&\n"
2258 " i = 0xf; /* Ensure that faulting address is not on a page\n"
2259 " boundary, in order to test that we correctly\n"
2260 " handle that case in fault_handling_thread(). */\n"
2261 " while (i E<lt> size) {\n"
2262 " c = addr[i];\n"
2263 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
2264 " printf(\"%c\\[rs]n\", c);\n"
2265 " i += 1024;\n"
2266 " usleep(100000); /* Slow things down a little */\n"
2267 " }\n"
2268 "\\&\n"
2269 " exit(EXIT_SUCCESS);\n"
2270 "}\n"
2271 msgstr ""
2272
2273 #. type: TH
2274 #: mageia-cauldron
2275 #, no-wrap
2276 msgid "2026-02-08"
2277 msgstr "8 февраля 2026 г."
2278
2279 #. type: TH
2280 #: mageia-cauldron
2281 #, no-wrap
2282 msgid "Linux man-pages 6.17"
2283 msgstr "Страницы руководства Linux 6.17"
2284
2285 #. type: Plain text
2286 #: mageia-cauldron
2287 #, no-wrap
2288 msgid ""
2289 "/* userfaultfd_demo.c\n"
2290 "\\&\n"
2291 " Licensed under the GNU General Public License version 2 or later.\n"
2292 "*/\n"
2293 "#define _GNU_SOURCE\n"
2294 "#include E<lt>err.hE<gt>\n"
2295 "#include E<lt>errno.hE<gt>\n"
2296 "#include E<lt>fcntl.hE<gt>\n"
2297 "#include E<lt>inttypes.hE<gt>\n"
2298 "#include E<lt>linux/userfaultfd.hE<gt>\n"
2299 "#include E<lt>poll.hE<gt>\n"
2300 "#include E<lt>pthread.hE<gt>\n"
2301 "#include E<lt>stdio.hE<gt>\n"
2302 "#include E<lt>stdlib.hE<gt>\n"
2303 "#include E<lt>string.hE<gt>\n"
2304 "#include E<lt>sys/ioctl.hE<gt>\n"
2305 "#include E<lt>sys/mman.hE<gt>\n"
2306 "#include E<lt>sys/syscall.hE<gt>\n"
2307 "#include E<lt>unistd.hE<gt>\n"
2308 "\\&\n"
2309 "static int page_size;\n"
2310 "\\&\n"
2311 "static void *\n"
2312 "fault_handler_thread(void *arg)\n"
2313 "{\n"
2314 " long uffd; /* userfaultfd file descriptor */\n"
2315 "\\&\n"
2316 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
2317 " static char *page = NULL;\n"
2318 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
2319 "\\&\n"
2320 " uffd = (long) arg;\n"
2321 "\\&\n"
2322 " /* Create a page that will be copied into the faulting region. */\n"
2323 "\\&\n"
2324 " if (page == NULL) {\n"
2325 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
2326 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2327 " if (page == MAP_FAILED)\n"
2328 " err(EXIT_FAILURE, \"mmap\");\n"
2329 " }\n"
2330 "\\&\n"
2331 " /* Loop, handling incoming events on the userfaultfd\n"
2332 " file descriptor. */\n"
2333 "\\&\n"
2334 " for (;;) {\n"
2335 " int nready;\n"
2336 " ssize_t nread;\n"
2337 " struct pollfd pollfd;\n"
2338 " struct uffdio_copy uffdio_copy;\n"
2339 "\\&\n"
2340 " /* See what poll() tells us about the userfaultfd. */\n"
2341 "\\&\n"
2342 " pollfd.fd = uffd;\n"
2343 " pollfd.events = POLLIN;\n"
2344 " nready = poll(&pollfd, 1, -1);\n"
2345 " if (nready == -1)\n"
2346 " err(EXIT_FAILURE, \"poll\");\n"
2347 "\\&\n"
2348 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
2349 " printf(\" poll() returns: nready = %d; \"\n"
2350 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
2351 " (pollfd.revents & POLLIN) != 0,\n"
2352 " (pollfd.revents & POLLERR) != 0);\n"
2353 "\\&\n"
2354 " /* Read an event from the userfaultfd. */\n"
2355 "\\&\n"
2356 " nread = read(uffd, &msg, sizeof(msg));\n"
2357 " if (nread == 0) {\n"
2358 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
2359 " exit(EXIT_FAILURE);\n"
2360 " }\n"
2361 "\\&\n"
2362 " if (nread == -1)\n"
2363 " err(EXIT_FAILURE, \"read\");\n"
2364 "\\&\n"
2365 " /* We expect only one kind of event; verify that assumption. */\n"
2366 "\\&\n"
2367 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
2368 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
2369 " exit(EXIT_FAILURE);\n"
2370 " }\n"
2371 "\\&\n"
2372 " /* Display info about the page-fault event. */\n"
2373 "\\&\n"
2374 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
2375 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
2376 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
2377 "\\&\n"
2378 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
2379 " region. Vary the contents that are copied in, so that it\n"
2380 " is more obvious that each fault is handled separately. */\n"
2381 "\\&\n"
2382 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
2383 " fault_cnt++;\n"
2384 "\\&\n"
2385 " uffdio_copy.src = (unsigned long) page;\n"
2386 "\\&\n"
2387 " /* We need to handle page faults in units of pages(!).\n"
2388 " So, round faulting address down to page boundary. */\n"
2389 "\\&\n"
2390 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
2391 " \\[ti](page_size - 1);\n"
2392 " uffdio_copy.len = page_size;\n"
2393 " uffdio_copy.mode = 0;\n"
2394 " uffdio_copy.copy = 0;\n"
2395 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
2396 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
2397 "\\&\n"
2398 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
2399 " uffdio_copy.copy);\n"
2400 " }\n"
2401 "}\n"
2402 "\\&\n"
2403 "int\n"
2404 "main(int argc, char *argv[])\n"
2405 "{\n"
2406 " int s;\n"
2407 " char *addr; /* Start of region handled by userfaultfd */\n"
2408 " long uffd; /* userfaultfd file descriptor */\n"
2409 " size_t size, i; /* Size of region handled by userfaultfd */\n"
2410 " pthread_t thr; /* ID of thread that handles page faults */\n"
2411 " struct uffdio_api uffdio_api;\n"
2412 " struct uffdio_register uffdio_register;\n"
2413 "\\&\n"
2414 " if (argc != 2) {\n"
2415 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
2416 " exit(EXIT_FAILURE);\n"
2417 " }\n"
2418 "\\&\n"
2419 " page_size = sysconf(_SC_PAGE_SIZE);\n"
2420 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
2421 "\\&\n"
2422 " /* Create and enable userfaultfd object. */\n"
2423 "\\&\n"
2424 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
2425 " if (uffd == -1)\n"
2426 " err(EXIT_FAILURE, \"userfaultfd\");\n"
2427 "\\&\n"
2428 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
2429 " example doesn't require any specific features.\n"
2430 "\\&\n"
2431 " Programs that *do* should call UFFDIO_API twice: once with\n"
2432 " `features = 0` to detect features supported by this kernel, and\n"
2433 " again with the subset of features the program actually wants to\n"
2434 " enable. */\n"
2435 " uffdio_api.api = UFFD_API;\n"
2436 " uffdio_api.features = 0;\n"
2437 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
2438 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
2439 "\\&\n"
2440 " /* Create a private anonymous mapping. The memory will be\n"
2441 " demand-zero paged--that is, not yet allocated. When we\n"
2442 " actually touch the memory, it will be allocated via\n"
2443 " the userfaultfd. */\n"
2444 "\\&\n"
2445 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
2446 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2447 " if (addr == MAP_FAILED)\n"
2448 " err(EXIT_FAILURE, \"mmap\");\n"
2449 "\\&\n"
2450 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
2451 "\\&\n"
2452 " /* Register the memory range of the mapping we just created for\n"
2453 " handling by the userfaultfd object. In mode, we request to track\n"
2454 " missing pages (i.e., pages that have not yet been faulted in). */\n"
2455 "\\&\n"
2456 " uffdio_register.range.start = (unsigned long) addr;\n"
2457 " uffdio_register.range.len = size;\n"
2458 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
2459 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
2460 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
2461 "\\&\n"
2462 " /* Create a thread that will process the userfaultfd events. */\n"
2463 "\\&\n"
2464 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
2465 " if (s != 0) {\n"
2466 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
2467 " }\n"
2468 "\\&\n"
2469 " /* Main thread now touches memory in the mapping, touching\n"
2470 " locations 1024 bytes apart. This will trigger userfaultfd\n"
2471 " events for all pages in the region. */\n"
2472 "\\&\n"
2473 " i = 0xf; /* Ensure that faulting address is not on a page\n"
2474 " boundary, in order to test that we correctly\n"
2475 " handle that case in fault_handling_thread(). */\n"
2476 " while (i E<lt> size) {\n"
2477 " char c;\n"
2478 "\\&\n"
2479 " c = addr[i];\n"
2480 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
2481 " printf(\"%c\\[rs]n\", c);\n"
2482 " i += 1024;\n"
2483 " usleep(100000); /* Slow things down a little */\n"
2484 " }\n"
2485 "\\&\n"
2486 " exit(EXIT_SUCCESS);\n"
2487 "}\n"
2488 msgstr ""
2489
2490 #. type: TH
2491 #: opensuse-leap-16-1 opensuse-tumbleweed
2492 #, no-wrap
2493 msgid "Linux man-pages (unreleased)"
2494 msgstr "Страницы руководства Linux (не выпущены)"