Debian Codegraph @

po/ar/man2/userfaultfd.2.po

raw
1 # Arabic translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 # زايد السعيدي <[email protected]>, 2026.
5
6 msgid ""
7 msgstr ""
8 "Project-Id-Version: manpages-l10n 4.30.2\n"
9 "POT-Creation-Date: 2026-06-05 06:50+0200\n"
10 "PO-Revision-Date: 2026-06-05 22:05+0400\n"
11 "Last-Translator: Zayed Al-Saidi <[email protected]>\n"
12 "Language-Team: Arabic <[email protected]>\n"
13 "Language: ar\n"
14 "MIME-Version: 1.0\n"
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: 8bit\n"
17 "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 &&"
18 " n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
19 "X-Generator: Lokalize 23.08.5\n"
20
21 #. type: TH
22 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
23 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
24 #, no-wrap
25 msgid "userfaultfd"
26 msgstr "userfaultfd"
27
28 #. type: TH
29 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
30 #, no-wrap
31 msgid "2026-02-16"
32 msgstr "16 فبراير 2026"
33
34 #. type: TH
35 #: archlinux debian-unstable
36 #, no-wrap
37 msgid "Linux man-pages 6.18"
38 msgstr "صفحات دليل لينكس 6.18"
39
40 #. type: SH
41 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
42 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
43 #, no-wrap
44 msgid "NAME"
45 msgstr "الاسم"
46
47 #. type: Plain text
48 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
49 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
50 msgid ""
51 "userfaultfd - create a file descriptor for handling page faults in user space"
52 msgstr "userfaultfd - إنشاء واصف ملف لمعالجة أخطاء الصفحات في مساحة المستخدم"
53
54 #. type: SH
55 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
56 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
57 #, no-wrap
58 msgid "LIBRARY"
59 msgstr "المكتبة"
60
61 #. type: Plain text
62 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
63 #: opensuse-leap-16-1 opensuse-tumbleweed
64 msgid "Standard C library (I<libc>,\\ I<-lc>)"
65 msgstr "مكتبة سي المعيارية (I<libc>،\\ I<-lc>)"
66
67 #. type: SH
68 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
69 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
70 #, no-wrap
71 msgid "SYNOPSIS"
72 msgstr "موجز"
73
74 #. type: Plain text
75 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
76 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
77 #, no-wrap
78 msgid ""
79 "B<#include E<lt>fcntl.hE<gt>> /* Definition of B<O_*> constants"
80 " */\n"
81 "B<#include E<lt>sys/syscall.hE<gt>> /* Definition of B<SYS_*> constants"
82 " */\n"
83 "B<#include E<lt>linux/userfaultfd.hE<gt>> /* Definition of B<UFFD_*>"
84 " constants */\n"
85 "B<#include E<lt>unistd.hE<gt>>\n"
86 msgstr ""
87 "B<#include E<lt>fcntl.hE<gt>> /* تعريف ثوابت B<O_*> */\n"
88 "B<#include E<lt>sys/syscall.hE<gt>> /* تعريف ثوابت B<SYS_*> */\n"
89 "B<#include E<lt>linux/userfaultfd.hE<gt>> /* تعريف ثوابت B<UFFD_*> */\n"
90 "B<#include E<lt>unistd.hE<gt>>\n"
91
92 #. type: Plain text
93 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
94 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
95 #, no-wrap
96 msgid "B<int syscall(SYS_userfaultfd, int >I<flags>B<);>\n"
97 msgstr "B<int syscall(SYS_userfaultfd, int >I<flags>B<);>\n"
98
99 #. type: Plain text
100 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
101 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
102 msgid ""
103 "I<Note>: glibc provides no wrapper for B<userfaultfd>(), necessitating the "
104 "use of B<syscall>(2)."
105 msgstr ""
106 "I<ملاحظة>: لا توفر glibc غلافًا لـ B<userfaultfd>()، مما يستلزم استخدام "
107 "B<syscall>(2)."
108
109 #. type: SH
110 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
111 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
112 #, no-wrap
113 msgid "DESCRIPTION"
114 msgstr "الوصف"
115
116 #. type: Plain text
117 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
118 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
119 msgid ""
120 "B<userfaultfd>() creates a new userfaultfd object that can be used for "
121 "delegation of page-fault handling to a user-space application, and returns a "
122 "file descriptor that refers to the new object. The new userfaultfd object "
123 "is configured using B<ioctl>(2)."
124 msgstr ""
125 "ينشئ B<userfaultfd>() كائن userfaultfd جديد يمكن استخدامه لتفويض معالجة "
126 "أخطاء الصفحات إلى تطبيق في مساحة المستخدم، ويعيد واصف ملف يشير إلى الكائن "
127 "الجديد. يُضبط كائن userfaultfd الجديد باستخدام B<ioctl>(2)."
128
129 #. type: Plain text
130 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
131 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
132 msgid ""
133 "Once the userfaultfd object is configured, the application can use "
134 "B<read>(2) to receive userfaultfd notifications. The reads from "
135 "userfaultfd may be blocking or non-blocking, depending on the value of "
136 "I<flags> used for the creation of the userfaultfd or subsequent calls to "
137 "B<fcntl>(2)."
138 msgstr ""
139 "بمجرد ضبط كائن userfaultfd، يمكن للتطبيق استخدام B<read>(2) لاستقبال إشعارات "
140 "userfaultfd. قد تكون القراءات من userfaultfd حاجبة أو غير حاجبة، اعتمادًا على "
141 "قيمة I<flags> المستخدمة لإنشاء userfaultfd أو الاستدعاءات اللاحقة لـ "
142 "B<fcntl>(2)."
143
144 #. type: Plain text
145 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
146 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
147 msgid ""
148 "The following values may be bitwise ORed in I<flags> to change the behavior "
149 "of B<userfaultfd>():"
150 msgstr ""
151 "قد تُجمع القيم التالية بعملية OR على مستوى البت في I<flags> لتغيير سلوك "
152 "B<userfaultfd>():"
153
154 #. type: TP
155 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
156 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
157 #, no-wrap
158 msgid "B<O_CLOEXEC>"
159 msgstr "B<O_CLOEXEC>"
160
161 #. type: Plain text
162 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
163 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
164 msgid ""
165 "Enable the close-on-exec flag for the new userfaultfd file descriptor. See "
166 "the description of the B<O_CLOEXEC> flag in B<open>(2)."
167 msgstr ""
168 "فعّل علم الإغلاق عند التنفيذ (close-on-exec) لواصف ملف userfaultfd الجديد. "
169 "انظر وصف علم B<O_CLOEXEC> في B<open>(2)."
170
171 #. type: TP
172 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
173 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
174 #, no-wrap
175 msgid "B<O_NONBLOCK>"
176 msgstr "B<O_NONBLOCK>"
177
178 #. type: Plain text
179 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
180 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
181 msgid ""
182 "Enables non-blocking operation for the userfaultfd object. See the "
183 "description of the B<O_NONBLOCK> flag in B<open>(2)."
184 msgstr ""
185 "يفعّل التشغيل غير الحاجب لكائن userfaultfd. انظر وصف علم B<O_NONBLOCK> في "
186 "B<open>(2)."
187
188 #. type: TP
189 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
190 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
191 #, no-wrap
192 msgid "B<UFFD_USER_MODE_ONLY>"
193 msgstr "B<UFFD_USER_MODE_ONLY>"
194
195 #. type: Plain text
196 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
197 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
198 msgid ""
199 "This is an userfaultfd-specific flag that was introduced in Linux 5.11. "
200 "When set, the userfaultfd object will only be able to handle page faults "
201 "originated from the user space on the registered regions. When a kernel-"
202 "originated fault was triggered on the registered range with this "
203 "userfaultfd, a B<SIGBUS> signal will be delivered."
204 msgstr ""
205 "هذا علم خاص بـ userfaultfd أُدخل في لينكس 5.11. عند ضبطه، سيكون كائن "
206 "userfaultfd قادرًا فقط على معالجة أخطاء الصفحات الناشئة من مساحة المستخدم في "
207 "المناطق المسجلة. عندما يُقدح خطأ ناشئ من النواة في النطاق المسجل باستخدام "
208 "userfaultfd هذا، ستُرسل إشارة B<SIGBUS>."
209
210 #. type: Plain text
211 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
212 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
213 msgid ""
214 "When the last file descriptor referring to a userfaultfd object is closed, "
215 "all memory ranges that were registered with the object are unregistered and "
216 "unread events are flushed."
217 msgstr ""
218 "عند إغلاق آخر واصف ملف يشير إلى كائن userfaultfd، تُلغى تسجيلات جميع نطاقات "
219 "الذاكرة التي سُجلت مع الكائن وتُفرغ الأحداث غير المقروءة."
220
221 #. type: Plain text
222 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
223 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
224 msgid "Userfaultfd supports three modes of registration:"
225 msgstr "يدعم Userfaultfd ثلاثة أوضاع للتسجيل:"
226
227 #. type: TP
228 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
229 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
230 #, no-wrap
231 msgid "B<UFFDIO_REGISTER_MODE_MISSING> (since Linux 4.10)"
232 msgstr "B<UFFDIO_REGISTER_MODE_MISSING> (منذ لينكس 4.10)"
233
234 #. type: Plain text
235 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
236 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
237 msgid ""
238 "When registered with B<UFFDIO_REGISTER_MODE_MISSING> mode, user-space will "
239 "receive a page-fault notification when a missing page is accessed. The "
240 "faulted thread will be stopped from execution until the page fault is "
241 "resolved from user-space by either an B<UFFDIO_COPY> or an "
242 "B<UFFDIO_ZEROPAGE> ioctl."
243 msgstr ""
244 "عند التسجيل بالوضع B<UFFDIO_REGISTER_MODE_MISSING>، ستتلقى مساحة المستخدم "
245 "إشعار خطأ صفحة عند الوصول إلى صفحة مفقودة. سيُوقف الخيط المتعطل عن التنفيذ "
246 "حتى يُحل خطأ الصفحة من مساحة المستخدم بواسطة ioctl إما B<UFFDIO_COPY> أو "
247 "B<UFFDIO_ZEROPAGE>."
248
249 #. type: TP
250 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
251 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
252 #, no-wrap
253 msgid "B<UFFDIO_REGISTER_MODE_MINOR> (since Linux 5.13)"
254 msgstr "B<UFFDIO_REGISTER_MODE_MINOR> (منذ لينكس 5.13)"
255
256 #. type: Plain text
257 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
258 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
259 msgid ""
260 "When registered with B<UFFDIO_REGISTER_MODE_MINOR> mode, user-space will "
261 "receive a page-fault notification when a minor page fault occurs. That is, "
262 "when a backing page is in the page cache, but page table entries don't yet "
263 "exist. The faulted thread will be stopped from execution until the page "
264 "fault is resolved from user-space by an B<UFFDIO_CONTINUE> ioctl."
265 msgstr ""
266 "عند التسجيل بالوضع B<UFFDIO_REGISTER_MODE_MINOR>، ستتلقى مساحة المستخدم "
267 "إشعار خطأ صفحة عند حدوث خطأ صفحة ثانوي. أي عندما تكون صفحة السند في خبيئة "
268 "الصفحات، ولكن مدخلات جدول الصفحات غير موجودة بعد. سيُوقف الخيط المتعطل عن "
269 "التنفيذ حتى يُحل خطأ الصفحة من مساحة المستخدم بواسطة ioctl B<UFFDIO_CONTINUE>."
270
271 #. type: TP
272 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
273 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
274 #, no-wrap
275 msgid "B<UFFDIO_REGISTER_MODE_WP> (since Linux 5.7)"
276 msgstr "B<UFFDIO_REGISTER_MODE_WP> (منذ لينكس 5.7)"
277
278 #. type: Plain text
279 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
280 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
281 msgid ""
282 "When registered with B<UFFDIO_REGISTER_MODE_WP> mode, user-space will "
283 "receive a page-fault notification when a write-protected page is written. "
284 "The faulted thread will be stopped from execution until user-space write-"
285 "unprotects the page using an B<UFFDIO_WRITEPROTECT> ioctl."
286 msgstr ""
287 "عند التسجيل بالوضع B<UFFDIO_REGISTER_MODE_WP>، ستتلقى مساحة المستخدم إشعار "
288 "خطأ صفحة عند كتابة صفحة محمية ضد الكتابة. سيُوقف الخيط المتعطل عن التنفيذ حتى "
289 "تُزيل مساحة المستخدم حماية الكتابة عن الصفحة باستخدام ioctl "
290 "B<UFFDIO_WRITEPROTECT>."
291
292 #. type: Plain text
293 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
294 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
295 msgid ""
296 "Multiple modes can be enabled at the same time for the same memory range."
297 msgstr "يمكن تمكين أوضاع متعددة في نفس الوقت لنفس نطاق الذاكرة."
298
299 #. type: Plain text
300 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
301 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
302 msgid ""
303 "Since Linux 4.14, a userfaultfd page-fault notification can selectively "
304 "embed faulting thread ID information into the notification. One needs to "
305 "enable this feature explicitly using the B<UFFD_FEATURE_THREAD_ID> feature "
306 "bit when initializing the userfaultfd context. By default, thread ID "
307 "reporting is disabled."
308 msgstr ""
309 "منذ لينكس 4.14، يمكن لإشعار خطأ صفحة userfaultfd أن يضمّن بشكل انتقائي "
310 "معلومات معرف الخيط المتعطل في الإشعار. يحتاج المرء إلى تمكين هذه الميزة "
311 "صراحةً باستخدام بت الميزة B<UFFD_FEATURE_THREAD_ID> عند تهيئة سياق "
312 "userfaultfd. الإبلاغ عن معرف الخيط معطل مبدئيًا."
313
314 #. type: SS
315 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
316 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
317 #, no-wrap
318 msgid "Usage"
319 msgstr "الاستخدام"
320
321 #. type: Plain text
322 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
323 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
324 msgid ""
325 "The userfaultfd mechanism is designed to allow a thread in a multithreaded "
326 "program to perform user-space paging for the other threads in the process. "
327 "When a page fault occurs for one of the regions registered to the "
328 "userfaultfd object, the faulting thread is put to sleep and an event is "
329 "generated that can be read via the userfaultfd file descriptor. The fault-"
330 "handling thread reads events from this file descriptor and services them "
331 "using the operations described in B<ioctl_userfaultfd>(2). When servicing "
332 "the page fault events, the fault-handling thread can trigger a wake-up for "
333 "the sleeping thread."
334 msgstr ""
335 "صُممت آلية userfaultfd للسماح لخيط في برنامج متعدد الخيوط بأداء ترحيل صفحات "
336 "في مساحة المستخدم للخيوط الأخرى في العملية. عند حدوث خطأ صفحة لإحدى المناطق "
337 "المسجلة لكائن userfaultfd، يُوضع الخيط المتعطل في حالة سكون ويُولد حدث يمكن "
338 "قراءته عبر واصف ملف userfaultfd. يقرأ خيط معالجة الأخطاء الأحداث من واصف "
339 "الملف هذا ويخدمها باستخدام العمليات الموصوفة في B<ioctl_userfaultfd>(2). عند "
340 "خدمة أحداث خطأ الصفحة، يمكن لخيط معالجة الأخطاء قدح إيقاظ للخيط النائم."
341
342 #. type: Plain text
343 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
344 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
345 msgid ""
346 "It is possible for the faulting threads and the fault-handling threads to "
347 "run in the context of different processes. In this case, these threads may "
348 "belong to different programs, and the program that executes the faulting "
349 "threads will not necessarily cooperate with the program that handles the "
350 "page faults. In such non-cooperative mode, the process that monitors "
351 "userfaultfd and handles page faults needs to be aware of the changes in the "
352 "virtual memory layout of the faulting process to avoid memory corruption."
353 msgstr ""
354 "من الممكن أن تعمل الخيوط المتعطلة وخيوط معالجة الأخطاء في سياق عمليات "
355 "مختلفة. في هذه الحالة، قد تنتمي هذه الخيوط إلى برامج مختلفة، ولن يتعاون "
356 "البرنامج الذي ينفذ الخيوط المتعطلة بالضرورة مع البرنامج الذي يعالج أخطاء "
357 "الصفحات. في هذا الوضع غير التعاوني، تحتاج العملية التي تراقب userfaultfd "
358 "وتعالج أخطاء الصفحات إلى أن تكون على دراية بالتغييرات في تخطيط الذاكرة "
359 "الافتراضية للعملية المتعطلة لتجنب فساد الذاكرة."
360
361 #. type: Plain text
362 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
363 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
364 msgid ""
365 "Since Linux 4.11, userfaultfd can also notify the fault-handling threads "
366 "about changes in the virtual memory layout of the faulting process. In "
367 "addition, if the faulting process invokes B<fork>(2), the userfaultfd "
368 "objects associated with the parent may be duplicated into the child process "
369 "and the userfaultfd monitor will be notified (via the B<UFFD_EVENT_FORK> "
370 "described below) about the file descriptor associated with the userfault "
371 "objects created for the child process, which allows the userfaultfd monitor "
372 "to perform user-space paging for the child process. Unlike page faults "
373 "which have to be synchronous and require an explicit or implicit wakeup, all "
374 "other events are delivered asynchronously and the non-cooperative process "
375 "resumes execution as soon as the userfaultfd manager executes B<read>(2). "
376 "The userfaultfd manager should carefully synchronize calls to B<UFFDIO_COPY> "
377 "with the processing of events."
378 msgstr ""
379 "منذ لينكس 4.11، يمكن لـ userfaultfd أيضًا إخطار خيوط معالجة الأخطاء حول "
380 "التغييرات في تخطيط الذاكرة الافتراضية للعملية المتعطلة. بالإضافة إلى ذلك، "
381 "إذا استدعت العملية المتعطلة B<fork>(2)، فقد تُكرر كائنات userfaultfd المرتبطة "
382 "بالأصل في العملية الفرعية وسيُخطر مراقب userfaultfd (عبر B<UFFD_EVENT_FORK> "
383 "الموصوف أدناه) بشأن واصف الملف المرتبط بكائنات userfault المنشأة للعملية "
384 "الفرعية، مما يسمح لمراقب userfaultfd بأداء ترحيل صفحات في مساحة المستخدم "
385 "للعملية الفرعية. على عكس أخطاء الصفحات التي يجب أن تكون متزامنة وتتطلب "
386 "إيقاظًا صريحًا أو ضمنيًا، تُسلم جميع الأحداث الأخرى بشكل غير متزامن وتستأنف "
387 "العملية غير التعاونية التنفيذ بمجرد أن ينفذ مدير userfaultfd B<read>(2). يجب "
388 "على مدير userfaultfd مزامنة استدعاءات B<UFFDIO_COPY> بعناية مع معالجة "
389 "الأحداث."
390
391 #. #-#-#-#-# archlinux: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
392 #. Regarding the preceding sentence, Mike Rapoport says:
393 #. The major point here is that current events delivery model could be
394 #. problematic for multi-threaded monitor. I even suspect that it would be
395 #. impossible to ensure synchronization between page faults and non-page
396 #. fault events in multi-threaded monitor.
397 #. .P
398 #. FIXME elaborate about non-cooperating mode, describe its limitations
399 #. for kernels before Linux 4.11, features added in Linux 4.11
400 #. and limitations remaining in Linux 4.11
401 #. Maybe it's worth adding a dedicated sub-section...
402 #. type: Plain text
403 #. #-#-#-#-# debian-trixie: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
404 #. Regarding the preceding sentence, Mike Rapoport says:
405 #. The major point here is that current events delivery model could be
406 #. problematic for multi-threaded monitor. I even suspect that it would be
407 #. impossible to ensure synchronization between page faults and non-page
408 #. fault events in multi-threaded monitor.
409 #. .P
410 #. FIXME elaborate about non-cooperating mode, describe its limitations
411 #. for kernels before Linux 4.11, features added in Linux 4.11
412 #. and limitations remaining in Linux 4.11
413 #. Maybe it's worth adding a dedicated sub-section...
414 #. type: Plain text
415 #. #-#-#-#-# debian-unstable: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
416 #. Regarding the preceding sentence, Mike Rapoport says:
417 #. The major point here is that current events delivery model could be
418 #. problematic for multi-threaded monitor. I even suspect that it would be
419 #. impossible to ensure synchronization between page faults and non-page
420 #. fault events in multi-threaded monitor.
421 #. .P
422 #. FIXME elaborate about non-cooperating mode, describe its limitations
423 #. for kernels before Linux 4.11, features added in Linux 4.11
424 #. and limitations remaining in Linux 4.11
425 #. Maybe it's worth adding a dedicated sub-section...
426 #. type: Plain text
427 #. #-#-#-#-# fedora-44: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
428 #. Regarding the preceding sentence, Mike Rapoport says:
429 #. The major point here is that current events delivery model could be
430 #. problematic for multi-threaded monitor. I even suspect that it would be
431 #. impossible to ensure synchronization between page faults and non-page
432 #. fault events in multi-threaded monitor.
433 #. .P
434 #. FIXME elaborate about non-cooperating mode, describe its limitations
435 #. for kernels before Linux 4.11, features added in Linux 4.11
436 #. and limitations remaining in Linux 4.11
437 #. Maybe it's worth adding a dedicated sub-section...
438 #. type: Plain text
439 #. #-#-#-#-# fedora-rawhide: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
440 #. Regarding the preceding sentence, Mike Rapoport says:
441 #. The major point here is that current events delivery model could be
442 #. problematic for multi-threaded monitor. I even suspect that it would be
443 #. impossible to ensure synchronization between page faults and non-page
444 #. fault events in multi-threaded monitor.
445 #. .P
446 #. FIXME elaborate about non-cooperating mode, describe its limitations
447 #. for kernels before Linux 4.11, features added in Linux 4.11
448 #. and limitations remaining in Linux 4.11
449 #. Maybe it's worth adding a dedicated sub-section...
450 #. type: Plain text
451 #. #-#-#-#-# mageia-cauldron: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
452 #. Regarding the preceding sentence, Mike Rapoport says:
453 #. The major point here is that current events delivery model could be
454 #. problematic for multi-threaded monitor. I even suspect that it would be
455 #. impossible to ensure synchronization between page faults and non-page
456 #. fault events in multi-threaded monitor.
457 #. .P
458 #. FIXME elaborate about non-cooperating mode, describe its limitations
459 #. for kernels before Linux 4.11, features added in Linux 4.11
460 #. and limitations remaining in Linux 4.11
461 #. Maybe it's worth adding a dedicated sub-section...
462 #. type: Plain text
463 #. #-#-#-#-# opensuse-leap-16-1: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
464 #. Regarding the preceding sentence, Mike Rapoport says:
465 #. The major point here is that current events delivery model could be
466 #. problematic for multi-threaded monitor. I even suspect that it would be
467 #. impossible to ensure synchronization between page faults and non-page
468 #. fault events in multi-threaded monitor.
469 #. .P
470 #. FIXME elaborate about non-cooperating mode, describe its limitations
471 #. for kernels before Linux 4.11, features added in Linux 4.11
472 #. and limitations remaining in Linux 4.11
473 #. Maybe it's worth adding a dedicated sub-section...
474 #. type: Plain text
475 #. #-#-#-#-# opensuse-tumbleweed: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-#
476 #. Regarding the preceding sentence, Mike Rapoport says:
477 #. The major point here is that current events delivery model could be
478 #. problematic for multi-threaded monitor. I even suspect that it would be
479 #. impossible to ensure synchronization between page faults and non-page
480 #. fault events in multi-threaded monitor.
481 #. .P
482 #. FIXME elaborate about non-cooperating mode, describe its limitations
483 #. for kernels before Linux 4.11, features added in Linux 4.11
484 #. and limitations remaining in Linux 4.11
485 #. Maybe it's worth adding a dedicated sub-section...
486 #. type: Plain text
487 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
488 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
489 msgid ""
490 "The current asynchronous model of the event delivery is optimal for single "
491 "threaded non-cooperative userfaultfd manager implementations."
492 msgstr ""
493 "النموذج غير المتزامن الحالي لتسليم الأحداث هو الأمثل لتطبيقات مدير "
494 "userfaultfd غير التعاونية أحادية الخيط."
495
496 #. type: Plain text
497 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
498 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
499 msgid ""
500 "Since Linux 5.7, userfaultfd is able to do synchronous page dirty tracking "
501 "using the new write-protect register mode. One should check against the "
502 "feature bit B<UFFD_FEATURE_PAGEFAULT_FLAG_WP> before using this feature. "
503 "Similar to the original userfaultfd missing mode, the write-protect mode "
504 "will generate a userfaultfd notification when the protected page is "
505 "written. The user needs to resolve the page fault by unprotecting the "
506 "faulted page and kicking the faulted thread to continue. For more "
507 "information, please refer to the \"Userfaultfd write-protect mode\" section."
508 msgstr ""
509 "منذ لينكس 5.7، أصبح userfaultfd قادرًا على القيام بتتبع متزامن لاتساخ الصفحات "
510 "باستخدام وضع التسجيل الجديد للحماية من الكتابة. يجب على المرء التحقق من بت "
511 "الميزة B<UFFD_FEATURE_PAGEFAULT_FLAG_WP> قبل استخدام هذه الميزة. على غرار "
512 "وضع الفقدان الأصلي لـ userfaultfd، سيُولد وضع الحماية من الكتابة إشعار "
513 "userfaultfd عند كتابة الصفحة المحمية. يحتاج المستخدم إلى حل خطأ الصفحة عن "
514 "طريق إزالة الحماية عن الصفحة المتعطلة وركل الخيط المتعطل للمتابعة. لمزيد من "
515 "المعلومات، يُرجى الرجوع إلى قسم \"وضع الحماية من الكتابة في Userfaultfd\"."
516
517 #. type: SS
518 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
519 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
520 #, no-wrap
521 msgid "Userfaultfd operation"
522 msgstr "عملية Userfaultfd"
523
524 #. type: Plain text
525 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
526 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
527 msgid ""
528 "After the userfaultfd object is created with B<userfaultfd>(), the "
529 "application must enable it using the B<UFFDIO_API> B<ioctl>(2) operation. "
530 "This operation allows a two-step handshake between the kernel and user space "
531 "to determine what API version and features the kernel supports, and then to "
532 "enable those features user space wants. This operation must be performed "
533 "before any of the other B<ioctl>(2) operations described below (or those "
534 "operations fail with the B<EINVAL> error)."
535 msgstr ""
536 "بعد إنشاء كائن userfaultfd باستخدام B<userfaultfd>()، يجب على التطبيق تمكينه "
537 "باستخدام عملية B<UFFDIO_API> B<ioctl>(2). تسمح هذه العملية بمصافحة من خطوتين "
538 "بين النواة ومساحة المستخدم لتحديد إصدار API والميزات التي تدعمها النواة، ثم "
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 msgid ""
547 "After a successful B<UFFDIO_API> operation, the application then registers "
548 "memory address ranges using the B<UFFDIO_REGISTER> B<ioctl>(2) operation. "
549 "After successful completion of a B<UFFDIO_REGISTER> operation, a page fault "
550 "occurring in the requested memory range, and satisfying the mode defined at "
551 "the registration time, will be forwarded by the kernel to the user-space "
552 "application. The application can then use various (e.g., B<UFFDIO_COPY>, "
553 "B<UFFDIO_ZEROPAGE>, or B<UFFDIO_CONTINUE>) B<ioctl>(2) operations to "
554 "resolve the page fault."
555 msgstr ""
556 "بعد نجاح عملية B<UFFDIO_API>، يقوم التطبيق بتسجيل نطاقات عناوين الذاكرة "
557 "باستخدام عملية B<UFFDIO_REGISTER> B<ioctl>(2). بعد الإكمال الناجح لعملية "
558 "B<UFFDIO_REGISTER>، سيقوم النواة بإعادة توجيه أي خطأ صفحة يحدث في نطاق "
559 "الذاكرة المطلوب، ويحقق الوضع المحدد وقت التسجيل، إلى تطبيق مساحة المستخدم. "
560 "يمكن للتطبيق بعد ذلك استخدام عمليات B<ioctl>(2) متنوعة (مثل B<UFFDIO_COPY>، "
561 "أو B<UFFDIO_ZEROPAGE>، أو B<UFFDIO_CONTINUE>) لحل خطأ الصفحة."
562
563 #. type: Plain text
564 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
565 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
566 msgid ""
567 "Since Linux 4.14, if the application sets the B<UFFD_FEATURE_SIGBUS> feature "
568 "bit using the B<UFFDIO_API> B<ioctl>(2), no page-fault notification will be "
569 "forwarded to user space. Instead a B<SIGBUS> signal is delivered to the "
570 "faulting process. With this feature, userfaultfd can be used for robustness "
571 "purposes to simply catch any access to areas within the registered address "
572 "range that do not have pages allocated, without having to listen to "
573 "userfaultfd events. No userfaultfd monitor will be required for dealing "
574 "with such memory accesses. For example, this feature can be useful for "
575 "applications that want to prevent the kernel from automatically allocating "
576 "pages and filling holes in sparse files when the hole is accessed through a "
577 "memory mapping."
578 msgstr ""
579 "منذ لينكس 4.14، إذا ضبط التطبيق بت الميزة B<UFFD_FEATURE_SIGBUS> باستخدام "
580 "B<UFFDIO_API> B<ioctl>(2)، فلن يُعاد توجيه أي إشعار بخطأ صفحة إلى مساحة "
581 "المستخدم. بدلاً من ذلك، تُسلم إشارة B<SIGBUS> إلى العملية المتعطلة. باستخدام "
582 "هذه الميزة، يمكن استخدام userfaultfd لأغراض المتانة للقبض ببساطة على أي وصول "
583 "لمناطق ضمن نطاق العناوين المسجل لا تحتوي على صفحات مخصصة، دون الحاجة "
584 "للاستماع لأحداث userfaultfd. لن يكون هناك حاجة لمراقب userfaultfd للتعامل مع "
585 "مثل هذه الوصولات للذاكرة. على سبيل المثال، يمكن أن تكون هذه الميزة مفيدة "
586 "للتطبيقات التي تريد منع النواة من تخصيص الصفحات آليًا وملء الفجوات في الملفات "
587 "المتفرقة عند الوصول إلى الفجوة عبر تعيين ذاكرة."
588
589 #. type: Plain text
590 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
591 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
592 msgid ""
593 "The B<UFFD_FEATURE_SIGBUS> feature is implicitly inherited through "
594 "B<fork>(2) if used in combination with B<UFFD_FEATURE_FORK>."
595 msgstr ""
596 "تُورث ميزة B<UFFD_FEATURE_SIGBUS> ضمنيًا من خلال B<fork>(2) إذا استُخدمت مع "
597 "B<UFFD_FEATURE_FORK>."
598
599 #. type: Plain text
600 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
601 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
602 msgid ""
603 "Details of the various B<ioctl>(2) operations can be found in "
604 "B<ioctl_userfaultfd>(2)."
605 msgstr ""
606 "يمكن العثور على تفاصيل عمليات B<ioctl>(2) المختلفة في "
607 "B<ioctl_userfaultfd>(2)."
608
609 #. type: Plain text
610 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
611 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
612 msgid ""
613 "Since Linux 4.11, events other than page-fault may enabled during "
614 "B<UFFDIO_API> operation."
615 msgstr ""
616 "منذ لينكس 4.11، يمكن تمكين أحداث بخلاف أخطاء الصفحات أثناء عملية "
617 "B<UFFDIO_API>."
618
619 #. type: Plain text
620 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
621 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
622 msgid ""
623 "Up to Linux 4.11, userfaultfd can be used only with anonymous private memory "
624 "mappings. Since Linux 4.11, userfaultfd can be also used with hugetlbfs and "
625 "shared memory mappings."
626 msgstr ""
627 "حتى لينكس 4.11، كان يمكن استخدام userfaultfd فقط مع تعيينات الذاكرة الخاصة "
628 "المجهولة. منذ لينكس 4.11، يمكن أيضًا استخدام userfaultfd مع hugetlbfs "
629 "وتعيينات الذاكرة المشتركة."
630
631 #. type: SS
632 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
633 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
634 #, no-wrap
635 msgid "Userfaultfd write-protect mode (since Linux 5.7)"
636 msgstr "وضع الحماية من الكتابة في Userfaultfd (منذ لينكس 5.7)"
637
638 #. type: Plain text
639 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
640 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
641 msgid ""
642 "Since Linux 5.7, userfaultfd supports write-protect mode for anonymous "
643 "memory. The user needs to first check availability of this feature using "
644 "B<UFFDIO_API> ioctl against the feature bit "
645 "B<UFFD_FEATURE_PAGEFAULT_FLAG_WP> before using this feature."
646 msgstr ""
647 "منذ لينكس 5.7، يدعم userfaultfd وضع الحماية من الكتابة للذاكرة المجهولة. "
648 "يحتاج المستخدم أولاً للتحقق من توفر هذه الميزة باستخدام ioctl B<UFFDIO_API> "
649 "مقابل بت الميزة B<UFFD_FEATURE_PAGEFAULT_FLAG_WP> قبل استخدام هذه الميزة."
650
651 #. type: Plain text
652 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
653 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
654 msgid ""
655 "Since Linux 5.19, the write-protection mode was also supported on shmem and "
656 "hugetlbfs memory types. It can be detected with the feature bit "
657 "B<UFFD_FEATURE_WP_HUGETLBFS_SHMEM>."
658 msgstr ""
659 "منذ لينكس 5.19، دُعم وضع الحماية من الكتابة أيضًا على أنواع الذاكرة shmem و "
660 "hugetlbfs. يمكن اكتشافه ببت الميزة B<UFFD_FEATURE_WP_HUGETLBFS_SHMEM>."
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 "To register with userfaultfd write-protect mode, the user needs to initiate "
667 "the B<UFFDIO_REGISTER> ioctl with mode B<UFFDIO_REGISTER_MODE_WP> set. Note "
668 "that it is legal to monitor the same memory range with multiple modes. For "
669 "example, the user can do B<UFFDIO_REGISTER> with the mode set to "
670 "B<UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP>. When there is "
671 "only B<UFFDIO_REGISTER_MODE_WP> registered, user-space will I<not> receive "
672 "any notification when a missing page is written. Instead, user-space will "
673 "receive a write-protect page-fault notification only when an existing but "
674 "write-protected page got written."
675 msgstr ""
676 "للتسجيل مع وضع الحماية من الكتابة لـ userfaultfd، يحتاج المستخدم إلى بدء "
677 "ioctl B<UFFDIO_REGISTER> مع تعيين الوضع B<UFFDIO_REGISTER_MODE_WP>. لاحظ أنه "
678 "من القانوني مراقبة نفس نطاق الذاكرة بأوضاع متعددة. على سبيل المثال، يمكن "
679 "للمستخدم القيام بـ B<UFFDIO_REGISTER> مع تعيين الوضع إلى "
680 "B<UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP>. عندما يتم تسجيل "
681 "B<UFFDIO_REGISTER_MODE_WP> فقط، I<لن> تتلقى مساحة المستخدم أي إشعار عند كتابة "
682 "صفحة مفقودة. بدلاً من ذلك، ستتلقى مساحة المستخدم إشعار خطأ صفحة للحماية من "
683 "الكتابة فقط عند كتابة صفحة موجودة ولكنها محمية من الكتابة."
684
685 #. type: Plain text
686 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
687 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
688 msgid ""
689 "After the B<UFFDIO_REGISTER> ioctl completed with B<UFFDIO_REGISTER_MODE_WP> "
690 "mode set, the user can write-protect any existing memory within the range "
691 "using the ioctl B<UFFDIO_WRITEPROTECT> where I<uffdio_writeprotect.mode> "
692 "should be set to B<UFFDIO_WRITEPROTECT_MODE_WP>."
693 msgstr ""
694 "بعد اكتمال ioctl B<UFFDIO_REGISTER> مع تعيين وضع B<UFFDIO_REGISTER_MODE_WP>، "
695 "يمكن للمستخدم حماية أي ذاكرة موجودة ضمن النطاق من الكتابة باستخدام ioctl "
696 "B<UFFDIO_WRITEPROTECT> حيث يجب تعيين I<uffdio_writeprotect.mode> إلى "
697 "B<UFFDIO_WRITEPROTECT_MODE_WP>."
698
699 #. type: Plain text
700 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
701 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
702 msgid ""
703 "When a write-protect event happens, user-space will receive a page-fault "
704 "notification whose I<uffd_msg.pagefault.flags> will be with "
705 "B<UFFD_PAGEFAULT_FLAG_WP> flag set. Note: since only writes can trigger "
706 "this kind of fault, write-protect notifications will always have the "
707 "B<UFFD_PAGEFAULT_FLAG_WRITE> bit set along with the "
708 "B<UFFD_PAGEFAULT_FLAG_WP> bit."
709 msgstr ""
710 "عند حدوث حدث حماية من الكتابة، ستتلقى مساحة المستخدم إشعار خطأ صفحة حيث "
711 "سيكون I<uffd_msg.pagefault.flags> مع تعيين علم B<UFFD_PAGEFAULT_FLAG_WP>. "
712 "ملاحظة: نظرًا لأن الكتابات فقط يمكنها تشغيل هذا النوع من الأخطاء، فإن إشعارات "
713 "الحماية من الكتابة ستحتوي دائمًا على بت B<UFFD_PAGEFAULT_FLAG_WRITE> مضبوطًا "
714 "مع بت B<UFFD_PAGEFAULT_FLAG_WP>."
715
716 #. type: Plain text
717 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
718 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
719 msgid ""
720 "To resolve a write-protection page fault, the user should initiate another "
721 "B<UFFDIO_WRITEPROTECT> ioctl, whose I<uffd_msg.pagefault.flags> should have "
722 "the flag B<UFFDIO_WRITEPROTECT_MODE_WP> cleared upon the faulted page or "
723 "range."
724 msgstr ""
725 "لحل خطأ صفحة الحماية من الكتابة، يجب على المستخدم بدء ioctl "
726 "B<UFFDIO_WRITEPROTECT> آخر، حيث يجب أن يكون I<uffd_msg.pagefault.flags> مع "
727 "مسح العلم B<UFFDIO_WRITEPROTECT_MODE_WP> على الصفحة أو النطاق المتسبب في "
728 "الخطأ."
729
730 #. type: SS
731 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
732 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
733 #, no-wrap
734 msgid "Userfaultfd minor fault mode (since Linux 5.13)"
735 msgstr "وضع الخطأ الثانوي لـ Userfaultfd (منذ لينكس 5.13)"
736
737 #. type: Plain text
738 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
739 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
740 msgid ""
741 "Since Linux 5.13, userfaultfd supports minor fault mode. In this mode, "
742 "fault messages are produced not for major faults (where the page was "
743 "missing), but rather for minor faults, where a page exists in the page "
744 "cache, but the page table entries are not yet present. The user needs to "
745 "first check availability of this feature using the B<UFFDIO_API> ioctl with "
746 "the appropriate feature bits set before using this feature: "
747 "B<UFFD_FEATURE_MINOR_HUGETLBFS> since Linux 5.13, or "
748 "B<UFFD_FEATURE_MINOR_SHMEM> since Linux 5.14."
749 msgstr ""
750 "منذ لينكس 5.13، يدعم userfaultfd وضع الخطأ الثانوي. في هذا الوضع، يتم إنتاج "
751 "رسائل الخطأ ليس للأخطاء الرئيسية (حيث كانت الصفحة مفقودة)، بل للأخطاء "
752 "الثانوية، حيث توجد صفحة في خبيئة الصفحة، ولكن إدخالات جدول الصفحة غير موجودة "
753 "بعد. يحتاج المستخدم أولاً إلى التحقق من توفر هذه الميزة باستخدام ioctl "
754 "B<UFFDIO_API> مع تعيين بتات الميزة المناسبة قبل استخدام هذه الميزة: "
755 "B<UFFD_FEATURE_MINOR_HUGETLBFS> منذ لينكس 5.13، أو "
756 "B<UFFD_FEATURE_MINOR_SHMEM> منذ لينكس 5.14."
757
758 #. type: Plain text
759 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
760 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
761 msgid ""
762 "To register with userfaultfd minor fault mode, the user needs to initiate "
763 "the B<UFFDIO_REGISTER> ioctl with mode B<UFFD_REGISTER_MODE_MINOR> set."
764 msgstr ""
765 "للتسجيل مع وضع الخطأ الثانوي لـ userfaultfd، يحتاج المستخدم إلى بدء ioctl "
766 "B<UFFDIO_REGISTER> مع تعيين الوضع B<UFFD_REGISTER_MODE_MINOR>."
767
768 #. type: Plain text
769 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
770 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
771 msgid ""
772 "When a minor fault occurs, user-space will receive a page-fault notification "
773 "whose I<uffd_msg.pagefault.flags> will have the B<UFFD_PAGEFAULT_FLAG_MINOR> "
774 "flag set."
775 msgstr ""
776 "عند حدوث خطأ ثانوي، ستتلقى مساحة المستخدم إشعار خطأ صفحة حيث سيكون "
777 "I<uffd_msg.pagefault.flags> مع تعيين علم B<UFFD_PAGEFAULT_FLAG_MINOR>."
778
779 #. type: Plain text
780 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
781 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
782 msgid ""
783 "To resolve a minor page fault, the handler should decide whether or not the "
784 "existing page contents need to be modified first. If so, this should be "
785 "done in-place via a second, non-userfaultfd-registered mapping to the same "
786 "backing page (e.g., by mapping the shmem or hugetlbfs file twice). Once the "
787 "page is considered \"up to date\", the fault can be resolved by initiating "
788 "an B<UFFDIO_CONTINUE> ioctl, which installs the page table entries and (by "
789 "default) wakes up the faulting thread(s)."
790 msgstr ""
791 "لحل خطأ صفحة ثانوي، يجب على المعالج تحديد ما إذا كانت محتويات الصفحة الحالية "
792 "تحتاج إلى تعديل أولاً أم لا. إذا كان الأمر كذلك، فيجب القيام بذلك في المكان "
793 "من خلال تعيين ثانٍ غير مسجل بـ userfaultfd لنفس الصفحة الداعمة (على سبيل "
794 "المثال، عن طريق تعيين ملف shmem أو hugetlbfs مرتين). بمجرد اعتبار الصفحة "
795 "\"محدثة\"، يمكن حل الخطأ عن طريق بدء ioctl B<UFFDIO_CONTINUE>، الذي يقوم "
796 "بتثبيت إدخالات جدول الصفحة و(بشكل مبدئي) إيقاظ الخيوط المتسببة في الخطأ."
797
798 #. type: Plain text
799 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
800 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
801 msgid ""
802 "Minor fault mode supports only hugetlbfs-backed (since Linux 5.13) and "
803 "shmem-backed (since Linux 5.14) memory."
804 msgstr ""
805 "يدعم وضع الخطأ الثانوي فقط الذاكرة المدعومة بـ hugetlbfs (منذ لينكس 5.13) "
806 "والمدعومة بـ shmem (منذ لينكس 5.14)."
807
808 #. type: SS
809 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
810 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
811 #, no-wrap
812 msgid "Reading from the userfaultfd structure"
813 msgstr "القراءة من بنية userfaultfd"
814
815 #. type: Plain text
816 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
817 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
818 msgid ""
819 "Each B<read>(2) from the userfaultfd file descriptor returns one or more "
820 "I<uffd_msg> structures, each of which describes a page-fault event or an "
821 "event required for the non-cooperative userfaultfd usage:"
822 msgstr ""
823 "كل B<read>(2) من واصف ملف userfaultfd يُرجع بنية I<uffd_msg> واحدة أو أكثر، "
824 "كل منها يصف حدث خطأ صفحة أو حدثًا مطلوبًا لاستخدام userfaultfd غير التعاوني:"
825
826 #. type: Plain text
827 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
828 #: opensuse-leap-16-1 opensuse-tumbleweed
829 #, no-wrap
830 msgid ""
831 "struct uffd_msg {\n"
832 " __u8 event; /* Type of event */\n"
833 " ...\n"
834 " union {\n"
835 " struct {\n"
836 " __u64 flags; /* Flags describing fault */\n"
837 " __u64 address; /* Faulting address */\n"
838 " union {\n"
839 " __u32 ptid; /* Thread ID of the fault */\n"
840 " } feat;\n"
841 " } pagefault;\n"
842 "\\&\n"
843 " struct { /* Since Linux 4.11 */\n"
844 " __u32 ufd; /* Userfault file descriptor\n"
845 " of the child process */\n"
846 " } fork;\n"
847 "\\&\n"
848 " struct { /* Since Linux 4.11 */\n"
849 " __u64 from; /* Old address of remapped area */\n"
850 " __u64 to; /* New address of remapped area */\n"
851 " __u64 len; /* Original mapping size */\n"
852 " } remap;\n"
853 "\\&\n"
854 " struct { /* Since Linux 4.11 */\n"
855 " __u64 start; /* Start address of removed area */\n"
856 " __u64 end; /* End address of removed area */\n"
857 " } remove;\n"
858 " ...\n"
859 " } arg;\n"
860 "\\&\n"
861 " /* Padding fields omitted */\n"
862 "} __packed;\n"
863 msgstr ""
864 "struct uffd_msg {\n"
865 " __u8 event; /* Type of event */\n"
866 " ...\n"
867 " union {\n"
868 " struct {\n"
869 " __u64 flags; /* Flags describing fault */\n"
870 " __u64 address; /* Faulting address */\n"
871 " union {\n"
872 " __u32 ptid; /* Thread ID of the fault */\n"
873 " } feat;\n"
874 " } pagefault;\n"
875 "\\&\n"
876 " struct { /* Since Linux 4.11 */\n"
877 " __u32 ufd; /* Userfault file descriptor\n"
878 " of the child process */\n"
879 " } fork;\n"
880 "\\&\n"
881 " struct { /* Since Linux 4.11 */\n"
882 " __u64 from; /* Old address of remapped area */\n"
883 " __u64 to; /* New address of remapped area */\n"
884 " __u64 len; /* Original mapping size */\n"
885 " } remap;\n"
886 "\\&\n"
887 " struct { /* Since Linux 4.11 */\n"
888 " __u64 start; /* Start address of removed area */\n"
889 " __u64 end; /* End address of removed area */\n"
890 " } remove;\n"
891 " ...\n"
892 " } arg;\n"
893 "\\&\n"
894 " /* Padding fields omitted */\n"
895 "} __packed;\n"
896
897 #. type: Plain text
898 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
899 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
900 msgid ""
901 "If multiple events are available and the supplied buffer is large enough, "
902 "B<read>(2) returns as many events as will fit in the supplied buffer. If "
903 "the buffer supplied to B<read>(2) is smaller than the size of the "
904 "I<uffd_msg> structure, the B<read>(2) fails with the error B<EINVAL>."
905 msgstr ""
906 "إذا توفرت أحداث متعددة وكان الوسيط (buffer) الموفر كبيراً بما يكفي، يعيد "
907 "الاستدعاء B<read>(2) أكبر عدد ممكن من الأحداث التي يمكن احتواؤها في الوسيط "
908 "الموفر. أما إذا كان الوسيط الموفر للاستدعاء B<read>(2) أصغر من حجم بنية "
909 "I<uffd_msg>، فيخفق الاستدعاء B<read>(2) مع الخطأ B<EINVAL>."
910
911 #. type: Plain text
912 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
913 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
914 msgid "The fields set in the I<uffd_msg> structure are as follows:"
915 msgstr "الحقول المضبوطة في بنية I<uffd_msg> هي كما يلي:"
916
917 #. type: TP
918 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
919 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
920 #, no-wrap
921 msgid "I<event>"
922 msgstr "I<event>"
923
924 #. type: Plain text
925 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
926 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
927 msgid ""
928 "The type of event. Depending of the event type, different fields of the "
929 "I<arg> union represent details required for the event processing. The non-"
930 "page-fault events are generated only when appropriate feature is enabled "
931 "during API handshake with B<UFFDIO_API> B<ioctl>(2)."
932 msgstr ""
933 "نوع الحدث. وبناءً على نوع الحدث، تمثل الحقول المختلفة لاتحاد I<arg> (union) "
934 "التفاصيل المطلوبة لمعالجة الحدث. لا تُولّد الأحداث التي ليست من نوع"
935 " خطأ-الصفحة "
936 "(page-fault) إلا عند تفعيل الميزة المناسبة أثناء مصافحة واجهة برمجة "
937 "التطبيقات عبر B<UFFDIO_API> B<ioctl>(2)."
938
939 #. type: Plain text
940 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
941 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
942 msgid "The following values can appear in the I<event> field:"
943 msgstr "يمكن أن تظهر القيم التالية في حقل I<event>:"
944
945 #. type: TP
946 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
947 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
948 #, no-wrap
949 msgid "B<UFFD_EVENT_PAGEFAULT> (since Linux 4.3)"
950 msgstr "B<UFFD_EVENT_PAGEFAULT> (منذ لينكس 4.3)"
951
952 #. type: Plain text
953 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
954 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
955 msgid ""
956 "A page-fault event. The page-fault details are available in the "
957 "I<pagefault> field."
958 msgstr "حدث خطأ-صفحة. تفاصيل خطأ-الصفحة متاحة في الحقل I<pagefault>."
959
960 #. type: TP
961 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
962 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
963 #, no-wrap
964 msgid "B<UFFD_EVENT_FORK> (since Linux 4.11)"
965 msgstr "B<UFFD_EVENT_FORK> (منذ لينكس 4.11)"
966
967 #. FIXME describe duplication of userfault file descriptor during fork
968 #. type: Plain text
969 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
970 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
971 msgid ""
972 "Generated when the faulting process invokes B<fork>(2) (or B<clone>(2) "
973 "without the B<CLONE_VM> flag). The event details are available in the "
974 "I<fork> field."
975 msgstr ""
976 "يُتولد عندما تستدعي العملية المتسببة بالخطأ B<fork>(2) (أو B<clone>(2) بدون "
977 "علمة B<CLONE_VM>). تفاصيل الحدث متوفرة في حقل I<fork>."
978
979 #. type: TP
980 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
981 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
982 #, no-wrap
983 msgid "B<UFFD_EVENT_REMAP> (since Linux 4.11)"
984 msgstr "B<UFFD_EVENT_REMAP> (منذ لينكس 4.11)"
985
986 #. type: Plain text
987 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
988 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
989 msgid ""
990 "Generated when the faulting process invokes B<mremap>(2). The event details "
991 "are available in the I<remap> field."
992 msgstr ""
993 "يُتولد عندما تستدعي العملية المتسببة بالخطأ B<mremap>(2). تفاصيل الحدث متوفرة "
994 "في حقل I<remap>."
995
996 #. type: TP
997 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
998 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
999 #, no-wrap
1000 msgid "B<UFFD_EVENT_REMOVE> (since Linux 4.11)"
1001 msgstr "B<UFFD_EVENT_REMOVE> (منذ لينكس 4.11)"
1002
1003 #. type: Plain text
1004 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1005 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1006 msgid ""
1007 "Generated when the faulting process invokes B<madvise>(2) with "
1008 "B<MADV_DONTNEED> or B<MADV_REMOVE> advice. The event details are available "
1009 "in the I<remove> field."
1010 msgstr ""
1011 "يُتولد عندما تستدعي العملية المتسببة بالخطأ B<madvise>(2) مع نصيحة "
1012 "B<MADV_DONTNEED> أو B<MADV_REMOVE>. تفاصيل الحدث متوفرة في حقل I<remove>."
1013
1014 #. type: TP
1015 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1016 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1017 #, no-wrap
1018 msgid "B<UFFD_EVENT_UNMAP> (since Linux 4.11)"
1019 msgstr "B<UFFD_EVENT_UNMAP> (منذ لينكس 4.11)"
1020
1021 #. type: Plain text
1022 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1023 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1024 msgid ""
1025 "Generated when the faulting process unmaps a memory range, either explicitly "
1026 "using B<munmap>(2) or implicitly during B<mmap>(2) or B<mremap>(2). The "
1027 "event details are available in the I<remove> field."
1028 msgstr ""
1029 "يُتولد عندما تلغي العملية المتسببة بالخطأ تعيين نطاق ذاكرة، إما صراحة "
1030 "باستخدام B<munmap>(2) أو ضمنًا أثناء B<mmap>(2) أو B<mremap>(2). تفاصيل الحدث "
1031 "متوفرة في حقل I<remove>."
1032
1033 #. type: TP
1034 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1035 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1036 #, no-wrap
1037 msgid "I<pagefault.address>"
1038 msgstr "I<pagefault.address>"
1039
1040 #. type: Plain text
1041 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1042 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1043 msgid "The address that triggered the page fault."
1044 msgstr "العنوان الذي أثار خطأ الصفحة."
1045
1046 #. type: TP
1047 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1048 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1049 #, no-wrap
1050 msgid "I<pagefault.flags>"
1051 msgstr "I<pagefault.flags>"
1052
1053 #. type: Plain text
1054 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1055 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1056 msgid ""
1057 "A bit mask of flags that describe the event. For B<UFFD_EVENT_PAGEFAULT>, "
1058 "the following flag may appear:"
1059 msgstr ""
1060 "قناع بتات للأعلام التي تصف الحدث. بالنسبة لـ B<UFFD_EVENT_PAGEFAULT>، قد "
1061 "يظهر العلم التالي:"
1062
1063 #. type: TP
1064 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1065 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1066 #, no-wrap
1067 msgid "B<UFFD_PAGEFAULT_FLAG_WP>"
1068 msgstr "B<UFFD_PAGEFAULT_FLAG_WP>"
1069
1070 #. type: Plain text
1071 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1072 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1073 msgid "If this flag is set, then the fault was a write-protect fault."
1074 msgstr "إذا كان هذا العلم مضبوطًا، فإن الخطأ كان خطأ حماية من الكتابة."
1075
1076 #. type: TP
1077 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1078 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1079 #, no-wrap
1080 msgid "B<UFFD_PAGEFAULT_FLAG_MINOR>"
1081 msgstr "B<UFFD_PAGEFAULT_FLAG_MINOR>"
1082
1083 #. type: Plain text
1084 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1085 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1086 msgid "If this flag is set, then the fault was a minor fault."
1087 msgstr "إذا كان هذا العلم مضبوطًا، فإن الخطأ كان خطأ بسيطًا."
1088
1089 #. type: TP
1090 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1091 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1092 #, no-wrap
1093 msgid "B<UFFD_PAGEFAULT_FLAG_WRITE>"
1094 msgstr "B<UFFD_PAGEFAULT_FLAG_WRITE>"
1095
1096 #. type: Plain text
1097 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1098 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1099 msgid "If this flag is set, then the fault was a write fault."
1100 msgstr "إذا كان هذا العلم مضبوطًا، فإن الخطأ كان خطأ كتابة."
1101
1102 #. type: Plain text
1103 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1104 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1105 msgid ""
1106 "If neither B<UFFD_PAGEFAULT_FLAG_WP> nor B<UFFD_PAGEFAULT_FLAG_MINOR> are "
1107 "set, then the fault was a missing fault."
1108 msgstr ""
1109 "إذا لم يكن أي من B<UFFD_PAGEFAULT_FLAG_WP> أو B<UFFD_PAGEFAULT_FLAG_MINOR> "
1110 "مضبوطًا، فإن الخطأ كان خطأ فقدان."
1111
1112 #. type: TP
1113 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1114 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1115 #, no-wrap
1116 msgid "I<pagefault.feat.pid>"
1117 msgstr "I<pagefault.feat.pid>"
1118
1119 #. type: Plain text
1120 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1121 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1122 msgid "The thread ID that triggered the page fault."
1123 msgstr "معرف الخيط الذي أثار خطأ الصفحة."
1124
1125 #. type: TP
1126 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1127 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1128 #, no-wrap
1129 msgid "I<fork.ufd>"
1130 msgstr "I<fork.ufd>"
1131
1132 #. type: Plain text
1133 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1134 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1135 msgid ""
1136 "The file descriptor associated with the userfault object created for the "
1137 "child created by B<fork>(2)."
1138 msgstr ""
1139 "واصف الملف المرتبط بكائن userfault الذي أُنشئ للطفل الذي أنشأته B<fork>(2)."
1140
1141 #. type: TP
1142 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1143 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1144 #, no-wrap
1145 msgid "I<remap.from>"
1146 msgstr "I<remap.from>"
1147
1148 #. type: Plain text
1149 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1150 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1151 msgid ""
1152 "The original address of the memory range that was remapped using "
1153 "B<mremap>(2)."
1154 msgstr "العنوان الأصلي لنطاق الذاكرة الذي أُعيد تعيينه باستخدام B<mremap>(2)."
1155
1156 #. type: TP
1157 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1158 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1159 #, no-wrap
1160 msgid "I<remap.to>"
1161 msgstr "I<remap.to>"
1162
1163 #. type: Plain text
1164 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1165 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1166 msgid ""
1167 "The new address of the memory range that was remapped using B<mremap>(2)."
1168 msgstr "العنوان الجديد لنطاق الذاكرة الذي أُعيد تعيينه باستخدام B<mremap>(2)."
1169
1170 #. type: TP
1171 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1172 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1173 #, no-wrap
1174 msgid "I<remap.len>"
1175 msgstr "I<remap.len>"
1176
1177 #. type: Plain text
1178 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1179 #: opensuse-leap-16-1 opensuse-tumbleweed
1180 msgid ""
1181 "The original size of the memory range that was remapped using B<mremap>(2)."
1182 msgstr "الحجم الأصلي لنطاق الذاكرة الذي أُعيد تعيينه باستخدام B<mremap>(2)."
1183
1184 #. type: TP
1185 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1186 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1187 #, no-wrap
1188 msgid "I<remove.start>"
1189 msgstr "I<remove.start>"
1190
1191 #. type: Plain text
1192 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1193 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1194 msgid ""
1195 "The start address of the memory range that was freed using B<madvise>(2) or "
1196 "unmapped"
1197 msgstr ""
1198 "عنوان البداية لنطاق الذاكرة الذي حُرر باستخدام B<madvise>(2) أو أُلغي تعيينه"
1199
1200 #. type: TP
1201 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1202 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1203 #, no-wrap
1204 msgid "I<remove.end>"
1205 msgstr "I<remove.end>"
1206
1207 #. type: Plain text
1208 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1209 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1210 msgid ""
1211 "The end address of the memory range that was freed using B<madvise>(2) or "
1212 "unmapped"
1213 msgstr ""
1214 "عنوان نهاية نطاق الذاكرة الذي تم تحريره باستخدام B<madvise>(2) أو إلغاء "
1215 "تعيينه"
1216
1217 #. type: Plain text
1218 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1219 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1220 msgid ""
1221 "A B<read>(2) on a userfaultfd file descriptor can fail with the following "
1222 "errors:"
1223 msgstr "قد تفشل عملية B<read>(2) على واصف ملف userfaultfd مع الأخطاء التالية:"
1224
1225 #. type: TP
1226 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1227 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1228 #, no-wrap
1229 msgid "B<EINVAL>"
1230 msgstr "B<EINVAL>"
1231
1232 #. type: Plain text
1233 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1234 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1235 msgid ""
1236 "The userfaultfd object has not yet been enabled using the B<UFFDIO_API> "
1237 "B<ioctl>(2) operation"
1238 msgstr ""
1239 "لم يتم تمكين كائن userfaultfd بعد باستخدام عملية B<UFFDIO_API> B<ioctl>(2)"
1240
1241 #. FIXME What is the reason for this seemingly odd behavior with respect
1242 #. to the O_NONBLOCK flag? (see userfaultfd_poll() in fs/userfaultfd.c).
1243 #. Something needs to be said about this.
1244 #. type: Plain text
1245 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1246 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1247 msgid ""
1248 "If the B<O_NONBLOCK> flag is enabled in the associated open file "
1249 "description, the userfaultfd file descriptor can be monitored with "
1250 "B<poll>(2), B<select>(2), and B<epoll>(7). When events are available, the "
1251 "file descriptor indicates as readable. If the B<O_NONBLOCK> flag is not "
1252 "enabled, then B<poll>(2) (always) indicates the file as having a B<POLLERR> "
1253 "condition, and B<select>(2) indicates the file descriptor as both readable "
1254 "and writable."
1255 msgstr ""
1256 "إذا تم تمكين علامة B<O_NONBLOCK> في وصف الملف المفتوح المرتبط، يمكن مراقبة "
1257 "واصف ملف userfaultfd باستخدام B<poll>(2) وB<select>(2) وB<epoll>(7). عندما "
1258 "تتوفر الأحداث، يشير واصف الملف إلى أنه قابل للقراءة. إذا لم يتم تمكين علامة "
1259 "B<O_NONBLOCK>، فإن B<poll>(2) (دائمًا) يشير إلى أن الملف لديه حالة "
1260 "B<POLLERR>، ويشير B<select>(2) إلى أن واصف الملف قابل للقراءة والكتابة معًا."
1261
1262 #. type: SH
1263 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1264 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1265 #, no-wrap
1266 msgid "RETURN VALUE"
1267 msgstr "قيمة الإرجاع"
1268
1269 #. type: Plain text
1270 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1271 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1272 msgid ""
1273 "On success, B<userfaultfd>() returns a new file descriptor that refers to "
1274 "the userfaultfd object. On error, -1 is returned, and I<errno> is set to "
1275 "indicate the error."
1276 msgstr ""
1277 "عند النجاح، تُرجع B<userfaultfd>() واصف ملف جديد يشير إلى كائن userfaultfd. "
1278 "عند الخطأ، تُرجع -1، ويتم تعيين I<errno> للإشارة إلى الخطأ."
1279
1280 #. type: SH
1281 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1282 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1283 #, no-wrap
1284 msgid "ERRORS"
1285 msgstr "الأخطاء"
1286
1287 #. type: Plain text
1288 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1289 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1290 msgid "An unsupported value was specified in I<flags>."
1291 msgstr "عُيّنت قيمة غير مدعومة في I<flags>."
1292
1293 #. type: TP
1294 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1295 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1296 #, no-wrap
1297 msgid "B<EMFILE>"
1298 msgstr "B<EMFILE>"
1299
1300 #. type: Plain text
1301 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1302 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1303 msgid ""
1304 "The per-process limit on the number of open file descriptors has been reached"
1305 msgstr "تم الوصول إلى الحد الأقصى لكل عملية لعدد واصفات الملفات المفتوحة"
1306
1307 #. type: TP
1308 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1309 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1310 #, no-wrap
1311 msgid "B<ENFILE>"
1312 msgstr "B<ENFILE>"
1313
1314 #. type: Plain text
1315 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1316 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1317 msgid ""
1318 "The system-wide limit on the total number of open files has been reached."
1319 msgstr "وُصل إلى الحد الأقصى لإجمالي عدد الملفات المفتوحة على مستوى النظام."
1320
1321 #. type: TP
1322 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1323 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1324 #, no-wrap
1325 msgid "B<ENOMEM>"
1326 msgstr "B<ENOMEM>"
1327
1328 #. type: Plain text
1329 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1330 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1331 msgid "Insufficient kernel memory was available."
1332 msgstr "ذاكرة النواة المتوفرة غير كافية."
1333
1334 #. type: TP
1335 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1336 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1337 #, no-wrap
1338 msgid "B<EPERM> (since Linux 5.2)"
1339 msgstr "B<EPERM> (منذ Linux 5.2)"
1340
1341 #. cefdca0a86be517bc390fc4541e3674b8e7803b0
1342 #. type: Plain text
1343 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1344 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1345 msgid ""
1346 "The caller is not privileged (does not have the B<CAP_SYS_PTRACE> capability "
1347 "in the initial user namespace), and I</proc/sys/vm/unprivileged_userfaultfd> "
1348 "has the value 0."
1349 msgstr ""
1350 "المتصل ليس لديه صلاحية (ليس لديه قدرة B<CAP_SYS_PTRACE> في مساحة اسم "
1351 "المستخدم الأولية)، وقيمة I</proc/sys/vm/unprivileged_userfaultfd> هي 0."
1352
1353 #. type: SH
1354 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1355 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1356 #, no-wrap
1357 msgid "STANDARDS"
1358 msgstr "المعايير"
1359
1360 #. type: Plain text
1361 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1362 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1363 msgid "Linux."
1364 msgstr "لينكس."
1365
1366 #. type: SH
1367 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1368 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1369 #, no-wrap
1370 msgid "HISTORY"
1371 msgstr "التاريخ"
1372
1373 #. type: Plain text
1374 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1375 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1376 msgid "Linux 4.3."
1377 msgstr "لينكس 4.3."
1378
1379 #. type: Plain text
1380 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1381 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1382 msgid ""
1383 "Support for hugetlbfs and shared memory areas and non-page-fault events was "
1384 "added in Linux 4.11"
1385 msgstr ""
1386 "تمت إضافة دعم hugetlbfs ومناطق الذاكرة المشتركة وأحداث غير خطأ الصفحة في "
1387 "Linux 4.11"
1388
1389 #. type: SH
1390 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1391 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1392 #, no-wrap
1393 msgid "NOTES"
1394 msgstr "ملاحظات"
1395
1396 #. type: Plain text
1397 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1398 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1399 msgid ""
1400 "The userfaultfd mechanism can be used as an alternative to traditional user-"
1401 "space paging techniques based on the use of the B<SIGSEGV> signal and "
1402 "B<mmap>(2). It can also be used to implement lazy restore for checkpoint/"
1403 "restore mechanisms, as well as post-copy migration to allow (nearly) "
1404 "uninterrupted execution when transferring virtual machines and Linux "
1405 "containers from one host to another."
1406 msgstr ""
1407 "يمكن استخدام آلية userfaultfd كبديل لتقنيات الترحيل التقليدية في مساحة "
1408 "المستخدم القائمة على استخدام إشارة B<SIGSEGV> وB<mmap>(2). يمكن استخدامها "
1409 "أيضًا لتنفيذ الاستعادة البطيئة لآليات نقطة التفتيش/الاستعادة، بالإضافة إلى "
1410 "الترحيل بعد النسخ للسماح بالتنفيذ (شبه) المتواصل عند نقل الأجهزة الافتراضية "
1411 "وحاويات Linux من مضيف إلى آخر."
1412
1413 #. type: SH
1414 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1415 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1416 #, no-wrap
1417 msgid "BUGS"
1418 msgstr "العلل"
1419
1420 #. type: Plain text
1421 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1422 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1423 msgid ""
1424 "If the B<UFFD_FEATURE_EVENT_FORK> is enabled and a system call from the "
1425 "B<fork>(2) family is interrupted by a signal or failed, a stale userfaultfd "
1426 "descriptor might be created. In this case, a spurious B<UFFD_EVENT_FORK> "
1427 "will be delivered to the userfaultfd monitor."
1428 msgstr ""
1429 "إذا تم تمكين B<UFFD_FEATURE_EVENT_FORK> وتم مقاطعة استدعاء نظام من عائلة "
1430 "B<fork>(2) بواسطة إشارة أو فشل، فقد يتم إنشاء واصف userfaultfd قديم. في هذه "
1431 "الحالة، سيتم تسليم B<UFFD_EVENT_FORK> زائف إلى مراقب userfaultfd."
1432
1433 #. type: SH
1434 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1435 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1436 #, no-wrap
1437 msgid "EXAMPLES"
1438 msgstr "أمثلة"
1439
1440 #. type: Plain text
1441 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1442 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1443 msgid ""
1444 "The program below demonstrates the use of the userfaultfd mechanism. The "
1445 "program creates two threads, one of which acts as the page-fault handler for "
1446 "the process, for the pages in a demand-page zero region created using "
1447 "B<mmap>(2)."
1448 msgstr ""
1449 "يوضح البرنامج أدناه استخدام آلية userfaultfd. يقوم البرنامج بإنشاء خيطين، "
1450 "أحدهما يعمل كمعالج خطأ الصفحة للعملية، للصفحات في منطقة طلب صفحة صفرية تم "
1451 "إنشاؤها باستخدام B<mmap>(2)."
1452
1453 #. type: Plain text
1454 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1455 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1456 msgid ""
1457 "The program takes one command-line argument, which is the number of pages "
1458 "that will be created in a mapping whose page faults will be handled via "
1459 "userfaultfd. After creating a userfaultfd object, the program then creates "
1460 "an anonymous private mapping of the specified size and registers the address "
1461 "range of that mapping using the B<UFFDIO_REGISTER> B<ioctl>(2) operation. "
1462 "The program then creates a second thread that will perform the task of "
1463 "handling page faults."
1464 msgstr ""
1465 "يأخذ البرنامج وسيطة سطر أوامر واحدة، وهي عدد الصفحات التي سيتم إنشاؤها في "
1466 "تعيين سيتم التعامل مع أخطاء صفحته عبر userfaultfd. بعد إنشاء كائن "
1467 "userfaultfd، يقوم البرنامج بعد ذلك بإنشاء تعيين خاص مجهول بالحجم المحدد "
1468 "ويسجل نطاق العنوان لذلك التعيين باستخدام عملية B<UFFDIO_REGISTER> "
1469 "B<ioctl>(2). ثم يقوم البرنامج بإنشاء خيط ثانٍ سيقوم بمهمة معالجة أخطاء الصفحة."
1470
1471 #. type: Plain text
1472 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1473 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1474 msgid ""
1475 "The main thread then walks through the pages of the mapping fetching bytes "
1476 "from successive pages. Because the pages have not yet been accessed, the "
1477 "first access of a byte in each page will trigger a page-fault event on the "
1478 "userfaultfd file descriptor."
1479 msgstr ""
1480 "ثم يتجول الخيط الرئيسي عبر صفحات التعيين لجلب البايتات من الصفحات المتتالية. "
1481 "نظرًا لعدم الوصول إلى الصفحات بعد، فإن أول وصول لبايت في كل صفحة سيؤدي إلى "
1482 "تشغيل حدث خطأ صفحة على واصف ملف userfaultfd."
1483
1484 #. type: Plain text
1485 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1486 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1487 msgid ""
1488 "Each of the page-fault events is handled by the second thread, which sits in "
1489 "a loop processing input from the userfaultfd file descriptor. In each loop "
1490 "iteration, the second thread first calls B<poll>(2) to check the state of "
1491 "the file descriptor, and then reads an event from the file descriptor. All "
1492 "such events should be B<UFFD_EVENT_PAGEFAULT> events, which the thread "
1493 "handles by copying a page of data into the faulting region using the "
1494 "B<UFFDIO_COPY> B<ioctl>(2) operation."
1495 msgstr ""
1496 "يتم التعامل مع كل حدث من أحداث خطأ الصفحة بواسطة الخيط الثاني، الذي يجلس في "
1497 "حلقة لمعالجة الإدخال من واصف ملف userfaultfd. في كل تكرار للحلقة، يستدعي "
1498 "الخيط الثاني أولاً B<poll>(2) للتحقق من حالة واصف الملف، ثم يقرأ حدثًا من"
1499 " واصف "
1500 "الملف. يجب أن تكون كل هذه الأحداث أحداث B<UFFD_EVENT_PAGEFAULT>، والتي "
1501 "يعالجها الخيط عن طريق نسخ صفحة من البيانات إلى المنطقة المتسببة في الخطأ "
1502 "باستخدام عملية B<UFFDIO_COPY> B<ioctl>(2)."
1503
1504 #. type: Plain text
1505 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1506 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1507 msgid "The following is an example of what we see when running the program:"
1508 msgstr "فيما يلي مثال لما نراه عند تشغيل البرنامج:"
1509
1510 #. type: Plain text
1511 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1512 #: opensuse-tumbleweed
1513 #, no-wrap
1514 msgid ""
1515 "$B< ./userfaultfd_demo 3>;\n"
1516 "Address returned by mmap() = 0x7fd30106c000\n"
1517 "\\&\n"
1518 "fault_handler_thread():\n"
1519 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1520 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n"
1521 " (uffdio_copy.copy returned 4096)\n"
1522 "Read address 0x7fd30106c00f in main(): A\n"
1523 "Read address 0x7fd30106c40f in main(): A\n"
1524 "Read address 0x7fd30106c80f in main(): A\n"
1525 "Read address 0x7fd30106cc0f in main(): A\n"
1526 "\\&\n"
1527 "fault_handler_thread():\n"
1528 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1529 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n"
1530 " (uffdio_copy.copy returned 4096)\n"
1531 "Read address 0x7fd30106d00f in main(): B\n"
1532 "Read address 0x7fd30106d40f in main(): B\n"
1533 "Read address 0x7fd30106d80f in main(): B\n"
1534 "Read address 0x7fd30106dc0f in main(): B\n"
1535 "\\&\n"
1536 "fault_handler_thread():\n"
1537 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1538 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n"
1539 " (uffdio_copy.copy returned 4096)\n"
1540 "Read address 0x7fd30106e00f in main(): C\n"
1541 "Read address 0x7fd30106e40f in main(): C\n"
1542 "Read address 0x7fd30106e80f in main(): C\n"
1543 "Read address 0x7fd30106ec0f in main(): C\n"
1544 msgstr ""
1545 "$B< ./userfaultfd_demo 3>;\n"
1546 "Address returned by mmap() = 0x7fd30106c000\n"
1547 "\\&\n"
1548 "fault_handler_thread():\n"
1549 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1550 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n"
1551 " (uffdio_copy.copy returned 4096)\n"
1552 "Read address 0x7fd30106c00f in main(): A\n"
1553 "Read address 0x7fd30106c40f in main(): A\n"
1554 "Read address 0x7fd30106c80f in main(): A\n"
1555 "Read address 0x7fd30106cc0f in main(): A\n"
1556 "\\&\n"
1557 "fault_handler_thread():\n"
1558 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1559 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n"
1560 " (uffdio_copy.copy returned 4096)\n"
1561 "Read address 0x7fd30106d00f in main(): B\n"
1562 "Read address 0x7fd30106d40f in main(): B\n"
1563 "Read address 0x7fd30106d80f in main(): B\n"
1564 "Read address 0x7fd30106dc0f in main(): B\n"
1565 "\\&\n"
1566 "fault_handler_thread():\n"
1567 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
1568 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n"
1569 " (uffdio_copy.copy returned 4096)\n"
1570 "Read address 0x7fd30106e00f in main(): C\n"
1571 "Read address 0x7fd30106e40f in main(): C\n"
1572 "Read address 0x7fd30106e80f in main(): C\n"
1573 "Read address 0x7fd30106ec0f in main(): C\n"
1574
1575 #. type: SS
1576 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1577 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1578 #, no-wrap
1579 msgid "Program source"
1580 msgstr "مصدر البرنامج"
1581
1582 #. type: Plain text
1583 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
1584 #, no-wrap
1585 msgid ""
1586 "/* userfaultfd_demo.c\n"
1587 "\\&\n"
1588 " Licensed under the GNU General Public License version 2 or later.\n"
1589 "*/\n"
1590 "#define _GNU_SOURCE\n"
1591 "#include E<lt>err.hE<gt>\n"
1592 "#include E<lt>errno.hE<gt>\n"
1593 "#include E<lt>fcntl.hE<gt>\n"
1594 "#include E<lt>inttypes.hE<gt>\n"
1595 "#include E<lt>linux/userfaultfd.hE<gt>\n"
1596 "#include E<lt>poll.hE<gt>\n"
1597 "#include E<lt>pthread.hE<gt>\n"
1598 "#include E<lt>stdio.hE<gt>\n"
1599 "#include E<lt>stdlib.hE<gt>\n"
1600 "#include E<lt>string.hE<gt>\n"
1601 "#include E<lt>sys/ioctl.hE<gt>\n"
1602 "#include E<lt>sys/mman.hE<gt>\n"
1603 "#include E<lt>sys/syscall.hE<gt>\n"
1604 "#include E<lt>unistd.hE<gt>\n"
1605 "\\&\n"
1606 "static int page_size;\n"
1607 "\\&\n"
1608 "static void *\n"
1609 "fault_handler_thread(void *arg)\n"
1610 "{\n"
1611 " long uffd; /* userfaultfd file descriptor */\n"
1612 "\\&\n"
1613 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
1614 " static char *page = NULL;\n"
1615 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
1616 "\\&\n"
1617 " uffd = (long) arg;\n"
1618 "\\&\n"
1619 " /* Create a page that will be copied into the faulting region. */\n"
1620 "\\&\n"
1621 " if (page == NULL) {\n"
1622 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
1623 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
1624 " if (page == MAP_FAILED)\n"
1625 " err(EXIT_FAILURE, \"mmap\");\n"
1626 " }\n"
1627 "\\&\n"
1628 " /* Loop, handling incoming events on the userfaultfd\n"
1629 " file descriptor. */\n"
1630 "\\&\n"
1631 " for (;;) {\n"
1632 " int nready;\n"
1633 " ssize_t nread;\n"
1634 " struct pollfd pollfd;\n"
1635 " struct uffdio_copy uffdio_copy;\n"
1636 "\\&\n"
1637 " /* See what poll() tells us about the userfaultfd. */\n"
1638 "\\&\n"
1639 " pollfd.fd = uffd;\n"
1640 " pollfd.events = POLLIN;\n"
1641 " nready = poll(&pollfd, 1, -1);\n"
1642 " if (nready == -1)\n"
1643 " err(EXIT_FAILURE, \"poll\");\n"
1644 "\\&\n"
1645 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
1646 " printf(\" poll() returns: nready = %d; \"\n"
1647 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
1648 " (pollfd.revents & POLLIN) != 0,\n"
1649 " (pollfd.revents & POLLERR) != 0);\n"
1650 "\\&\n"
1651 " /* Read an event from the userfaultfd. */\n"
1652 "\\&\n"
1653 " nread = read(uffd, &msg, sizeof(msg));\n"
1654 " if (nread == 0) {\n"
1655 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
1656 " exit(EXIT_FAILURE);\n"
1657 " }\n"
1658 "\\&\n"
1659 " if (nread == -1)\n"
1660 " err(EXIT_FAILURE, \"read\");\n"
1661 "\\&\n"
1662 " /* We expect only one kind of event; verify that assumption. */\n"
1663 "\\&\n"
1664 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
1665 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
1666 " exit(EXIT_FAILURE);\n"
1667 " }\n"
1668 "\\&\n"
1669 " /* Display info about the page-fault event. */\n"
1670 "\\&\n"
1671 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
1672 " printf(\"flags = %w64x; \", msg.arg.pagefault.flags);\n"
1673 " printf(\"address = %w64x\\[rs]n\", msg.arg.pagefault.address);\n"
1674 "\\&\n"
1675 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
1676 " region. Vary the contents that are copied in, so that it\n"
1677 " is more obvious that each fault is handled separately. */\n"
1678 "\\&\n"
1679 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
1680 " fault_cnt++;\n"
1681 "\\&\n"
1682 " uffdio_copy.src = (unsigned long) page;\n"
1683 "\\&\n"
1684 " /* We need to handle page faults in units of pages(!).\n"
1685 " So, round faulting address down to page boundary. */\n"
1686 "\\&\n"
1687 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
1688 " \\[ti](page_size - 1);\n"
1689 " uffdio_copy.len = page_size;\n"
1690 " uffdio_copy.mode = 0;\n"
1691 " uffdio_copy.copy = 0;\n"
1692 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
1693 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
1694 "\\&\n"
1695 " printf(\" (uffdio_copy.copy returned %w64d)\\[rs]n\",\n"
1696 " uffdio_copy.copy);\n"
1697 " }\n"
1698 "}\n"
1699 "\\&\n"
1700 "int\n"
1701 "main(int argc, char *argv[])\n"
1702 "{\n"
1703 " int s;\n"
1704 " char *addr; /* Start of region handled by userfaultfd */\n"
1705 " long uffd; /* userfaultfd file descriptor */\n"
1706 " size_t size, i; /* Size of region handled by userfaultfd */\n"
1707 " pthread_t thr; /* ID of thread that handles page faults */\n"
1708 " struct uffdio_api uffdio_api;\n"
1709 " struct uffdio_register uffdio_register;\n"
1710 "\\&\n"
1711 " if (argc != 2) {\n"
1712 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
1713 " exit(EXIT_FAILURE);\n"
1714 " }\n"
1715 "\\&\n"
1716 " page_size = sysconf(_SC_PAGE_SIZE);\n"
1717 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
1718 "\\&\n"
1719 " /* Create and enable userfaultfd object. */\n"
1720 "\\&\n"
1721 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
1722 " if (uffd == -1)\n"
1723 " err(EXIT_FAILURE, \"userfaultfd\");\n"
1724 "\\&\n"
1725 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
1726 " example doesn't require any specific features.\n"
1727 "\\&\n"
1728 " Programs that *do* should call UFFDIO_API twice: once with\n"
1729 " `features = 0` to detect features supported by this kernel, and\n"
1730 " again with the subset of features the program actually wants to\n"
1731 " enable. */\n"
1732 " uffdio_api.api = UFFD_API;\n"
1733 " uffdio_api.features = 0;\n"
1734 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
1735 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
1736 "\\&\n"
1737 " /* Create a private anonymous mapping. The memory will be\n"
1738 " demand-zero paged--that is, not yet allocated. When we\n"
1739 " actually touch the memory, it will be allocated via\n"
1740 " the userfaultfd. */\n"
1741 "\\&\n"
1742 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
1743 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
1744 " if (addr == MAP_FAILED)\n"
1745 " err(EXIT_FAILURE, \"mmap\");\n"
1746 "\\&\n"
1747 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
1748 "\\&\n"
1749 " /* Register the memory range of the mapping we just created for\n"
1750 " handling by the userfaultfd object. In mode, we request to track\n"
1751 " missing pages (i.e., pages that have not yet been faulted in). */\n"
1752 "\\&\n"
1753 " uffdio_register.range.start = (unsigned long) addr;\n"
1754 " uffdio_register.range.len = size;\n"
1755 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
1756 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
1757 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
1758 "\\&\n"
1759 " /* Create a thread that will process the userfaultfd events. */\n"
1760 "\\&\n"
1761 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
1762 " if (s != 0) {\n"
1763 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
1764 " }\n"
1765 "\\&\n"
1766 " /* Main thread now touches memory in the mapping, touching\n"
1767 " locations 1024 bytes apart. This will trigger userfaultfd\n"
1768 " events for all pages in the region. */\n"
1769 "\\&\n"
1770 " i = 0xf; /* Ensure that faulting address is not on a page\n"
1771 " boundary, in order to test that we correctly\n"
1772 " handle that case in fault_handling_thread(). */\n"
1773 " while (i E<lt> size) {\n"
1774 " char c;\n"
1775 "\\&\n"
1776 " c = addr[i];\n"
1777 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
1778 " printf(\"%c\\[rs]n\", c);\n"
1779 " i += 1024;\n"
1780 " usleep(100000); /* Slow things down a little */\n"
1781 " }\n"
1782 "\\&\n"
1783 " exit(EXIT_SUCCESS);\n"
1784 "}\n"
1785 msgstr ""
1786 "/* userfaultfd_demo.c\n"
1787 "\\&\n"
1788 " Licensed under the GNU General Public License version 2 or later.\n"
1789 "*/\n"
1790 "#define _GNU_SOURCE\n"
1791 "#include E<lt>err.hE<gt>\n"
1792 "#include E<lt>errno.hE<gt>\n"
1793 "#include E<lt>fcntl.hE<gt>\n"
1794 "#include E<lt>inttypes.hE<gt>\n"
1795 "#include E<lt>linux/userfaultfd.hE<gt>\n"
1796 "#include E<lt>poll.hE<gt>\n"
1797 "#include E<lt>pthread.hE<gt>\n"
1798 "#include E<lt>stdio.hE<gt>\n"
1799 "#include E<lt>stdlib.hE<gt>\n"
1800 "#include E<lt>string.hE<gt>\n"
1801 "#include E<lt>sys/ioctl.hE<gt>\n"
1802 "#include E<lt>sys/mman.hE<gt>\n"
1803 "#include E<lt>sys/syscall.hE<gt>\n"
1804 "#include E<lt>unistd.hE<gt>\n"
1805 "\\&\n"
1806 "static int page_size;\n"
1807 "\\&\n"
1808 "static void *\n"
1809 "fault_handler_thread(void *arg)\n"
1810 "{\n"
1811 " long uffd; /* userfaultfd file descriptor */\n"
1812 "\\&\n"
1813 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
1814 " static char *page = NULL;\n"
1815 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
1816 "\\&\n"
1817 " uffd = (long) arg;\n"
1818 "\\&\n"
1819 " /* Create a page that will be copied into the faulting region. */\n"
1820 "\\&\n"
1821 " if (page == NULL) {\n"
1822 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
1823 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
1824 " if (page == MAP_FAILED)\n"
1825 " err(EXIT_FAILURE, \"mmap\");\n"
1826 " }\n"
1827 "\\&\n"
1828 " /* Loop, handling incoming events on the userfaultfd\n"
1829 " file descriptor. */\n"
1830 "\\&\n"
1831 " for (;;) {\n"
1832 " int nready;\n"
1833 " ssize_t nread;\n"
1834 " struct pollfd pollfd;\n"
1835 " struct uffdio_copy uffdio_copy;\n"
1836 "\\&\n"
1837 " /* See what poll() tells us about the userfaultfd. */\n"
1838 "\\&\n"
1839 " pollfd.fd = uffd;\n"
1840 " pollfd.events = POLLIN;\n"
1841 " nready = poll(&pollfd, 1, -1);\n"
1842 " if (nready == -1)\n"
1843 " err(EXIT_FAILURE, \"poll\");\n"
1844 "\\&\n"
1845 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
1846 " printf(\" poll() returns: nready = %d; \"\n"
1847 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
1848 " (pollfd.revents & POLLIN) != 0,\n"
1849 " (pollfd.revents & POLLERR) != 0);\n"
1850 "\\&\n"
1851 " /* Read an event from the userfaultfd. */\n"
1852 "\\&\n"
1853 " nread = read(uffd, &msg, sizeof(msg));\n"
1854 " if (nread == 0) {\n"
1855 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
1856 " exit(EXIT_FAILURE);\n"
1857 " }\n"
1858 "\\&\n"
1859 " if (nread == -1)\n"
1860 " err(EXIT_FAILURE, \"read\");\n"
1861 "\\&\n"
1862 " /* We expect only one kind of event; verify that assumption. */\n"
1863 "\\&\n"
1864 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
1865 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
1866 " exit(EXIT_FAILURE);\n"
1867 " }\n"
1868 "\\&\n"
1869 " /* Display info about the page-fault event. */\n"
1870 "\\&\n"
1871 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
1872 " printf(\"flags = %w64x; \", msg.arg.pagefault.flags);\n"
1873 " printf(\"address = %w64x\\[rs]n\", msg.arg.pagefault.address);\n"
1874 "\\&\n"
1875 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
1876 " region. Vary the contents that are copied in, so that it\n"
1877 " is more obvious that each fault is handled separately. */\n"
1878 "\\&\n"
1879 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
1880 " fault_cnt++;\n"
1881 "\\&\n"
1882 " uffdio_copy.src = (unsigned long) page;\n"
1883 "\\&\n"
1884 " /* We need to handle page faults in units of pages(!).\n"
1885 " So, round faulting address down to page boundary. */\n"
1886 "\\&\n"
1887 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
1888 " \\[ti](page_size - 1);\n"
1889 " uffdio_copy.len = page_size;\n"
1890 " uffdio_copy.mode = 0;\n"
1891 " uffdio_copy.copy = 0;\n"
1892 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
1893 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
1894 "\\&\n"
1895 " printf(\" (uffdio_copy.copy returned %w64d)\\[rs]n\",\n"
1896 " uffdio_copy.copy);\n"
1897 " }\n"
1898 "}\n"
1899 "\\&\n"
1900 "int\n"
1901 "main(int argc, char *argv[])\n"
1902 "{\n"
1903 " int s;\n"
1904 " char *addr; /* Start of region handled by userfaultfd */\n"
1905 " long uffd; /* userfaultfd file descriptor */\n"
1906 " size_t size, i; /* Size of region handled by userfaultfd */\n"
1907 " pthread_t thr; /* ID of thread that handles page faults */\n"
1908 " struct uffdio_api uffdio_api;\n"
1909 " struct uffdio_register uffdio_register;\n"
1910 "\\&\n"
1911 " if (argc != 2) {\n"
1912 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
1913 " exit(EXIT_FAILURE);\n"
1914 " }\n"
1915 "\\&\n"
1916 " page_size = sysconf(_SC_PAGE_SIZE);\n"
1917 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
1918 "\\&\n"
1919 " /* Create and enable userfaultfd object. */\n"
1920 "\\&\n"
1921 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
1922 " if (uffd == -1)\n"
1923 " err(EXIT_FAILURE, \"userfaultfd\");\n"
1924 "\\&\n"
1925 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
1926 " example doesn't require any specific features.\n"
1927 "\\&\n"
1928 " Programs that *do* should call UFFDIO_API twice: once with\n"
1929 " `features = 0` to detect features supported by this kernel, and\n"
1930 " again with the subset of features the program actually wants to\n"
1931 " enable. */\n"
1932 " uffdio_api.api = UFFD_API;\n"
1933 " uffdio_api.features = 0;\n"
1934 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
1935 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
1936 "\\&\n"
1937 " /* Create a private anonymous mapping. The memory will be\n"
1938 " demand-zero paged--that is, not yet allocated. When we\n"
1939 " actually touch the memory, it will be allocated via\n"
1940 " the userfaultfd. */\n"
1941 "\\&\n"
1942 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
1943 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
1944 " if (addr == MAP_FAILED)\n"
1945 " err(EXIT_FAILURE, \"mmap\");\n"
1946 "\\&\n"
1947 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
1948 "\\&\n"
1949 " /* Register the memory range of the mapping we just created for\n"
1950 " handling by the userfaultfd object. In mode, we request to track\n"
1951 " missing pages (i.e., pages that have not yet been faulted in). */\n"
1952 "\\&\n"
1953 " uffdio_register.range.start = (unsigned long) addr;\n"
1954 " uffdio_register.range.len = size;\n"
1955 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
1956 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
1957 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
1958 "\\&\n"
1959 " /* Create a thread that will process the userfaultfd events. */\n"
1960 "\\&\n"
1961 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
1962 " if (s != 0) {\n"
1963 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
1964 " }\n"
1965 "\\&\n"
1966 " /* Main thread now touches memory in the mapping, touching\n"
1967 " locations 1024 bytes apart. This will trigger userfaultfd\n"
1968 " events for all pages in the region. */\n"
1969 "\\&\n"
1970 " i = 0xf; /* Ensure that faulting address is not on a page\n"
1971 " boundary, in order to test that we correctly\n"
1972 " handle that case in fault_handling_thread(). */\n"
1973 " while (i E<lt> size) {\n"
1974 " char c;\n"
1975 "\\&\n"
1976 " c = addr[i];\n"
1977 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
1978 " printf(\"%c\\[rs]n\", c);\n"
1979 " i += 1024;\n"
1980 " usleep(100000); /* Slow things down a little */\n"
1981 " }\n"
1982 "\\&\n"
1983 " exit(EXIT_SUCCESS);\n"
1984 "}\n"
1985
1986 #. SRC END
1987 #. type: SH
1988 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1989 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1990 #, no-wrap
1991 msgid "SEE ALSO"
1992 msgstr "انظر أيضًا"
1993
1994 #. type: Plain text
1995 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1996 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1997 msgid ""
1998 "B<fcntl>(2), B<ioctl>(2), B<ioctl_userfaultfd>(2), B<madvise>(2), B<mmap>(2)"
1999 msgstr ""
2000 "B<fcntl>(2), B<ioctl>(2), B<ioctl_userfaultfd>(2), B<madvise>(2), B<mmap>(2)"
2001
2002 #. type: Plain text
2003 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2004 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2005 msgid ""
2006 "I<Documentation/admin-guide/mm/userfaultfd.rst> in the Linux kernel source "
2007 "tree"
2008 msgstr ""
2009 "الملف I<Documentation/admin-guide/mm/userfaultfd.rst> في شجرة مصدر نواة لينكس"
2010
2011 #. type: TH
2012 #: debian-trixie
2013 #, no-wrap
2014 msgid "2024-06-15"
2015 msgstr "15 يونيو 2024"
2016
2017 #. type: TH
2018 #: debian-trixie
2019 #, no-wrap
2020 msgid "Linux man-pages 6.9.1"
2021 msgstr "صفحات دليل لينكس 6.9.1"
2022
2023 #. type: Plain text
2024 #: debian-trixie
2025 msgid "Standard C library (I<libc>, I<-lc>)"
2026 msgstr "مكتبة سي المعيارية (I<libc>، I<-lc>)"
2027
2028 #. type: Plain text
2029 #: debian-trixie
2030 #, no-wrap
2031 msgid ""
2032 "struct uffd_msg {\n"
2033 " __u8 event; /* Type of event */\n"
2034 " ...\n"
2035 " union {\n"
2036 " struct {\n"
2037 " __u64 flags; /* Flags describing fault */\n"
2038 " __u64 address; /* Faulting address */\n"
2039 " union {\n"
2040 " __u32 ptid; /* Thread ID of the fault */\n"
2041 " } feat;\n"
2042 " } pagefault;\n"
2043 "\\&\n"
2044 " struct { /* Since Linux 4.11 */\n"
2045 " __u32 ufd; /* Userfault file descriptor\n"
2046 " of the child process */\n"
2047 " } fork;\n"
2048 "\\&\n"
2049 " struct { /* Since Linux 4.11 */\n"
2050 " __u64 from; /* Old address of remapped area */\n"
2051 " __u64 to; /* New address of remapped area */\n"
2052 " __u64 len; /* Original mapping length */\n"
2053 " } remap;\n"
2054 "\\&\n"
2055 " struct { /* Since Linux 4.11 */\n"
2056 " __u64 start; /* Start address of removed area */\n"
2057 " __u64 end; /* End address of removed area */\n"
2058 " } remove;\n"
2059 " ...\n"
2060 " } arg;\n"
2061 "\\&\n"
2062 " /* Padding fields omitted */\n"
2063 "} __packed;\n"
2064 msgstr ""
2065 "struct uffd_msg {\n"
2066 " __u8 event; /* Type of event */\n"
2067 " ...\n"
2068 " union {\n"
2069 " struct {\n"
2070 " __u64 flags; /* Flags describing fault */\n"
2071 " __u64 address; /* Faulting address */\n"
2072 " union {\n"
2073 " __u32 ptid; /* Thread ID of the fault */\n"
2074 " } feat;\n"
2075 " } pagefault;\n"
2076 "\\&\n"
2077 " struct { /* Since Linux 4.11 */\n"
2078 " __u32 ufd; /* Userfault file descriptor\n"
2079 " of the child process */\n"
2080 " } fork;\n"
2081 "\\&\n"
2082 " struct { /* Since Linux 4.11 */\n"
2083 " __u64 from; /* Old address of remapped area */\n"
2084 " __u64 to; /* New address of remapped area */\n"
2085 " __u64 len; /* Original mapping length */\n"
2086 " } remap;\n"
2087 "\\&\n"
2088 " struct { /* Since Linux 4.11 */\n"
2089 " __u64 start; /* Start address of removed area */\n"
2090 " __u64 end; /* End address of removed area */\n"
2091 " } remove;\n"
2092 " ...\n"
2093 " } arg;\n"
2094 "\\&\n"
2095 " /* Padding fields omitted */\n"
2096 "} __packed;\n"
2097
2098 #. type: Plain text
2099 #: debian-trixie
2100 msgid ""
2101 "The original length of the memory range that was remapped using B<mremap>(2)."
2102 msgstr "الطول الأصلي لنطاق الذاكرة الذي أُعيد تعيينه باستخدام B<mremap>(2)."
2103
2104 #. type: Plain text
2105 #: debian-trixie fedora-44 fedora-rawhide
2106 #, no-wrap
2107 msgid ""
2108 "$ B<./userfaultfd_demo 3>\n"
2109 "Address returned by mmap() = 0x7fd30106c000\n"
2110 "\\&\n"
2111 "fault_handler_thread():\n"
2112 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
2113 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n"
2114 " (uffdio_copy.copy returned 4096)\n"
2115 "Read address 0x7fd30106c00f in main(): A\n"
2116 "Read address 0x7fd30106c40f in main(): A\n"
2117 "Read address 0x7fd30106c80f in main(): A\n"
2118 "Read address 0x7fd30106cc0f in main(): A\n"
2119 "\\&\n"
2120 "fault_handler_thread():\n"
2121 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
2122 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n"
2123 " (uffdio_copy.copy returned 4096)\n"
2124 "Read address 0x7fd30106d00f in main(): B\n"
2125 "Read address 0x7fd30106d40f in main(): B\n"
2126 "Read address 0x7fd30106d80f in main(): B\n"
2127 "Read address 0x7fd30106dc0f in main(): B\n"
2128 "\\&\n"
2129 "fault_handler_thread():\n"
2130 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
2131 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n"
2132 " (uffdio_copy.copy returned 4096)\n"
2133 "Read address 0x7fd30106e00f in main(): C\n"
2134 "Read address 0x7fd30106e40f in main(): C\n"
2135 "Read address 0x7fd30106e80f in main(): C\n"
2136 "Read address 0x7fd30106ec0f in main(): C\n"
2137 msgstr ""
2138 "$ B<./userfaultfd_demo 3>\n"
2139 "Address returned by mmap() = 0x7fd30106c000\n"
2140 "\\&\n"
2141 "fault_handler_thread():\n"
2142 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
2143 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n"
2144 " (uffdio_copy.copy returned 4096)\n"
2145 "Read address 0x7fd30106c00f in main(): A\n"
2146 "Read address 0x7fd30106c40f in main(): A\n"
2147 "Read address 0x7fd30106c80f in main(): A\n"
2148 "Read address 0x7fd30106cc0f in main(): A\n"
2149 "\\&\n"
2150 "fault_handler_thread():\n"
2151 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
2152 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n"
2153 " (uffdio_copy.copy returned 4096)\n"
2154 "Read address 0x7fd30106d00f in main(): B\n"
2155 "Read address 0x7fd30106d40f in main(): B\n"
2156 "Read address 0x7fd30106d80f in main(): B\n"
2157 "Read address 0x7fd30106dc0f in main(): B\n"
2158 "\\&\n"
2159 "fault_handler_thread():\n"
2160 " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n"
2161 " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n"
2162 " (uffdio_copy.copy returned 4096)\n"
2163 "Read address 0x7fd30106e00f in main(): C\n"
2164 "Read address 0x7fd30106e40f in main(): C\n"
2165 "Read address 0x7fd30106e80f in main(): C\n"
2166 "Read address 0x7fd30106ec0f in main(): C\n"
2167
2168 #. type: Plain text
2169 #: debian-trixie
2170 #, no-wrap
2171 msgid ""
2172 "/* userfaultfd_demo.c\n"
2173 "\\&\n"
2174 " Licensed under the GNU General Public License version 2 or later.\n"
2175 "*/\n"
2176 "#define _GNU_SOURCE\n"
2177 "#include E<lt>err.hE<gt>\n"
2178 "#include E<lt>errno.hE<gt>\n"
2179 "#include E<lt>fcntl.hE<gt>\n"
2180 "#include E<lt>inttypes.hE<gt>\n"
2181 "#include E<lt>linux/userfaultfd.hE<gt>\n"
2182 "#include E<lt>poll.hE<gt>\n"
2183 "#include E<lt>pthread.hE<gt>\n"
2184 "#include E<lt>stdio.hE<gt>\n"
2185 "#include E<lt>stdlib.hE<gt>\n"
2186 "#include E<lt>string.hE<gt>\n"
2187 "#include E<lt>sys/ioctl.hE<gt>\n"
2188 "#include E<lt>sys/mman.hE<gt>\n"
2189 "#include E<lt>sys/syscall.hE<gt>\n"
2190 "#include E<lt>unistd.hE<gt>\n"
2191 "\\&\n"
2192 "static int page_size;\n"
2193 "\\&\n"
2194 "static void *\n"
2195 "fault_handler_thread(void *arg)\n"
2196 "{\n"
2197 " int nready;\n"
2198 " long uffd; /* userfaultfd file descriptor */\n"
2199 " ssize_t nread;\n"
2200 " struct pollfd pollfd;\n"
2201 " struct uffdio_copy uffdio_copy;\n"
2202 "\\&\n"
2203 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
2204 " static char *page = NULL;\n"
2205 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
2206 "\\&\n"
2207 " uffd = (long) arg;\n"
2208 "\\&\n"
2209 " /* Create a page that will be copied into the faulting region. */\n"
2210 "\\&\n"
2211 " if (page == NULL) {\n"
2212 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
2213 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2214 " if (page == MAP_FAILED)\n"
2215 " err(EXIT_FAILURE, \"mmap\");\n"
2216 " }\n"
2217 "\\&\n"
2218 " /* Loop, handling incoming events on the userfaultfd\n"
2219 " file descriptor. */\n"
2220 "\\&\n"
2221 " for (;;) {\n"
2222 "\\&\n"
2223 " /* See what poll() tells us about the userfaultfd. */\n"
2224 "\\&\n"
2225 " pollfd.fd = uffd;\n"
2226 " pollfd.events = POLLIN;\n"
2227 " nready = poll(&pollfd, 1, -1);\n"
2228 " if (nready == -1)\n"
2229 " err(EXIT_FAILURE, \"poll\");\n"
2230 "\\&\n"
2231 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
2232 " printf(\" poll() returns: nready = %d; \"\n"
2233 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
2234 " (pollfd.revents & POLLIN) != 0,\n"
2235 " (pollfd.revents & POLLERR) != 0);\n"
2236 "\\&\n"
2237 " /* Read an event from the userfaultfd. */\n"
2238 "\\&\n"
2239 " nread = read(uffd, &msg, sizeof(msg));\n"
2240 " if (nread == 0) {\n"
2241 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
2242 " exit(EXIT_FAILURE);\n"
2243 " }\n"
2244 "\\&\n"
2245 " if (nread == -1)\n"
2246 " err(EXIT_FAILURE, \"read\");\n"
2247 "\\&\n"
2248 " /* We expect only one kind of event; verify that assumption. */\n"
2249 "\\&\n"
2250 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
2251 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
2252 " exit(EXIT_FAILURE);\n"
2253 " }\n"
2254 "\\&\n"
2255 " /* Display info about the page-fault event. */\n"
2256 "\\&\n"
2257 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
2258 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
2259 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
2260 "\\&\n"
2261 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
2262 " region. Vary the contents that are copied in, so that it\n"
2263 " is more obvious that each fault is handled separately. */\n"
2264 "\\&\n"
2265 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
2266 " fault_cnt++;\n"
2267 "\\&\n"
2268 " uffdio_copy.src = (unsigned long) page;\n"
2269 "\\&\n"
2270 " /* We need to handle page faults in units of pages(!).\n"
2271 " So, round faulting address down to page boundary. */\n"
2272 "\\&\n"
2273 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
2274 " \\[ti](page_size - 1);\n"
2275 " uffdio_copy.len = page_size;\n"
2276 " uffdio_copy.mode = 0;\n"
2277 " uffdio_copy.copy = 0;\n"
2278 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
2279 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
2280 "\\&\n"
2281 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
2282 " uffdio_copy.copy);\n"
2283 " }\n"
2284 "}\n"
2285 "\\&\n"
2286 "int\n"
2287 "main(int argc, char *argv[])\n"
2288 "{\n"
2289 " int s;\n"
2290 " char c;\n"
2291 " char *addr; /* Start of region handled by userfaultfd */\n"
2292 " long uffd; /* userfaultfd file descriptor */\n"
2293 " size_t len, l; /* Length of region handled by userfaultfd */\n"
2294 " pthread_t thr; /* ID of thread that handles page faults */\n"
2295 " struct uffdio_api uffdio_api;\n"
2296 " struct uffdio_register uffdio_register;\n"
2297 "\\&\n"
2298 " if (argc != 2) {\n"
2299 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
2300 " exit(EXIT_FAILURE);\n"
2301 " }\n"
2302 "\\&\n"
2303 " page_size = sysconf(_SC_PAGE_SIZE);\n"
2304 " len = strtoull(argv[1], NULL, 0) * page_size;\n"
2305 "\\&\n"
2306 " /* Create and enable userfaultfd object. */\n"
2307 "\\&\n"
2308 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
2309 " if (uffd == -1)\n"
2310 " err(EXIT_FAILURE, \"userfaultfd\");\n"
2311 "\\&\n"
2312 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
2313 " example doesn't require any specific features.\n"
2314 "\\&\n"
2315 " Programs that *do* should call UFFDIO_API twice: once with\n"
2316 " `features = 0` to detect features supported by this kernel, and\n"
2317 " again with the subset of features the program actually wants to\n"
2318 " enable. */\n"
2319 " uffdio_api.api = UFFD_API;\n"
2320 " uffdio_api.features = 0;\n"
2321 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
2322 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
2323 "\\&\n"
2324 " /* Create a private anonymous mapping. The memory will be\n"
2325 " demand-zero paged--that is, not yet allocated. When we\n"
2326 " actually touch the memory, it will be allocated via\n"
2327 " the userfaultfd. */\n"
2328 "\\&\n"
2329 " addr = mmap(NULL, len, PROT_READ | PROT_WRITE,\n"
2330 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2331 " if (addr == MAP_FAILED)\n"
2332 " err(EXIT_FAILURE, \"mmap\");\n"
2333 "\\&\n"
2334 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
2335 "\\&\n"
2336 " /* Register the memory range of the mapping we just created for\n"
2337 " handling by the userfaultfd object. In mode, we request to track\n"
2338 " missing pages (i.e., pages that have not yet been faulted in). */\n"
2339 "\\&\n"
2340 " uffdio_register.range.start = (unsigned long) addr;\n"
2341 " uffdio_register.range.len = len;\n"
2342 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
2343 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
2344 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
2345 "\\&\n"
2346 " /* Create a thread that will process the userfaultfd events. */\n"
2347 "\\&\n"
2348 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
2349 " if (s != 0) {\n"
2350 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
2351 " }\n"
2352 "\\&\n"
2353 " /* Main thread now touches memory in the mapping, touching\n"
2354 " locations 1024 bytes apart. This will trigger userfaultfd\n"
2355 " events for all pages in the region. */\n"
2356 "\\&\n"
2357 " l = 0xf; /* Ensure that faulting address is not on a page\n"
2358 " boundary, in order to test that we correctly\n"
2359 " handle that case in fault_handling_thread(). */\n"
2360 " while (l E<lt> len) {\n"
2361 " c = addr[l];\n"
2362 " printf(\"Read address %p in %s(): \", addr + l, __func__);\n"
2363 " printf(\"%c\\[rs]n\", c);\n"
2364 " l += 1024;\n"
2365 " usleep(100000); /* Slow things down a little */\n"
2366 " }\n"
2367 "\\&\n"
2368 " exit(EXIT_SUCCESS);\n"
2369 "}\n"
2370 msgstr ""
2371 "/* userfaultfd_demo.c\n"
2372 "\\&\n"
2373 " Licensed under the GNU General Public License version 2 or later.\n"
2374 "*/\n"
2375 "#define _GNU_SOURCE\n"
2376 "#include E<lt>err.hE<gt>\n"
2377 "#include E<lt>errno.hE<gt>\n"
2378 "#include E<lt>fcntl.hE<gt>\n"
2379 "#include E<lt>inttypes.hE<gt>\n"
2380 "#include E<lt>linux/userfaultfd.hE<gt>\n"
2381 "#include E<lt>poll.hE<gt>\n"
2382 "#include E<lt>pthread.hE<gt>\n"
2383 "#include E<lt>stdio.hE<gt>\n"
2384 "#include E<lt>stdlib.hE<gt>\n"
2385 "#include E<lt>string.hE<gt>\n"
2386 "#include E<lt>sys/ioctl.hE<gt>\n"
2387 "#include E<lt>sys/mman.hE<gt>\n"
2388 "#include E<lt>sys/syscall.hE<gt>\n"
2389 "#include E<lt>unistd.hE<gt>\n"
2390 "\\&\n"
2391 "static int page_size;\n"
2392 "\\&\n"
2393 "static void *\n"
2394 "fault_handler_thread(void *arg)\n"
2395 "{\n"
2396 " int nready;\n"
2397 " long uffd; /* userfaultfd file descriptor */\n"
2398 " ssize_t nread;\n"
2399 " struct pollfd pollfd;\n"
2400 " struct uffdio_copy uffdio_copy;\n"
2401 "\\&\n"
2402 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
2403 " static char *page = NULL;\n"
2404 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
2405 "\\&\n"
2406 " uffd = (long) arg;\n"
2407 "\\&\n"
2408 " /* Create a page that will be copied into the faulting region. */\n"
2409 "\\&\n"
2410 " if (page == NULL) {\n"
2411 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
2412 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2413 " if (page == MAP_FAILED)\n"
2414 " err(EXIT_FAILURE, \"mmap\");\n"
2415 " }\n"
2416 "\\&\n"
2417 " /* Loop, handling incoming events on the userfaultfd\n"
2418 " file descriptor. */\n"
2419 "\\&\n"
2420 " for (;;) {\n"
2421 "\\&\n"
2422 " /* See what poll() tells us about the userfaultfd. */\n"
2423 "\\&\n"
2424 " pollfd.fd = uffd;\n"
2425 " pollfd.events = POLLIN;\n"
2426 " nready = poll(&pollfd, 1, -1);\n"
2427 " if (nready == -1)\n"
2428 " err(EXIT_FAILURE, \"poll\");\n"
2429 "\\&\n"
2430 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
2431 " printf(\" poll() returns: nready = %d; \"\n"
2432 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
2433 " (pollfd.revents & POLLIN) != 0,\n"
2434 " (pollfd.revents & POLLERR) != 0);\n"
2435 "\\&\n"
2436 " /* Read an event from the userfaultfd. */\n"
2437 "\\&\n"
2438 " nread = read(uffd, &msg, sizeof(msg));\n"
2439 " if (nread == 0) {\n"
2440 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
2441 " exit(EXIT_FAILURE);\n"
2442 " }\n"
2443 "\\&\n"
2444 " if (nread == -1)\n"
2445 " err(EXIT_FAILURE, \"read\");\n"
2446 "\\&\n"
2447 " /* We expect only one kind of event; verify that assumption. */\n"
2448 "\\&\n"
2449 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
2450 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
2451 " exit(EXIT_FAILURE);\n"
2452 " }\n"
2453 "\\&\n"
2454 " /* Display info about the page-fault event. */\n"
2455 "\\&\n"
2456 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
2457 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
2458 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
2459 "\\&\n"
2460 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
2461 " region. Vary the contents that are copied in, so that it\n"
2462 " is more obvious that each fault is handled separately. */\n"
2463 "\\&\n"
2464 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
2465 " fault_cnt++;\n"
2466 "\\&\n"
2467 " uffdio_copy.src = (unsigned long) page;\n"
2468 "\\&\n"
2469 " /* We need to handle page faults in units of pages(!).\n"
2470 " So, round faulting address down to page boundary. */\n"
2471 "\\&\n"
2472 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
2473 " \\[ti](page_size - 1);\n"
2474 " uffdio_copy.len = page_size;\n"
2475 " uffdio_copy.mode = 0;\n"
2476 " uffdio_copy.copy = 0;\n"
2477 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
2478 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
2479 "\\&\n"
2480 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
2481 " uffdio_copy.copy);\n"
2482 " }\n"
2483 "}\n"
2484 "\\&\n"
2485 "int\n"
2486 "main(int argc, char *argv[])\n"
2487 "{\n"
2488 " int s;\n"
2489 " char c;\n"
2490 " char *addr; /* Start of region handled by userfaultfd */\n"
2491 " long uffd; /* userfaultfd file descriptor */\n"
2492 " size_t len, l; /* Length of region handled by userfaultfd */\n"
2493 " pthread_t thr; /* ID of thread that handles page faults */\n"
2494 " struct uffdio_api uffdio_api;\n"
2495 " struct uffdio_register uffdio_register;\n"
2496 "\\&\n"
2497 " if (argc != 2) {\n"
2498 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
2499 " exit(EXIT_FAILURE);\n"
2500 " }\n"
2501 "\\&\n"
2502 " page_size = sysconf(_SC_PAGE_SIZE);\n"
2503 " len = strtoull(argv[1], NULL, 0) * page_size;\n"
2504 "\\&\n"
2505 " /* Create and enable userfaultfd object. */\n"
2506 "\\&\n"
2507 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
2508 " if (uffd == -1)\n"
2509 " err(EXIT_FAILURE, \"userfaultfd\");\n"
2510 "\\&\n"
2511 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
2512 " example doesn't require any specific features.\n"
2513 "\\&\n"
2514 " Programs that *do* should call UFFDIO_API twice: once with\n"
2515 " `features = 0` to detect features supported by this kernel, and\n"
2516 " again with the subset of features the program actually wants to\n"
2517 " enable. */\n"
2518 " uffdio_api.api = UFFD_API;\n"
2519 " uffdio_api.features = 0;\n"
2520 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
2521 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
2522 "\\&\n"
2523 " /* Create a private anonymous mapping. The memory will be\n"
2524 " demand-zero paged--that is, not yet allocated. When we\n"
2525 " actually touch the memory, it will be allocated via\n"
2526 " the userfaultfd. */\n"
2527 "\\&\n"
2528 " addr = mmap(NULL, len, PROT_READ | PROT_WRITE,\n"
2529 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2530 " if (addr == MAP_FAILED)\n"
2531 " err(EXIT_FAILURE, \"mmap\");\n"
2532 "\\&\n"
2533 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
2534 "\\&\n"
2535 " /* Register the memory range of the mapping we just created for\n"
2536 " handling by the userfaultfd object. In mode, we request to track\n"
2537 " missing pages (i.e., pages that have not yet been faulted in). */\n"
2538 "\\&\n"
2539 " uffdio_register.range.start = (unsigned long) addr;\n"
2540 " uffdio_register.range.len = len;\n"
2541 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
2542 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
2543 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
2544 "\\&\n"
2545 " /* Create a thread that will process the userfaultfd events. */\n"
2546 "\\&\n"
2547 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
2548 " if (s != 0) {\n"
2549 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
2550 " }\n"
2551 "\\&\n"
2552 " /* Main thread now touches memory in the mapping, touching\n"
2553 " locations 1024 bytes apart. This will trigger userfaultfd\n"
2554 " events for all pages in the region. */\n"
2555 "\\&\n"
2556 " l = 0xf; /* Ensure that faulting address is not on a page\n"
2557 " boundary, in order to test that we correctly\n"
2558 " handle that case in fault_handling_thread(). */\n"
2559 " while (l E<lt> len) {\n"
2560 " c = addr[l];\n"
2561 " printf(\"Read address %p in %s(): \", addr + l, __func__);\n"
2562 " printf(\"%c\\[rs]n\", c);\n"
2563 " l += 1024;\n"
2564 " usleep(100000); /* Slow things down a little */\n"
2565 " }\n"
2566 "\\&\n"
2567 " exit(EXIT_SUCCESS);\n"
2568 "}\n"
2569
2570 #. type: TH
2571 #: fedora-44 fedora-rawhide
2572 #, no-wrap
2573 msgid "2024-11-17"
2574 msgstr "17 نوفمبر 2024"
2575
2576 #. type: TH
2577 #: fedora-44 fedora-rawhide
2578 #, no-wrap
2579 msgid "Linux man-pages 6.13"
2580 msgstr "صفحات دليل لينكس 6.13"
2581
2582 #. type: Plain text
2583 #: fedora-44 fedora-rawhide
2584 #, no-wrap
2585 msgid ""
2586 "/* userfaultfd_demo.c\n"
2587 "\\&\n"
2588 " Licensed under the GNU General Public License version 2 or later.\n"
2589 "*/\n"
2590 "#define _GNU_SOURCE\n"
2591 "#include E<lt>err.hE<gt>\n"
2592 "#include E<lt>errno.hE<gt>\n"
2593 "#include E<lt>fcntl.hE<gt>\n"
2594 "#include E<lt>inttypes.hE<gt>\n"
2595 "#include E<lt>linux/userfaultfd.hE<gt>\n"
2596 "#include E<lt>poll.hE<gt>\n"
2597 "#include E<lt>pthread.hE<gt>\n"
2598 "#include E<lt>stdio.hE<gt>\n"
2599 "#include E<lt>stdlib.hE<gt>\n"
2600 "#include E<lt>string.hE<gt>\n"
2601 "#include E<lt>sys/ioctl.hE<gt>\n"
2602 "#include E<lt>sys/mman.hE<gt>\n"
2603 "#include E<lt>sys/syscall.hE<gt>\n"
2604 "#include E<lt>unistd.hE<gt>\n"
2605 "\\&\n"
2606 "static int page_size;\n"
2607 "\\&\n"
2608 "static void *\n"
2609 "fault_handler_thread(void *arg)\n"
2610 "{\n"
2611 " int nready;\n"
2612 " long uffd; /* userfaultfd file descriptor */\n"
2613 " ssize_t nread;\n"
2614 " struct pollfd pollfd;\n"
2615 " struct uffdio_copy uffdio_copy;\n"
2616 "\\&\n"
2617 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
2618 " static char *page = NULL;\n"
2619 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
2620 "\\&\n"
2621 " uffd = (long) arg;\n"
2622 "\\&\n"
2623 " /* Create a page that will be copied into the faulting region. */\n"
2624 "\\&\n"
2625 " if (page == NULL) {\n"
2626 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
2627 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2628 " if (page == MAP_FAILED)\n"
2629 " err(EXIT_FAILURE, \"mmap\");\n"
2630 " }\n"
2631 "\\&\n"
2632 " /* Loop, handling incoming events on the userfaultfd\n"
2633 " file descriptor. */\n"
2634 "\\&\n"
2635 " for (;;) {\n"
2636 "\\&\n"
2637 " /* See what poll() tells us about the userfaultfd. */\n"
2638 "\\&\n"
2639 " pollfd.fd = uffd;\n"
2640 " pollfd.events = POLLIN;\n"
2641 " nready = poll(&pollfd, 1, -1);\n"
2642 " if (nready == -1)\n"
2643 " err(EXIT_FAILURE, \"poll\");\n"
2644 "\\&\n"
2645 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
2646 " printf(\" poll() returns: nready = %d; \"\n"
2647 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
2648 " (pollfd.revents & POLLIN) != 0,\n"
2649 " (pollfd.revents & POLLERR) != 0);\n"
2650 "\\&\n"
2651 " /* Read an event from the userfaultfd. */\n"
2652 "\\&\n"
2653 " nread = read(uffd, &msg, sizeof(msg));\n"
2654 " if (nread == 0) {\n"
2655 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
2656 " exit(EXIT_FAILURE);\n"
2657 " }\n"
2658 "\\&\n"
2659 " if (nread == -1)\n"
2660 " err(EXIT_FAILURE, \"read\");\n"
2661 "\\&\n"
2662 " /* We expect only one kind of event; verify that assumption. */\n"
2663 "\\&\n"
2664 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
2665 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
2666 " exit(EXIT_FAILURE);\n"
2667 " }\n"
2668 "\\&\n"
2669 " /* Display info about the page-fault event. */\n"
2670 "\\&\n"
2671 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
2672 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
2673 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
2674 "\\&\n"
2675 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
2676 " region. Vary the contents that are copied in, so that it\n"
2677 " is more obvious that each fault is handled separately. */\n"
2678 "\\&\n"
2679 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
2680 " fault_cnt++;\n"
2681 "\\&\n"
2682 " uffdio_copy.src = (unsigned long) page;\n"
2683 "\\&\n"
2684 " /* We need to handle page faults in units of pages(!).\n"
2685 " So, round faulting address down to page boundary. */\n"
2686 "\\&\n"
2687 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
2688 " \\[ti](page_size - 1);\n"
2689 " uffdio_copy.len = page_size;\n"
2690 " uffdio_copy.mode = 0;\n"
2691 " uffdio_copy.copy = 0;\n"
2692 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
2693 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
2694 "\\&\n"
2695 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
2696 " uffdio_copy.copy);\n"
2697 " }\n"
2698 "}\n"
2699 "\\&\n"
2700 "int\n"
2701 "main(int argc, char *argv[])\n"
2702 "{\n"
2703 " int s;\n"
2704 " char c;\n"
2705 " char *addr; /* Start of region handled by userfaultfd */\n"
2706 " long uffd; /* userfaultfd file descriptor */\n"
2707 " size_t size, i; /* Size of region handled by userfaultfd */\n"
2708 " pthread_t thr; /* ID of thread that handles page faults */\n"
2709 " struct uffdio_api uffdio_api;\n"
2710 " struct uffdio_register uffdio_register;\n"
2711 "\\&\n"
2712 " if (argc != 2) {\n"
2713 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
2714 " exit(EXIT_FAILURE);\n"
2715 " }\n"
2716 "\\&\n"
2717 " page_size = sysconf(_SC_PAGE_SIZE);\n"
2718 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
2719 "\\&\n"
2720 " /* Create and enable userfaultfd object. */\n"
2721 "\\&\n"
2722 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
2723 " if (uffd == -1)\n"
2724 " err(EXIT_FAILURE, \"userfaultfd\");\n"
2725 "\\&\n"
2726 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
2727 " example doesn't require any specific features.\n"
2728 "\\&\n"
2729 " Programs that *do* should call UFFDIO_API twice: once with\n"
2730 " `features = 0` to detect features supported by this kernel, and\n"
2731 " again with the subset of features the program actually wants to\n"
2732 " enable. */\n"
2733 " uffdio_api.api = UFFD_API;\n"
2734 " uffdio_api.features = 0;\n"
2735 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
2736 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
2737 "\\&\n"
2738 " /* Create a private anonymous mapping. The memory will be\n"
2739 " demand-zero paged--that is, not yet allocated. When we\n"
2740 " actually touch the memory, it will be allocated via\n"
2741 " the userfaultfd. */\n"
2742 "\\&\n"
2743 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
2744 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2745 " if (addr == MAP_FAILED)\n"
2746 " err(EXIT_FAILURE, \"mmap\");\n"
2747 "\\&\n"
2748 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
2749 "\\&\n"
2750 " /* Register the memory range of the mapping we just created for\n"
2751 " handling by the userfaultfd object. In mode, we request to track\n"
2752 " missing pages (i.e., pages that have not yet been faulted in). */\n"
2753 "\\&\n"
2754 " uffdio_register.range.start = (unsigned long) addr;\n"
2755 " uffdio_register.range.len = size;\n"
2756 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
2757 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
2758 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
2759 "\\&\n"
2760 " /* Create a thread that will process the userfaultfd events. */\n"
2761 "\\&\n"
2762 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
2763 " if (s != 0) {\n"
2764 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
2765 " }\n"
2766 "\\&\n"
2767 " /* Main thread now touches memory in the mapping, touching\n"
2768 " locations 1024 bytes apart. This will trigger userfaultfd\n"
2769 " events for all pages in the region. */\n"
2770 "\\&\n"
2771 " i = 0xf; /* Ensure that faulting address is not on a page\n"
2772 " boundary, in order to test that we correctly\n"
2773 " handle that case in fault_handling_thread(). */\n"
2774 " while (i E<lt> size) {\n"
2775 " c = addr[i];\n"
2776 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
2777 " printf(\"%c\\[rs]n\", c);\n"
2778 " i += 1024;\n"
2779 " usleep(100000); /* Slow things down a little */\n"
2780 " }\n"
2781 "\\&\n"
2782 " exit(EXIT_SUCCESS);\n"
2783 "}\n"
2784 msgstr ""
2785 "/* userfaultfd_demo.c\n"
2786 "\\&\n"
2787 " Licensed under the GNU General Public License version 2 or later.\n"
2788 "*/\n"
2789 "#define _GNU_SOURCE\n"
2790 "#include E<lt>err.hE<gt>\n"
2791 "#include E<lt>errno.hE<gt>\n"
2792 "#include E<lt>fcntl.hE<gt>\n"
2793 "#include E<lt>inttypes.hE<gt>\n"
2794 "#include E<lt>linux/userfaultfd.hE<gt>\n"
2795 "#include E<lt>poll.hE<gt>\n"
2796 "#include E<lt>pthread.hE<gt>\n"
2797 "#include E<lt>stdio.hE<gt>\n"
2798 "#include E<lt>stdlib.hE<gt>\n"
2799 "#include E<lt>string.hE<gt>\n"
2800 "#include E<lt>sys/ioctl.hE<gt>\n"
2801 "#include E<lt>sys/mman.hE<gt>\n"
2802 "#include E<lt>sys/syscall.hE<gt>\n"
2803 "#include E<lt>unistd.hE<gt>\n"
2804 "\\&\n"
2805 "static int page_size;\n"
2806 "\\&\n"
2807 "static void *\n"
2808 "fault_handler_thread(void *arg)\n"
2809 "{\n"
2810 " int nready;\n"
2811 " long uffd; /* userfaultfd file descriptor */\n"
2812 " ssize_t nread;\n"
2813 " struct pollfd pollfd;\n"
2814 " struct uffdio_copy uffdio_copy;\n"
2815 "\\&\n"
2816 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
2817 " static char *page = NULL;\n"
2818 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
2819 "\\&\n"
2820 " uffd = (long) arg;\n"
2821 "\\&\n"
2822 " /* Create a page that will be copied into the faulting region. */\n"
2823 "\\&\n"
2824 " if (page == NULL) {\n"
2825 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
2826 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2827 " if (page == MAP_FAILED)\n"
2828 " err(EXIT_FAILURE, \"mmap\");\n"
2829 " }\n"
2830 "\\&\n"
2831 " /* Loop, handling incoming events on the userfaultfd\n"
2832 " file descriptor. */\n"
2833 "\\&\n"
2834 " for (;;) {\n"
2835 "\\&\n"
2836 " /* See what poll() tells us about the userfaultfd. */\n"
2837 "\\&\n"
2838 " pollfd.fd = uffd;\n"
2839 " pollfd.events = POLLIN;\n"
2840 " nready = poll(&pollfd, 1, -1);\n"
2841 " if (nready == -1)\n"
2842 " err(EXIT_FAILURE, \"poll\");\n"
2843 "\\&\n"
2844 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
2845 " printf(\" poll() returns: nready = %d; \"\n"
2846 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
2847 " (pollfd.revents & POLLIN) != 0,\n"
2848 " (pollfd.revents & POLLERR) != 0);\n"
2849 "\\&\n"
2850 " /* Read an event from the userfaultfd. */\n"
2851 "\\&\n"
2852 " nread = read(uffd, &msg, sizeof(msg));\n"
2853 " if (nread == 0) {\n"
2854 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
2855 " exit(EXIT_FAILURE);\n"
2856 " }\n"
2857 "\\&\n"
2858 " if (nread == -1)\n"
2859 " err(EXIT_FAILURE, \"read\");\n"
2860 "\\&\n"
2861 " /* We expect only one kind of event; verify that assumption. */\n"
2862 "\\&\n"
2863 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
2864 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
2865 " exit(EXIT_FAILURE);\n"
2866 " }\n"
2867 "\\&\n"
2868 " /* Display info about the page-fault event. */\n"
2869 "\\&\n"
2870 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
2871 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
2872 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
2873 "\\&\n"
2874 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
2875 " region. Vary the contents that are copied in, so that it\n"
2876 " is more obvious that each fault is handled separately. */\n"
2877 "\\&\n"
2878 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
2879 " fault_cnt++;\n"
2880 "\\&\n"
2881 " uffdio_copy.src = (unsigned long) page;\n"
2882 "\\&\n"
2883 " /* We need to handle page faults in units of pages(!).\n"
2884 " So, round faulting address down to page boundary. */\n"
2885 "\\&\n"
2886 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
2887 " \\[ti](page_size - 1);\n"
2888 " uffdio_copy.len = page_size;\n"
2889 " uffdio_copy.mode = 0;\n"
2890 " uffdio_copy.copy = 0;\n"
2891 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
2892 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
2893 "\\&\n"
2894 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
2895 " uffdio_copy.copy);\n"
2896 " }\n"
2897 "}\n"
2898 "\\&\n"
2899 "int\n"
2900 "main(int argc, char *argv[])\n"
2901 "{\n"
2902 " int s;\n"
2903 " char c;\n"
2904 " char *addr; /* Start of region handled by userfaultfd */\n"
2905 " long uffd; /* userfaultfd file descriptor */\n"
2906 " size_t size, i; /* Size of region handled by userfaultfd */\n"
2907 " pthread_t thr; /* ID of thread that handles page faults */\n"
2908 " struct uffdio_api uffdio_api;\n"
2909 " struct uffdio_register uffdio_register;\n"
2910 "\\&\n"
2911 " if (argc != 2) {\n"
2912 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
2913 " exit(EXIT_FAILURE);\n"
2914 " }\n"
2915 "\\&\n"
2916 " page_size = sysconf(_SC_PAGE_SIZE);\n"
2917 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
2918 "\\&\n"
2919 " /* Create and enable userfaultfd object. */\n"
2920 "\\&\n"
2921 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
2922 " if (uffd == -1)\n"
2923 " err(EXIT_FAILURE, \"userfaultfd\");\n"
2924 "\\&\n"
2925 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
2926 " example doesn't require any specific features.\n"
2927 "\\&\n"
2928 " Programs that *do* should call UFFDIO_API twice: once with\n"
2929 " `features = 0` to detect features supported by this kernel, and\n"
2930 " again with the subset of features the program actually wants to\n"
2931 " enable. */\n"
2932 " uffdio_api.api = UFFD_API;\n"
2933 " uffdio_api.features = 0;\n"
2934 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
2935 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
2936 "\\&\n"
2937 " /* Create a private anonymous mapping. The memory will be\n"
2938 " demand-zero paged--that is, not yet allocated. When we\n"
2939 " actually touch the memory, it will be allocated via\n"
2940 " the userfaultfd. */\n"
2941 "\\&\n"
2942 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
2943 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
2944 " if (addr == MAP_FAILED)\n"
2945 " err(EXIT_FAILURE, \"mmap\");\n"
2946 "\\&\n"
2947 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
2948 "\\&\n"
2949 " /* Register the memory range of the mapping we just created for\n"
2950 " handling by the userfaultfd object. In mode, we request to track\n"
2951 " missing pages (i.e., pages that have not yet been faulted in). */\n"
2952 "\\&\n"
2953 " uffdio_register.range.start = (unsigned long) addr;\n"
2954 " uffdio_register.range.len = size;\n"
2955 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
2956 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
2957 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
2958 "\\&\n"
2959 " /* Create a thread that will process the userfaultfd events. */\n"
2960 "\\&\n"
2961 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
2962 " if (s != 0) {\n"
2963 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
2964 " }\n"
2965 "\\&\n"
2966 " /* Main thread now touches memory in the mapping, touching\n"
2967 " locations 1024 bytes apart. This will trigger userfaultfd\n"
2968 " events for all pages in the region. */\n"
2969 "\\&\n"
2970 " i = 0xf; /* Ensure that faulting address is not on a page\n"
2971 " boundary, in order to test that we correctly\n"
2972 " handle that case in fault_handling_thread(). */\n"
2973 " while (i E<lt> size) {\n"
2974 " c = addr[i];\n"
2975 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
2976 " printf(\"%c\\[rs]n\", c);\n"
2977 " i += 1024;\n"
2978 " usleep(100000); /* Slow things down a little */\n"
2979 " }\n"
2980 "\\&\n"
2981 " exit(EXIT_SUCCESS);\n"
2982 "}\n"
2983
2984 #. type: TH
2985 #: mageia-cauldron
2986 #, no-wrap
2987 msgid "2026-02-08"
2988 msgstr "8 فبراير 2026"
2989
2990 #. type: TH
2991 #: mageia-cauldron
2992 #, no-wrap
2993 msgid "Linux man-pages 6.17"
2994 msgstr "صفحات دليل لينكس 6.17"
2995
2996 #. type: Plain text
2997 #: mageia-cauldron
2998 #, no-wrap
2999 msgid ""
3000 "/* userfaultfd_demo.c\n"
3001 "\\&\n"
3002 " Licensed under the GNU General Public License version 2 or later.\n"
3003 "*/\n"
3004 "#define _GNU_SOURCE\n"
3005 "#include E<lt>err.hE<gt>\n"
3006 "#include E<lt>errno.hE<gt>\n"
3007 "#include E<lt>fcntl.hE<gt>\n"
3008 "#include E<lt>inttypes.hE<gt>\n"
3009 "#include E<lt>linux/userfaultfd.hE<gt>\n"
3010 "#include E<lt>poll.hE<gt>\n"
3011 "#include E<lt>pthread.hE<gt>\n"
3012 "#include E<lt>stdio.hE<gt>\n"
3013 "#include E<lt>stdlib.hE<gt>\n"
3014 "#include E<lt>string.hE<gt>\n"
3015 "#include E<lt>sys/ioctl.hE<gt>\n"
3016 "#include E<lt>sys/mman.hE<gt>\n"
3017 "#include E<lt>sys/syscall.hE<gt>\n"
3018 "#include E<lt>unistd.hE<gt>\n"
3019 "\\&\n"
3020 "static int page_size;\n"
3021 "\\&\n"
3022 "static void *\n"
3023 "fault_handler_thread(void *arg)\n"
3024 "{\n"
3025 " long uffd; /* userfaultfd file descriptor */\n"
3026 "\\&\n"
3027 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
3028 " static char *page = NULL;\n"
3029 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
3030 "\\&\n"
3031 " uffd = (long) arg;\n"
3032 "\\&\n"
3033 " /* Create a page that will be copied into the faulting region. */\n"
3034 "\\&\n"
3035 " if (page == NULL) {\n"
3036 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
3037 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
3038 " if (page == MAP_FAILED)\n"
3039 " err(EXIT_FAILURE, \"mmap\");\n"
3040 " }\n"
3041 "\\&\n"
3042 " /* Loop, handling incoming events on the userfaultfd\n"
3043 " file descriptor. */\n"
3044 "\\&\n"
3045 " for (;;) {\n"
3046 " int nready;\n"
3047 " ssize_t nread;\n"
3048 " struct pollfd pollfd;\n"
3049 " struct uffdio_copy uffdio_copy;\n"
3050 "\\&\n"
3051 " /* See what poll() tells us about the userfaultfd. */\n"
3052 "\\&\n"
3053 " pollfd.fd = uffd;\n"
3054 " pollfd.events = POLLIN;\n"
3055 " nready = poll(&pollfd, 1, -1);\n"
3056 " if (nready == -1)\n"
3057 " err(EXIT_FAILURE, \"poll\");\n"
3058 "\\&\n"
3059 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
3060 " printf(\" poll() returns: nready = %d; \"\n"
3061 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
3062 " (pollfd.revents & POLLIN) != 0,\n"
3063 " (pollfd.revents & POLLERR) != 0);\n"
3064 "\\&\n"
3065 " /* Read an event from the userfaultfd. */\n"
3066 "\\&\n"
3067 " nread = read(uffd, &msg, sizeof(msg));\n"
3068 " if (nread == 0) {\n"
3069 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
3070 " exit(EXIT_FAILURE);\n"
3071 " }\n"
3072 "\\&\n"
3073 " if (nread == -1)\n"
3074 " err(EXIT_FAILURE, \"read\");\n"
3075 "\\&\n"
3076 " /* We expect only one kind of event; verify that assumption. */\n"
3077 "\\&\n"
3078 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
3079 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
3080 " exit(EXIT_FAILURE);\n"
3081 " }\n"
3082 "\\&\n"
3083 " /* Display info about the page-fault event. */\n"
3084 "\\&\n"
3085 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
3086 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
3087 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
3088 "\\&\n"
3089 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
3090 " region. Vary the contents that are copied in, so that it\n"
3091 " is more obvious that each fault is handled separately. */\n"
3092 "\\&\n"
3093 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
3094 " fault_cnt++;\n"
3095 "\\&\n"
3096 " uffdio_copy.src = (unsigned long) page;\n"
3097 "\\&\n"
3098 " /* We need to handle page faults in units of pages(!).\n"
3099 " So, round faulting address down to page boundary. */\n"
3100 "\\&\n"
3101 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
3102 " \\[ti](page_size - 1);\n"
3103 " uffdio_copy.len = page_size;\n"
3104 " uffdio_copy.mode = 0;\n"
3105 " uffdio_copy.copy = 0;\n"
3106 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
3107 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
3108 "\\&\n"
3109 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
3110 " uffdio_copy.copy);\n"
3111 " }\n"
3112 "}\n"
3113 "\\&\n"
3114 "int\n"
3115 "main(int argc, char *argv[])\n"
3116 "{\n"
3117 " int s;\n"
3118 " char *addr; /* Start of region handled by userfaultfd */\n"
3119 " long uffd; /* userfaultfd file descriptor */\n"
3120 " size_t size, i; /* Size of region handled by userfaultfd */\n"
3121 " pthread_t thr; /* ID of thread that handles page faults */\n"
3122 " struct uffdio_api uffdio_api;\n"
3123 " struct uffdio_register uffdio_register;\n"
3124 "\\&\n"
3125 " if (argc != 2) {\n"
3126 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
3127 " exit(EXIT_FAILURE);\n"
3128 " }\n"
3129 "\\&\n"
3130 " page_size = sysconf(_SC_PAGE_SIZE);\n"
3131 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
3132 "\\&\n"
3133 " /* Create and enable userfaultfd object. */\n"
3134 "\\&\n"
3135 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
3136 " if (uffd == -1)\n"
3137 " err(EXIT_FAILURE, \"userfaultfd\");\n"
3138 "\\&\n"
3139 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
3140 " example doesn't require any specific features.\n"
3141 "\\&\n"
3142 " Programs that *do* should call UFFDIO_API twice: once with\n"
3143 " `features = 0` to detect features supported by this kernel, and\n"
3144 " again with the subset of features the program actually wants to\n"
3145 " enable. */\n"
3146 " uffdio_api.api = UFFD_API;\n"
3147 " uffdio_api.features = 0;\n"
3148 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
3149 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
3150 "\\&\n"
3151 " /* Create a private anonymous mapping. The memory will be\n"
3152 " demand-zero paged--that is, not yet allocated. When we\n"
3153 " actually touch the memory, it will be allocated via\n"
3154 " the userfaultfd. */\n"
3155 "\\&\n"
3156 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
3157 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
3158 " if (addr == MAP_FAILED)\n"
3159 " err(EXIT_FAILURE, \"mmap\");\n"
3160 "\\&\n"
3161 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
3162 "\\&\n"
3163 " /* Register the memory range of the mapping we just created for\n"
3164 " handling by the userfaultfd object. In mode, we request to track\n"
3165 " missing pages (i.e., pages that have not yet been faulted in). */\n"
3166 "\\&\n"
3167 " uffdio_register.range.start = (unsigned long) addr;\n"
3168 " uffdio_register.range.len = size;\n"
3169 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
3170 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
3171 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
3172 "\\&\n"
3173 " /* Create a thread that will process the userfaultfd events. */\n"
3174 "\\&\n"
3175 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
3176 " if (s != 0) {\n"
3177 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
3178 " }\n"
3179 "\\&\n"
3180 " /* Main thread now touches memory in the mapping, touching\n"
3181 " locations 1024 bytes apart. This will trigger userfaultfd\n"
3182 " events for all pages in the region. */\n"
3183 "\\&\n"
3184 " i = 0xf; /* Ensure that faulting address is not on a page\n"
3185 " boundary, in order to test that we correctly\n"
3186 " handle that case in fault_handling_thread(). */\n"
3187 " while (i E<lt> size) {\n"
3188 " char c;\n"
3189 "\\&\n"
3190 " c = addr[i];\n"
3191 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
3192 " printf(\"%c\\[rs]n\", c);\n"
3193 " i += 1024;\n"
3194 " usleep(100000); /* Slow things down a little */\n"
3195 " }\n"
3196 "\\&\n"
3197 " exit(EXIT_SUCCESS);\n"
3198 "}\n"
3199 msgstr ""
3200 "/* userfaultfd_demo.c\n"
3201 "\\&\n"
3202 " Licensed under the GNU General Public License version 2 or later.\n"
3203 "*/\n"
3204 "#define _GNU_SOURCE\n"
3205 "#include E<lt>err.hE<gt>\n"
3206 "#include E<lt>errno.hE<gt>\n"
3207 "#include E<lt>fcntl.hE<gt>\n"
3208 "#include E<lt>inttypes.hE<gt>\n"
3209 "#include E<lt>linux/userfaultfd.hE<gt>\n"
3210 "#include E<lt>poll.hE<gt>\n"
3211 "#include E<lt>pthread.hE<gt>\n"
3212 "#include E<lt>stdio.hE<gt>\n"
3213 "#include E<lt>stdlib.hE<gt>\n"
3214 "#include E<lt>string.hE<gt>\n"
3215 "#include E<lt>sys/ioctl.hE<gt>\n"
3216 "#include E<lt>sys/mman.hE<gt>\n"
3217 "#include E<lt>sys/syscall.hE<gt>\n"
3218 "#include E<lt>unistd.hE<gt>\n"
3219 "\\&\n"
3220 "static int page_size;\n"
3221 "\\&\n"
3222 "static void *\n"
3223 "fault_handler_thread(void *arg)\n"
3224 "{\n"
3225 " long uffd; /* userfaultfd file descriptor */\n"
3226 "\\&\n"
3227 " static int fault_cnt = 0; /* Number of faults so far handled */\n"
3228 " static char *page = NULL;\n"
3229 " static struct uffd_msg msg; /* Data read from userfaultfd */\n"
3230 "\\&\n"
3231 " uffd = (long) arg;\n"
3232 "\\&\n"
3233 " /* Create a page that will be copied into the faulting region. */\n"
3234 "\\&\n"
3235 " if (page == NULL) {\n"
3236 " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n"
3237 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
3238 " if (page == MAP_FAILED)\n"
3239 " err(EXIT_FAILURE, \"mmap\");\n"
3240 " }\n"
3241 "\\&\n"
3242 " /* Loop, handling incoming events on the userfaultfd\n"
3243 " file descriptor. */\n"
3244 "\\&\n"
3245 " for (;;) {\n"
3246 " int nready;\n"
3247 " ssize_t nread;\n"
3248 " struct pollfd pollfd;\n"
3249 " struct uffdio_copy uffdio_copy;\n"
3250 "\\&\n"
3251 " /* See what poll() tells us about the userfaultfd. */\n"
3252 "\\&\n"
3253 " pollfd.fd = uffd;\n"
3254 " pollfd.events = POLLIN;\n"
3255 " nready = poll(&pollfd, 1, -1);\n"
3256 " if (nready == -1)\n"
3257 " err(EXIT_FAILURE, \"poll\");\n"
3258 "\\&\n"
3259 " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n"
3260 " printf(\" poll() returns: nready = %d; \"\n"
3261 " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n"
3262 " (pollfd.revents & POLLIN) != 0,\n"
3263 " (pollfd.revents & POLLERR) != 0);\n"
3264 "\\&\n"
3265 " /* Read an event from the userfaultfd. */\n"
3266 "\\&\n"
3267 " nread = read(uffd, &msg, sizeof(msg));\n"
3268 " if (nread == 0) {\n"
3269 " printf(\"EOF on userfaultfd!\\[rs]n\");\n"
3270 " exit(EXIT_FAILURE);\n"
3271 " }\n"
3272 "\\&\n"
3273 " if (nread == -1)\n"
3274 " err(EXIT_FAILURE, \"read\");\n"
3275 "\\&\n"
3276 " /* We expect only one kind of event; verify that assumption. */\n"
3277 "\\&\n"
3278 " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n"
3279 " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n"
3280 " exit(EXIT_FAILURE);\n"
3281 " }\n"
3282 "\\&\n"
3283 " /* Display info about the page-fault event. */\n"
3284 "\\&\n"
3285 " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n"
3286 " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n"
3287 " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n"
3288 "\\&\n"
3289 " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n"
3290 " region. Vary the contents that are copied in, so that it\n"
3291 " is more obvious that each fault is handled separately. */\n"
3292 "\\&\n"
3293 " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n"
3294 " fault_cnt++;\n"
3295 "\\&\n"
3296 " uffdio_copy.src = (unsigned long) page;\n"
3297 "\\&\n"
3298 " /* We need to handle page faults in units of pages(!).\n"
3299 " So, round faulting address down to page boundary. */\n"
3300 "\\&\n"
3301 " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n"
3302 " \\[ti](page_size - 1);\n"
3303 " uffdio_copy.len = page_size;\n"
3304 " uffdio_copy.mode = 0;\n"
3305 " uffdio_copy.copy = 0;\n"
3306 " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n"
3307 " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n"
3308 "\\&\n"
3309 " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n"
3310 " uffdio_copy.copy);\n"
3311 " }\n"
3312 "}\n"
3313 "\\&\n"
3314 "int\n"
3315 "main(int argc, char *argv[])\n"
3316 "{\n"
3317 " int s;\n"
3318 " char *addr; /* Start of region handled by userfaultfd */\n"
3319 " long uffd; /* userfaultfd file descriptor */\n"
3320 " size_t size, i; /* Size of region handled by userfaultfd */\n"
3321 " pthread_t thr; /* ID of thread that handles page faults */\n"
3322 " struct uffdio_api uffdio_api;\n"
3323 " struct uffdio_register uffdio_register;\n"
3324 "\\&\n"
3325 " if (argc != 2) {\n"
3326 " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n"
3327 " exit(EXIT_FAILURE);\n"
3328 " }\n"
3329 "\\&\n"
3330 " page_size = sysconf(_SC_PAGE_SIZE);\n"
3331 " size = strtoull(argv[1], NULL, 0) * page_size;\n"
3332 "\\&\n"
3333 " /* Create and enable userfaultfd object. */\n"
3334 "\\&\n"
3335 " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n"
3336 " if (uffd == -1)\n"
3337 " err(EXIT_FAILURE, \"userfaultfd\");\n"
3338 "\\&\n"
3339 " /* NOTE: Two-step feature handshake is not needed here, since this\n"
3340 " example doesn't require any specific features.\n"
3341 "\\&\n"
3342 " Programs that *do* should call UFFDIO_API twice: once with\n"
3343 " `features = 0` to detect features supported by this kernel, and\n"
3344 " again with the subset of features the program actually wants to\n"
3345 " enable. */\n"
3346 " uffdio_api.api = UFFD_API;\n"
3347 " uffdio_api.features = 0;\n"
3348 " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n"
3349 " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n"
3350 "\\&\n"
3351 " /* Create a private anonymous mapping. The memory will be\n"
3352 " demand-zero paged--that is, not yet allocated. When we\n"
3353 " actually touch the memory, it will be allocated via\n"
3354 " the userfaultfd. */\n"
3355 "\\&\n"
3356 " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n"
3357 " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n"
3358 " if (addr == MAP_FAILED)\n"
3359 " err(EXIT_FAILURE, \"mmap\");\n"
3360 "\\&\n"
3361 " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n"
3362 "\\&\n"
3363 " /* Register the memory range of the mapping we just created for\n"
3364 " handling by the userfaultfd object. In mode, we request to track\n"
3365 " missing pages (i.e., pages that have not yet been faulted in). */\n"
3366 "\\&\n"
3367 " uffdio_register.range.start = (unsigned long) addr;\n"
3368 " uffdio_register.range.len = size;\n"
3369 " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n"
3370 " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n"
3371 " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n"
3372 "\\&\n"
3373 " /* Create a thread that will process the userfaultfd events. */\n"
3374 "\\&\n"
3375 " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n"
3376 " if (s != 0) {\n"
3377 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
3378 " }\n"
3379 "\\&\n"
3380 " /* Main thread now touches memory in the mapping, touching\n"
3381 " locations 1024 bytes apart. This will trigger userfaultfd\n"
3382 " events for all pages in the region. */\n"
3383 "\\&\n"
3384 " i = 0xf; /* Ensure that faulting address is not on a page\n"
3385 " boundary, in order to test that we correctly\n"
3386 " handle that case in fault_handling_thread(). */\n"
3387 " while (i E<lt> size) {\n"
3388 " char c;\n"
3389 "\\&\n"
3390 " c = addr[i];\n"
3391 " printf(\"Read address %p in %s(): \", addr + i, __func__);\n"
3392 " printf(\"%c\\[rs]n\", c);\n"
3393 " i += 1024;\n"
3394 " usleep(100000); /* Slow things down a little */\n"
3395 " }\n"
3396 "\\&\n"
3397 " exit(EXIT_SUCCESS);\n"
3398 "}\n"
3399
3400 #. type: TH
3401 #: opensuse-leap-16-1 opensuse-tumbleweed
3402 #, no-wrap
3403 msgid "Linux man-pages (unreleased)"
3404 msgstr "صفحات دليل لينكس (لم تصدر بعد)"
3405