# Arabic translation of manpages # This file is distributed under the same license as the manpages-l10n package. # Copyright © of this file: # زايد السعيدي , 2026. msgid "" msgstr "" "Project-Id-Version: manpages-l10n 4.30.2\n" "POT-Creation-Date: 2026-06-05 06:50+0200\n" "PO-Revision-Date: 2026-06-05 22:05+0400\n" "Last-Translator: Zayed Al-Saidi \n" "Language-Team: Arabic \n" "Language: ar\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 &&" " n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" "X-Generator: Lokalize 23.08.5\n" #. type: TH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "userfaultfd" msgstr "userfaultfd" #. type: TH #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "2026-02-16" msgstr "16 فبراير 2026" #. type: TH #: archlinux debian-unstable #, no-wrap msgid "Linux man-pages 6.18" msgstr "صفحات دليل لينكس 6.18" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "NAME" msgstr "الاسم" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "userfaultfd - create a file descriptor for handling page faults in user space" msgstr "userfaultfd - إنشاء واصف ملف لمعالجة أخطاء الصفحات في مساحة المستخدم" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "LIBRARY" msgstr "المكتبة" #. type: Plain text #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron #: opensuse-leap-16-1 opensuse-tumbleweed msgid "Standard C library (I,\\ I<-lc>)" msgstr "مكتبة سي المعيارية (I،\\ I<-lc>)" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "SYNOPSIS" msgstr "موجز" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "" "B<#include Efcntl.hE> /* Definition of B constants" " */\n" "B<#include Esys/syscall.hE> /* Definition of B constants" " */\n" "B<#include Elinux/userfaultfd.hE> /* Definition of B" " constants */\n" "B<#include Eunistd.hE>\n" msgstr "" "B<#include Efcntl.hE> /* تعريف ثوابت B */\n" "B<#include Esys/syscall.hE> /* تعريف ثوابت B */\n" "B<#include Elinux/userfaultfd.hE> /* تعريف ثوابت B */\n" "B<#include Eunistd.hE>\n" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "BIB<);>\n" msgstr "BIB<);>\n" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "I: glibc provides no wrapper for B(), necessitating the " "use of B(2)." msgstr "" "I<ملاحظة>: لا توفر glibc غلافًا لـ B()، مما يستلزم استخدام " "B(2)." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "DESCRIPTION" msgstr "الوصف" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "B() creates a new userfaultfd object that can be used for " "delegation of page-fault handling to a user-space application, and returns a " "file descriptor that refers to the new object. The new userfaultfd object " "is configured using B(2)." msgstr "" "ينشئ B() كائن userfaultfd جديد يمكن استخدامه لتفويض معالجة " "أخطاء الصفحات إلى تطبيق في مساحة المستخدم، ويعيد واصف ملف يشير إلى الكائن " "الجديد. يُضبط كائن userfaultfd الجديد باستخدام B(2)." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Once the userfaultfd object is configured, the application can use " "B(2) to receive userfaultfd notifications. The reads from " "userfaultfd may be blocking or non-blocking, depending on the value of " "I used for the creation of the userfaultfd or subsequent calls to " "B(2)." msgstr "" "بمجرد ضبط كائن userfaultfd، يمكن للتطبيق استخدام B(2) لاستقبال إشعارات " "userfaultfd. قد تكون القراءات من userfaultfd حاجبة أو غير حاجبة، اعتمادًا على " "قيمة I المستخدمة لإنشاء userfaultfd أو الاستدعاءات اللاحقة لـ " "B(2)." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The following values may be bitwise ORed in I to change the behavior " "of B():" msgstr "" "قد تُجمع القيم التالية بعملية OR على مستوى البت في I لتغيير سلوك " "B():" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Enable the close-on-exec flag for the new userfaultfd file descriptor. See " "the description of the B flag in B(2)." msgstr "" "فعّل علم الإغلاق عند التنفيذ (close-on-exec) لواصف ملف userfaultfd الجديد. " "انظر وصف علم B في B(2)." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Enables non-blocking operation for the userfaultfd object. See the " "description of the B flag in B(2)." msgstr "" "يفعّل التشغيل غير الحاجب لكائن userfaultfd. انظر وصف علم B في " "B(2)." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "This is an userfaultfd-specific flag that was introduced in Linux 5.11. " "When set, the userfaultfd object will only be able to handle page faults " "originated from the user space on the registered regions. When a kernel-" "originated fault was triggered on the registered range with this " "userfaultfd, a B signal will be delivered." msgstr "" "هذا علم خاص بـ userfaultfd أُدخل في لينكس 5.11. عند ضبطه، سيكون كائن " "userfaultfd قادرًا فقط على معالجة أخطاء الصفحات الناشئة من مساحة المستخدم في " "المناطق المسجلة. عندما يُقدح خطأ ناشئ من النواة في النطاق المسجل باستخدام " "userfaultfd هذا، ستُرسل إشارة B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When the last file descriptor referring to a userfaultfd object is closed, " "all memory ranges that were registered with the object are unregistered and " "unread events are flushed." msgstr "" "عند إغلاق آخر واصف ملف يشير إلى كائن userfaultfd، تُلغى تسجيلات جميع نطاقات " "الذاكرة التي سُجلت مع الكائن وتُفرغ الأحداث غير المقروءة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "Userfaultfd supports three modes of registration:" msgstr "يدعم Userfaultfd ثلاثة أوضاع للتسجيل:" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.10)" msgstr "B (منذ لينكس 4.10)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When registered with B mode, user-space will " "receive a page-fault notification when a missing page is accessed. The " "faulted thread will be stopped from execution until the page fault is " "resolved from user-space by either an B or an " "B ioctl." msgstr "" "عند التسجيل بالوضع B، ستتلقى مساحة المستخدم " "إشعار خطأ صفحة عند الوصول إلى صفحة مفقودة. سيُوقف الخيط المتعطل عن التنفيذ " "حتى يُحل خطأ الصفحة من مساحة المستخدم بواسطة ioctl إما B أو " "B." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 5.13)" msgstr "B (منذ لينكس 5.13)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When registered with B mode, user-space will " "receive a page-fault notification when a minor page fault occurs. That is, " "when a backing page is in the page cache, but page table entries don't yet " "exist. The faulted thread will be stopped from execution until the page " "fault is resolved from user-space by an B ioctl." msgstr "" "عند التسجيل بالوضع B، ستتلقى مساحة المستخدم " "إشعار خطأ صفحة عند حدوث خطأ صفحة ثانوي. أي عندما تكون صفحة السند في خبيئة " "الصفحات، ولكن مدخلات جدول الصفحات غير موجودة بعد. سيُوقف الخيط المتعطل عن " "التنفيذ حتى يُحل خطأ الصفحة من مساحة المستخدم بواسطة ioctl B." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 5.7)" msgstr "B (منذ لينكس 5.7)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When registered with B mode, user-space will " "receive a page-fault notification when a write-protected page is written. " "The faulted thread will be stopped from execution until user-space write-" "unprotects the page using an B ioctl." msgstr "" "عند التسجيل بالوضع B، ستتلقى مساحة المستخدم إشعار " "خطأ صفحة عند كتابة صفحة محمية ضد الكتابة. سيُوقف الخيط المتعطل عن التنفيذ حتى " "تُزيل مساحة المستخدم حماية الكتابة عن الصفحة باستخدام ioctl " "B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Multiple modes can be enabled at the same time for the same memory range." msgstr "يمكن تمكين أوضاع متعددة في نفس الوقت لنفس نطاق الذاكرة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Since Linux 4.14, a userfaultfd page-fault notification can selectively " "embed faulting thread ID information into the notification. One needs to " "enable this feature explicitly using the B feature " "bit when initializing the userfaultfd context. By default, thread ID " "reporting is disabled." msgstr "" "منذ لينكس 4.14، يمكن لإشعار خطأ صفحة userfaultfd أن يضمّن بشكل انتقائي " "معلومات معرف الخيط المتعطل في الإشعار. يحتاج المرء إلى تمكين هذه الميزة " "صراحةً باستخدام بت الميزة B عند تهيئة سياق " "userfaultfd. الإبلاغ عن معرف الخيط معطل مبدئيًا." #. type: SS #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Usage" msgstr "الاستخدام" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The userfaultfd mechanism is designed to allow a thread in a multithreaded " "program to perform user-space paging for the other threads in the process. " "When a page fault occurs for one of the regions registered to the " "userfaultfd object, the faulting thread is put to sleep and an event is " "generated that can be read via the userfaultfd file descriptor. The fault-" "handling thread reads events from this file descriptor and services them " "using the operations described in B(2). When servicing " "the page fault events, the fault-handling thread can trigger a wake-up for " "the sleeping thread." msgstr "" "صُممت آلية userfaultfd للسماح لخيط في برنامج متعدد الخيوط بأداء ترحيل صفحات " "في مساحة المستخدم للخيوط الأخرى في العملية. عند حدوث خطأ صفحة لإحدى المناطق " "المسجلة لكائن userfaultfd، يُوضع الخيط المتعطل في حالة سكون ويُولد حدث يمكن " "قراءته عبر واصف ملف userfaultfd. يقرأ خيط معالجة الأخطاء الأحداث من واصف " "الملف هذا ويخدمها باستخدام العمليات الموصوفة في B(2). عند " "خدمة أحداث خطأ الصفحة، يمكن لخيط معالجة الأخطاء قدح إيقاظ للخيط النائم." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "It is possible for the faulting threads and the fault-handling threads to " "run in the context of different processes. In this case, these threads may " "belong to different programs, and the program that executes the faulting " "threads will not necessarily cooperate with the program that handles the " "page faults. In such non-cooperative mode, the process that monitors " "userfaultfd and handles page faults needs to be aware of the changes in the " "virtual memory layout of the faulting process to avoid memory corruption." msgstr "" "من الممكن أن تعمل الخيوط المتعطلة وخيوط معالجة الأخطاء في سياق عمليات " "مختلفة. في هذه الحالة، قد تنتمي هذه الخيوط إلى برامج مختلفة، ولن يتعاون " "البرنامج الذي ينفذ الخيوط المتعطلة بالضرورة مع البرنامج الذي يعالج أخطاء " "الصفحات. في هذا الوضع غير التعاوني، تحتاج العملية التي تراقب userfaultfd " "وتعالج أخطاء الصفحات إلى أن تكون على دراية بالتغييرات في تخطيط الذاكرة " "الافتراضية للعملية المتعطلة لتجنب فساد الذاكرة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Since Linux 4.11, userfaultfd can also notify the fault-handling threads " "about changes in the virtual memory layout of the faulting process. In " "addition, if the faulting process invokes B(2), the userfaultfd " "objects associated with the parent may be duplicated into the child process " "and the userfaultfd monitor will be notified (via the B " "described below) about the file descriptor associated with the userfault " "objects created for the child process, which allows the userfaultfd monitor " "to perform user-space paging for the child process. Unlike page faults " "which have to be synchronous and require an explicit or implicit wakeup, all " "other events are delivered asynchronously and the non-cooperative process " "resumes execution as soon as the userfaultfd manager executes B(2). " "The userfaultfd manager should carefully synchronize calls to B " "with the processing of events." msgstr "" "منذ لينكس 4.11، يمكن لـ userfaultfd أيضًا إخطار خيوط معالجة الأخطاء حول " "التغييرات في تخطيط الذاكرة الافتراضية للعملية المتعطلة. بالإضافة إلى ذلك، " "إذا استدعت العملية المتعطلة B(2)، فقد تُكرر كائنات userfaultfd المرتبطة " "بالأصل في العملية الفرعية وسيُخطر مراقب userfaultfd (عبر B " "الموصوف أدناه) بشأن واصف الملف المرتبط بكائنات userfault المنشأة للعملية " "الفرعية، مما يسمح لمراقب userfaultfd بأداء ترحيل صفحات في مساحة المستخدم " "للعملية الفرعية. على عكس أخطاء الصفحات التي يجب أن تكون متزامنة وتتطلب " "إيقاظًا صريحًا أو ضمنيًا، تُسلم جميع الأحداث الأخرى بشكل غير متزامن وتستأنف " "العملية غير التعاونية التنفيذ بمجرد أن ينفذ مدير userfaultfd B(2). يجب " "على مدير userfaultfd مزامنة استدعاءات B بعناية مع معالجة " "الأحداث." #. #-#-#-#-# archlinux: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-# #. Regarding the preceding sentence, Mike Rapoport says: #. The major point here is that current events delivery model could be #. problematic for multi-threaded monitor. I even suspect that it would be #. impossible to ensure synchronization between page faults and non-page #. fault events in multi-threaded monitor. #. .P #. FIXME elaborate about non-cooperating mode, describe its limitations #. for kernels before Linux 4.11, features added in Linux 4.11 #. and limitations remaining in Linux 4.11 #. Maybe it's worth adding a dedicated sub-section... #. type: Plain text #. #-#-#-#-# debian-trixie: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-# #. Regarding the preceding sentence, Mike Rapoport says: #. The major point here is that current events delivery model could be #. problematic for multi-threaded monitor. I even suspect that it would be #. impossible to ensure synchronization between page faults and non-page #. fault events in multi-threaded monitor. #. .P #. FIXME elaborate about non-cooperating mode, describe its limitations #. for kernels before Linux 4.11, features added in Linux 4.11 #. and limitations remaining in Linux 4.11 #. Maybe it's worth adding a dedicated sub-section... #. type: Plain text #. #-#-#-#-# debian-unstable: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-# #. Regarding the preceding sentence, Mike Rapoport says: #. The major point here is that current events delivery model could be #. problematic for multi-threaded monitor. I even suspect that it would be #. impossible to ensure synchronization between page faults and non-page #. fault events in multi-threaded monitor. #. .P #. FIXME elaborate about non-cooperating mode, describe its limitations #. for kernels before Linux 4.11, features added in Linux 4.11 #. and limitations remaining in Linux 4.11 #. Maybe it's worth adding a dedicated sub-section... #. type: Plain text #. #-#-#-#-# fedora-44: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-# #. Regarding the preceding sentence, Mike Rapoport says: #. The major point here is that current events delivery model could be #. problematic for multi-threaded monitor. I even suspect that it would be #. impossible to ensure synchronization between page faults and non-page #. fault events in multi-threaded monitor. #. .P #. FIXME elaborate about non-cooperating mode, describe its limitations #. for kernels before Linux 4.11, features added in Linux 4.11 #. and limitations remaining in Linux 4.11 #. Maybe it's worth adding a dedicated sub-section... #. type: Plain text #. #-#-#-#-# fedora-rawhide: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-# #. Regarding the preceding sentence, Mike Rapoport says: #. The major point here is that current events delivery model could be #. problematic for multi-threaded monitor. I even suspect that it would be #. impossible to ensure synchronization between page faults and non-page #. fault events in multi-threaded monitor. #. .P #. FIXME elaborate about non-cooperating mode, describe its limitations #. for kernels before Linux 4.11, features added in Linux 4.11 #. and limitations remaining in Linux 4.11 #. Maybe it's worth adding a dedicated sub-section... #. type: Plain text #. #-#-#-#-# mageia-cauldron: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-# #. Regarding the preceding sentence, Mike Rapoport says: #. The major point here is that current events delivery model could be #. problematic for multi-threaded monitor. I even suspect that it would be #. impossible to ensure synchronization between page faults and non-page #. fault events in multi-threaded monitor. #. .P #. FIXME elaborate about non-cooperating mode, describe its limitations #. for kernels before Linux 4.11, features added in Linux 4.11 #. and limitations remaining in Linux 4.11 #. Maybe it's worth adding a dedicated sub-section... #. type: Plain text #. #-#-#-#-# opensuse-leap-16-1: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-# #. Regarding the preceding sentence, Mike Rapoport says: #. The major point here is that current events delivery model could be #. problematic for multi-threaded monitor. I even suspect that it would be #. impossible to ensure synchronization between page faults and non-page #. fault events in multi-threaded monitor. #. .P #. FIXME elaborate about non-cooperating mode, describe its limitations #. for kernels before Linux 4.11, features added in Linux 4.11 #. and limitations remaining in Linux 4.11 #. Maybe it's worth adding a dedicated sub-section... #. type: Plain text #. #-#-#-#-# opensuse-tumbleweed: userfaultfd.2.pot (PACKAGE VERSION) #-#-#-#-# #. Regarding the preceding sentence, Mike Rapoport says: #. The major point here is that current events delivery model could be #. problematic for multi-threaded monitor. I even suspect that it would be #. impossible to ensure synchronization between page faults and non-page #. fault events in multi-threaded monitor. #. .P #. FIXME elaborate about non-cooperating mode, describe its limitations #. for kernels before Linux 4.11, features added in Linux 4.11 #. and limitations remaining in Linux 4.11 #. Maybe it's worth adding a dedicated sub-section... #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The current asynchronous model of the event delivery is optimal for single " "threaded non-cooperative userfaultfd manager implementations." msgstr "" "النموذج غير المتزامن الحالي لتسليم الأحداث هو الأمثل لتطبيقات مدير " "userfaultfd غير التعاونية أحادية الخيط." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Since Linux 5.7, userfaultfd is able to do synchronous page dirty tracking " "using the new write-protect register mode. One should check against the " "feature bit B before using this feature. " "Similar to the original userfaultfd missing mode, the write-protect mode " "will generate a userfaultfd notification when the protected page is " "written. The user needs to resolve the page fault by unprotecting the " "faulted page and kicking the faulted thread to continue. For more " "information, please refer to the \"Userfaultfd write-protect mode\" section." msgstr "" "منذ لينكس 5.7، أصبح userfaultfd قادرًا على القيام بتتبع متزامن لاتساخ الصفحات " "باستخدام وضع التسجيل الجديد للحماية من الكتابة. يجب على المرء التحقق من بت " "الميزة B قبل استخدام هذه الميزة. على غرار " "وضع الفقدان الأصلي لـ userfaultfd، سيُولد وضع الحماية من الكتابة إشعار " "userfaultfd عند كتابة الصفحة المحمية. يحتاج المستخدم إلى حل خطأ الصفحة عن " "طريق إزالة الحماية عن الصفحة المتعطلة وركل الخيط المتعطل للمتابعة. لمزيد من " "المعلومات، يُرجى الرجوع إلى قسم \"وضع الحماية من الكتابة في Userfaultfd\"." #. type: SS #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Userfaultfd operation" msgstr "عملية Userfaultfd" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "After the userfaultfd object is created with B(), the " "application must enable it using the B B(2) operation. " "This operation allows a two-step handshake between the kernel and user space " "to determine what API version and features the kernel supports, and then to " "enable those features user space wants. This operation must be performed " "before any of the other B(2) operations described below (or those " "operations fail with the B error)." msgstr "" "بعد إنشاء كائن userfaultfd باستخدام B()، يجب على التطبيق تمكينه " "باستخدام عملية B B(2). تسمح هذه العملية بمصافحة من خطوتين " "بين النواة ومساحة المستخدم لتحديد إصدار API والميزات التي تدعمها النواة، ثم " "تمكين الميزات التي تريدها مساحة المستخدم. يجب تنفيذ هذه العملية قبل أي من " "عمليات B(2) الأخرى الموصوفة أدناه (وإلا ستفشل تلك العمليات مع الخطأ " "B)." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "After a successful B operation, the application then registers " "memory address ranges using the B B(2) operation. " "After successful completion of a B operation, a page fault " "occurring in the requested memory range, and satisfying the mode defined at " "the registration time, will be forwarded by the kernel to the user-space " "application. The application can then use various (e.g., B, " "B, or B) B(2) operations to " "resolve the page fault." msgstr "" "بعد نجاح عملية B، يقوم التطبيق بتسجيل نطاقات عناوين الذاكرة " "باستخدام عملية B B(2). بعد الإكمال الناجح لعملية " "B، سيقوم النواة بإعادة توجيه أي خطأ صفحة يحدث في نطاق " "الذاكرة المطلوب، ويحقق الوضع المحدد وقت التسجيل، إلى تطبيق مساحة المستخدم. " "يمكن للتطبيق بعد ذلك استخدام عمليات B(2) متنوعة (مثل B، " "أو B، أو B) لحل خطأ الصفحة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Since Linux 4.14, if the application sets the B feature " "bit using the B B(2), no page-fault notification will be " "forwarded to user space. Instead a B signal is delivered to the " "faulting process. With this feature, userfaultfd can be used for robustness " "purposes to simply catch any access to areas within the registered address " "range that do not have pages allocated, without having to listen to " "userfaultfd events. No userfaultfd monitor will be required for dealing " "with such memory accesses. For example, this feature can be useful for " "applications that want to prevent the kernel from automatically allocating " "pages and filling holes in sparse files when the hole is accessed through a " "memory mapping." msgstr "" "منذ لينكس 4.14، إذا ضبط التطبيق بت الميزة B باستخدام " "B B(2)، فلن يُعاد توجيه أي إشعار بخطأ صفحة إلى مساحة " "المستخدم. بدلاً من ذلك، تُسلم إشارة B إلى العملية المتعطلة. باستخدام " "هذه الميزة، يمكن استخدام userfaultfd لأغراض المتانة للقبض ببساطة على أي وصول " "لمناطق ضمن نطاق العناوين المسجل لا تحتوي على صفحات مخصصة، دون الحاجة " "للاستماع لأحداث userfaultfd. لن يكون هناك حاجة لمراقب userfaultfd للتعامل مع " "مثل هذه الوصولات للذاكرة. على سبيل المثال، يمكن أن تكون هذه الميزة مفيدة " "للتطبيقات التي تريد منع النواة من تخصيص الصفحات آليًا وملء الفجوات في الملفات " "المتفرقة عند الوصول إلى الفجوة عبر تعيين ذاكرة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The B feature is implicitly inherited through " "B(2) if used in combination with B." msgstr "" "تُورث ميزة B ضمنيًا من خلال B(2) إذا استُخدمت مع " "B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Details of the various B(2) operations can be found in " "B(2)." msgstr "" "يمكن العثور على تفاصيل عمليات B(2) المختلفة في " "B(2)." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Since Linux 4.11, events other than page-fault may enabled during " "B operation." msgstr "" "منذ لينكس 4.11، يمكن تمكين أحداث بخلاف أخطاء الصفحات أثناء عملية " "B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Up to Linux 4.11, userfaultfd can be used only with anonymous private memory " "mappings. Since Linux 4.11, userfaultfd can be also used with hugetlbfs and " "shared memory mappings." msgstr "" "حتى لينكس 4.11، كان يمكن استخدام userfaultfd فقط مع تعيينات الذاكرة الخاصة " "المجهولة. منذ لينكس 4.11، يمكن أيضًا استخدام userfaultfd مع hugetlbfs " "وتعيينات الذاكرة المشتركة." #. type: SS #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Userfaultfd write-protect mode (since Linux 5.7)" msgstr "وضع الحماية من الكتابة في Userfaultfd (منذ لينكس 5.7)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Since Linux 5.7, userfaultfd supports write-protect mode for anonymous " "memory. The user needs to first check availability of this feature using " "B ioctl against the feature bit " "B before using this feature." msgstr "" "منذ لينكس 5.7، يدعم userfaultfd وضع الحماية من الكتابة للذاكرة المجهولة. " "يحتاج المستخدم أولاً للتحقق من توفر هذه الميزة باستخدام ioctl B " "مقابل بت الميزة B قبل استخدام هذه الميزة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Since Linux 5.19, the write-protection mode was also supported on shmem and " "hugetlbfs memory types. It can be detected with the feature bit " "B." msgstr "" "منذ لينكس 5.19، دُعم وضع الحماية من الكتابة أيضًا على أنواع الذاكرة shmem و " "hugetlbfs. يمكن اكتشافه ببت الميزة B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "To register with userfaultfd write-protect mode, the user needs to initiate " "the B ioctl with mode B set. Note " "that it is legal to monitor the same memory range with multiple modes. For " "example, the user can do B with the mode set to " "B. When there is " "only B registered, user-space will I receive " "any notification when a missing page is written. Instead, user-space will " "receive a write-protect page-fault notification only when an existing but " "write-protected page got written." msgstr "" "للتسجيل مع وضع الحماية من الكتابة لـ userfaultfd، يحتاج المستخدم إلى بدء " "ioctl B مع تعيين الوضع B. لاحظ أنه " "من القانوني مراقبة نفس نطاق الذاكرة بأوضاع متعددة. على سبيل المثال، يمكن " "للمستخدم القيام بـ B مع تعيين الوضع إلى " "B. عندما يتم تسجيل " "B فقط، I<لن> تتلقى مساحة المستخدم أي إشعار عند كتابة " "صفحة مفقودة. بدلاً من ذلك، ستتلقى مساحة المستخدم إشعار خطأ صفحة للحماية من " "الكتابة فقط عند كتابة صفحة موجودة ولكنها محمية من الكتابة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "After the B ioctl completed with B " "mode set, the user can write-protect any existing memory within the range " "using the ioctl B where I " "should be set to B." msgstr "" "بعد اكتمال ioctl B مع تعيين وضع B، " "يمكن للمستخدم حماية أي ذاكرة موجودة ضمن النطاق من الكتابة باستخدام ioctl " "B حيث يجب تعيين I إلى " "B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When a write-protect event happens, user-space will receive a page-fault " "notification whose I will be with " "B flag set. Note: since only writes can trigger " "this kind of fault, write-protect notifications will always have the " "B bit set along with the " "B bit." msgstr "" "عند حدوث حدث حماية من الكتابة، ستتلقى مساحة المستخدم إشعار خطأ صفحة حيث " "سيكون I مع تعيين علم B. " "ملاحظة: نظرًا لأن الكتابات فقط يمكنها تشغيل هذا النوع من الأخطاء، فإن إشعارات " "الحماية من الكتابة ستحتوي دائمًا على بت B مضبوطًا " "مع بت B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "To resolve a write-protection page fault, the user should initiate another " "B ioctl, whose I should have " "the flag B cleared upon the faulted page or " "range." msgstr "" "لحل خطأ صفحة الحماية من الكتابة، يجب على المستخدم بدء ioctl " "B آخر، حيث يجب أن يكون I مع " "مسح العلم B على الصفحة أو النطاق المتسبب في " "الخطأ." #. type: SS #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Userfaultfd minor fault mode (since Linux 5.13)" msgstr "وضع الخطأ الثانوي لـ Userfaultfd (منذ لينكس 5.13)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Since Linux 5.13, userfaultfd supports minor fault mode. In this mode, " "fault messages are produced not for major faults (where the page was " "missing), but rather for minor faults, where a page exists in the page " "cache, but the page table entries are not yet present. The user needs to " "first check availability of this feature using the B ioctl with " "the appropriate feature bits set before using this feature: " "B since Linux 5.13, or " "B since Linux 5.14." msgstr "" "منذ لينكس 5.13، يدعم userfaultfd وضع الخطأ الثانوي. في هذا الوضع، يتم إنتاج " "رسائل الخطأ ليس للأخطاء الرئيسية (حيث كانت الصفحة مفقودة)، بل للأخطاء " "الثانوية، حيث توجد صفحة في خبيئة الصفحة، ولكن إدخالات جدول الصفحة غير موجودة " "بعد. يحتاج المستخدم أولاً إلى التحقق من توفر هذه الميزة باستخدام ioctl " "B مع تعيين بتات الميزة المناسبة قبل استخدام هذه الميزة: " "B منذ لينكس 5.13، أو " "B منذ لينكس 5.14." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "To register with userfaultfd minor fault mode, the user needs to initiate " "the B ioctl with mode B set." msgstr "" "للتسجيل مع وضع الخطأ الثانوي لـ userfaultfd، يحتاج المستخدم إلى بدء ioctl " "B مع تعيين الوضع B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "When a minor fault occurs, user-space will receive a page-fault notification " "whose I will have the B " "flag set." msgstr "" "عند حدوث خطأ ثانوي، ستتلقى مساحة المستخدم إشعار خطأ صفحة حيث سيكون " "I مع تعيين علم B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "To resolve a minor page fault, the handler should decide whether or not the " "existing page contents need to be modified first. If so, this should be " "done in-place via a second, non-userfaultfd-registered mapping to the same " "backing page (e.g., by mapping the shmem or hugetlbfs file twice). Once the " "page is considered \"up to date\", the fault can be resolved by initiating " "an B ioctl, which installs the page table entries and (by " "default) wakes up the faulting thread(s)." msgstr "" "لحل خطأ صفحة ثانوي، يجب على المعالج تحديد ما إذا كانت محتويات الصفحة الحالية " "تحتاج إلى تعديل أولاً أم لا. إذا كان الأمر كذلك، فيجب القيام بذلك في المكان " "من خلال تعيين ثانٍ غير مسجل بـ userfaultfd لنفس الصفحة الداعمة (على سبيل " "المثال، عن طريق تعيين ملف shmem أو hugetlbfs مرتين). بمجرد اعتبار الصفحة " "\"محدثة\"، يمكن حل الخطأ عن طريق بدء ioctl B، الذي يقوم " "بتثبيت إدخالات جدول الصفحة و(بشكل مبدئي) إيقاظ الخيوط المتسببة في الخطأ." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Minor fault mode supports only hugetlbfs-backed (since Linux 5.13) and " "shmem-backed (since Linux 5.14) memory." msgstr "" "يدعم وضع الخطأ الثانوي فقط الذاكرة المدعومة بـ hugetlbfs (منذ لينكس 5.13) " "والمدعومة بـ shmem (منذ لينكس 5.14)." #. type: SS #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Reading from the userfaultfd structure" msgstr "القراءة من بنية userfaultfd" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Each B(2) from the userfaultfd file descriptor returns one or more " "I structures, each of which describes a page-fault event or an " "event required for the non-cooperative userfaultfd usage:" msgstr "" "كل B(2) من واصف ملف userfaultfd يُرجع بنية I واحدة أو أكثر، " "كل منها يصف حدث خطأ صفحة أو حدثًا مطلوبًا لاستخدام userfaultfd غير التعاوني:" #. type: Plain text #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron #: opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "" "struct uffd_msg {\n" " __u8 event; /* Type of event */\n" " ...\n" " union {\n" " struct {\n" " __u64 flags; /* Flags describing fault */\n" " __u64 address; /* Faulting address */\n" " union {\n" " __u32 ptid; /* Thread ID of the fault */\n" " } feat;\n" " } pagefault;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u32 ufd; /* Userfault file descriptor\n" " of the child process */\n" " } fork;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u64 from; /* Old address of remapped area */\n" " __u64 to; /* New address of remapped area */\n" " __u64 len; /* Original mapping size */\n" " } remap;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u64 start; /* Start address of removed area */\n" " __u64 end; /* End address of removed area */\n" " } remove;\n" " ...\n" " } arg;\n" "\\&\n" " /* Padding fields omitted */\n" "} __packed;\n" msgstr "" "struct uffd_msg {\n" " __u8 event; /* Type of event */\n" " ...\n" " union {\n" " struct {\n" " __u64 flags; /* Flags describing fault */\n" " __u64 address; /* Faulting address */\n" " union {\n" " __u32 ptid; /* Thread ID of the fault */\n" " } feat;\n" " } pagefault;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u32 ufd; /* Userfault file descriptor\n" " of the child process */\n" " } fork;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u64 from; /* Old address of remapped area */\n" " __u64 to; /* New address of remapped area */\n" " __u64 len; /* Original mapping size */\n" " } remap;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u64 start; /* Start address of removed area */\n" " __u64 end; /* End address of removed area */\n" " } remove;\n" " ...\n" " } arg;\n" "\\&\n" " /* Padding fields omitted */\n" "} __packed;\n" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "If multiple events are available and the supplied buffer is large enough, " "B(2) returns as many events as will fit in the supplied buffer. If " "the buffer supplied to B(2) is smaller than the size of the " "I structure, the B(2) fails with the error B." msgstr "" "إذا توفرت أحداث متعددة وكان الوسيط (buffer) الموفر كبيراً بما يكفي، يعيد " "الاستدعاء B(2) أكبر عدد ممكن من الأحداث التي يمكن احتواؤها في الوسيط " "الموفر. أما إذا كان الوسيط الموفر للاستدعاء B(2) أصغر من حجم بنية " "I، فيخفق الاستدعاء B(2) مع الخطأ B." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "The fields set in the I structure are as follows:" msgstr "الحقول المضبوطة في بنية I هي كما يلي:" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The type of event. Depending of the event type, different fields of the " "I union represent details required for the event processing. The non-" "page-fault events are generated only when appropriate feature is enabled " "during API handshake with B B(2)." msgstr "" "نوع الحدث. وبناءً على نوع الحدث، تمثل الحقول المختلفة لاتحاد I (union) " "التفاصيل المطلوبة لمعالجة الحدث. لا تُولّد الأحداث التي ليست من نوع" " خطأ-الصفحة " "(page-fault) إلا عند تفعيل الميزة المناسبة أثناء مصافحة واجهة برمجة " "التطبيقات عبر B B(2)." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "The following values can appear in the I field:" msgstr "يمكن أن تظهر القيم التالية في حقل I:" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.3)" msgstr "B (منذ لينكس 4.3)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "A page-fault event. The page-fault details are available in the " "I field." msgstr "حدث خطأ-صفحة. تفاصيل خطأ-الصفحة متاحة في الحقل I." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.11)" msgstr "B (منذ لينكس 4.11)" #. FIXME describe duplication of userfault file descriptor during fork #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Generated when the faulting process invokes B(2) (or B(2) " "without the B flag). The event details are available in the " "I field." msgstr "" "يُتولد عندما تستدعي العملية المتسببة بالخطأ B(2) (أو B(2) بدون " "علمة B). تفاصيل الحدث متوفرة في حقل I." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.11)" msgstr "B (منذ لينكس 4.11)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Generated when the faulting process invokes B(2). The event details " "are available in the I field." msgstr "" "يُتولد عندما تستدعي العملية المتسببة بالخطأ B(2). تفاصيل الحدث متوفرة " "في حقل I." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.11)" msgstr "B (منذ لينكس 4.11)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Generated when the faulting process invokes B(2) with " "B or B advice. The event details are available " "in the I field." msgstr "" "يُتولد عندما تستدعي العملية المتسببة بالخطأ B(2) مع نصيحة " "B أو B. تفاصيل الحدث متوفرة في حقل I." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.11)" msgstr "B (منذ لينكس 4.11)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Generated when the faulting process unmaps a memory range, either explicitly " "using B(2) or implicitly during B(2) or B(2). The " "event details are available in the I field." msgstr "" "يُتولد عندما تلغي العملية المتسببة بالخطأ تعيين نطاق ذاكرة، إما صراحة " "باستخدام B(2) أو ضمنًا أثناء B(2) أو B(2). تفاصيل الحدث " "متوفرة في حقل I." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "The address that triggered the page fault." msgstr "العنوان الذي أثار خطأ الصفحة." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "A bit mask of flags that describe the event. For B, " "the following flag may appear:" msgstr "" "قناع بتات للأعلام التي تصف الحدث. بالنسبة لـ B، قد " "يظهر العلم التالي:" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "If this flag is set, then the fault was a write-protect fault." msgstr "إذا كان هذا العلم مضبوطًا، فإن الخطأ كان خطأ حماية من الكتابة." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "If this flag is set, then the fault was a minor fault." msgstr "إذا كان هذا العلم مضبوطًا، فإن الخطأ كان خطأ بسيطًا." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "If this flag is set, then the fault was a write fault." msgstr "إذا كان هذا العلم مضبوطًا، فإن الخطأ كان خطأ كتابة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "If neither B nor B are " "set, then the fault was a missing fault." msgstr "" "إذا لم يكن أي من B أو B " "مضبوطًا، فإن الخطأ كان خطأ فقدان." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "The thread ID that triggered the page fault." msgstr "معرف الخيط الذي أثار خطأ الصفحة." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The file descriptor associated with the userfault object created for the " "child created by B(2)." msgstr "" "واصف الملف المرتبط بكائن userfault الذي أُنشئ للطفل الذي أنشأته B(2)." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The original address of the memory range that was remapped using " "B(2)." msgstr "العنوان الأصلي لنطاق الذاكرة الذي أُعيد تعيينه باستخدام B(2)." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The new address of the memory range that was remapped using B(2)." msgstr "العنوان الجديد لنطاق الذاكرة الذي أُعيد تعيينه باستخدام B(2)." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron #: opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The original size of the memory range that was remapped using B(2)." msgstr "الحجم الأصلي لنطاق الذاكرة الذي أُعيد تعيينه باستخدام B(2)." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The start address of the memory range that was freed using B(2) or " "unmapped" msgstr "" "عنوان البداية لنطاق الذاكرة الذي حُرر باستخدام B(2) أو أُلغي تعيينه" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "I" msgstr "I" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The end address of the memory range that was freed using B(2) or " "unmapped" msgstr "" "عنوان نهاية نطاق الذاكرة الذي تم تحريره باستخدام B(2) أو إلغاء " "تعيينه" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "A B(2) on a userfaultfd file descriptor can fail with the following " "errors:" msgstr "قد تفشل عملية B(2) على واصف ملف userfaultfd مع الأخطاء التالية:" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The userfaultfd object has not yet been enabled using the B " "B(2) operation" msgstr "" "لم يتم تمكين كائن userfaultfd بعد باستخدام عملية B B(2)" #. FIXME What is the reason for this seemingly odd behavior with respect #. to the O_NONBLOCK flag? (see userfaultfd_poll() in fs/userfaultfd.c). #. Something needs to be said about this. #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "If the B flag is enabled in the associated open file " "description, the userfaultfd file descriptor can be monitored with " "B(2), B(2) indicates the file descriptor as both readable " "and writable." msgstr "" "إذا تم تمكين علامة B في وصف الملف المفتوح المرتبط، يمكن مراقبة " "واصف ملف userfaultfd باستخدام B(2) وB(2) إلى أن واصف الملف قابل للقراءة والكتابة معًا." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "RETURN VALUE" msgstr "قيمة الإرجاع" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "On success, B() returns a new file descriptor that refers to " "the userfaultfd object. On error, -1 is returned, and I is set to " "indicate the error." msgstr "" "عند النجاح، تُرجع B() واصف ملف جديد يشير إلى كائن userfaultfd. " "عند الخطأ، تُرجع -1، ويتم تعيين I للإشارة إلى الخطأ." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "ERRORS" msgstr "الأخطاء" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "An unsupported value was specified in I." msgstr "عُيّنت قيمة غير مدعومة في I." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The per-process limit on the number of open file descriptors has been reached" msgstr "تم الوصول إلى الحد الأقصى لكل عملية لعدد واصفات الملفات المفتوحة" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The system-wide limit on the total number of open files has been reached." msgstr "وُصل إلى الحد الأقصى لإجمالي عدد الملفات المفتوحة على مستوى النظام." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "B" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "Insufficient kernel memory was available." msgstr "ذاكرة النواة المتوفرة غير كافية." #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 5.2)" msgstr "B (منذ Linux 5.2)" #. cefdca0a86be517bc390fc4541e3674b8e7803b0 #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The caller is not privileged (does not have the B capability " "in the initial user namespace), and I " "has the value 0." msgstr "" "المتصل ليس لديه صلاحية (ليس لديه قدرة B في مساحة اسم " "المستخدم الأولية)، وقيمة I هي 0." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "STANDARDS" msgstr "المعايير" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "Linux." msgstr "لينكس." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "HISTORY" msgstr "التاريخ" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "Linux 4.3." msgstr "لينكس 4.3." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Support for hugetlbfs and shared memory areas and non-page-fault events was " "added in Linux 4.11" msgstr "" "تمت إضافة دعم hugetlbfs ومناطق الذاكرة المشتركة وأحداث غير خطأ الصفحة في " "Linux 4.11" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "NOTES" msgstr "ملاحظات" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The userfaultfd mechanism can be used as an alternative to traditional user-" "space paging techniques based on the use of the B signal and " "B(2). It can also be used to implement lazy restore for checkpoint/" "restore mechanisms, as well as post-copy migration to allow (nearly) " "uninterrupted execution when transferring virtual machines and Linux " "containers from one host to another." msgstr "" "يمكن استخدام آلية userfaultfd كبديل لتقنيات الترحيل التقليدية في مساحة " "المستخدم القائمة على استخدام إشارة B وB(2). يمكن استخدامها " "أيضًا لتنفيذ الاستعادة البطيئة لآليات نقطة التفتيش/الاستعادة، بالإضافة إلى " "الترحيل بعد النسخ للسماح بالتنفيذ (شبه) المتواصل عند نقل الأجهزة الافتراضية " "وحاويات Linux من مضيف إلى آخر." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "BUGS" msgstr "العلل" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "If the B is enabled and a system call from the " "B(2) family is interrupted by a signal or failed, a stale userfaultfd " "descriptor might be created. In this case, a spurious B " "will be delivered to the userfaultfd monitor." msgstr "" "إذا تم تمكين B وتم مقاطعة استدعاء نظام من عائلة " "B(2) بواسطة إشارة أو فشل، فقد يتم إنشاء واصف userfaultfd قديم. في هذه " "الحالة، سيتم تسليم B زائف إلى مراقب userfaultfd." #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "EXAMPLES" msgstr "أمثلة" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The program below demonstrates the use of the userfaultfd mechanism. The " "program creates two threads, one of which acts as the page-fault handler for " "the process, for the pages in a demand-page zero region created using " "B(2)." msgstr "" "يوضح البرنامج أدناه استخدام آلية userfaultfd. يقوم البرنامج بإنشاء خيطين، " "أحدهما يعمل كمعالج خطأ الصفحة للعملية، للصفحات في منطقة طلب صفحة صفرية تم " "إنشاؤها باستخدام B(2)." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The program takes one command-line argument, which is the number of pages " "that will be created in a mapping whose page faults will be handled via " "userfaultfd. After creating a userfaultfd object, the program then creates " "an anonymous private mapping of the specified size and registers the address " "range of that mapping using the B B(2) operation. " "The program then creates a second thread that will perform the task of " "handling page faults." msgstr "" "يأخذ البرنامج وسيطة سطر أوامر واحدة، وهي عدد الصفحات التي سيتم إنشاؤها في " "تعيين سيتم التعامل مع أخطاء صفحته عبر userfaultfd. بعد إنشاء كائن " "userfaultfd، يقوم البرنامج بعد ذلك بإنشاء تعيين خاص مجهول بالحجم المحدد " "ويسجل نطاق العنوان لذلك التعيين باستخدام عملية B " "B(2). ثم يقوم البرنامج بإنشاء خيط ثانٍ سيقوم بمهمة معالجة أخطاء الصفحة." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The main thread then walks through the pages of the mapping fetching bytes " "from successive pages. Because the pages have not yet been accessed, the " "first access of a byte in each page will trigger a page-fault event on the " "userfaultfd file descriptor." msgstr "" "ثم يتجول الخيط الرئيسي عبر صفحات التعيين لجلب البايتات من الصفحات المتتالية. " "نظرًا لعدم الوصول إلى الصفحات بعد، فإن أول وصول لبايت في كل صفحة سيؤدي إلى " "تشغيل حدث خطأ صفحة على واصف ملف userfaultfd." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Each of the page-fault events is handled by the second thread, which sits in " "a loop processing input from the userfaultfd file descriptor. In each loop " "iteration, the second thread first calls B(2) to check the state of " "the file descriptor, and then reads an event from the file descriptor. All " "such events should be B events, which the thread " "handles by copying a page of data into the faulting region using the " "B B(2) operation." msgstr "" "يتم التعامل مع كل حدث من أحداث خطأ الصفحة بواسطة الخيط الثاني، الذي يجلس في " "حلقة لمعالجة الإدخال من واصف ملف userfaultfd. في كل تكرار للحلقة، يستدعي " "الخيط الثاني أولاً B(2) للتحقق من حالة واصف الملف، ثم يقرأ حدثًا من" " واصف " "الملف. يجب أن تكون كل هذه الأحداث أحداث B، والتي " "يعالجها الخيط عن طريق نسخ صفحة من البيانات إلى المنطقة المتسببة في الخطأ " "باستخدام عملية B B(2)." #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "The following is an example of what we see when running the program:" msgstr "فيما يلي مثال لما نراه عند تشغيل البرنامج:" #. type: Plain text #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "" "$B< ./userfaultfd_demo 3>;\n" "Address returned by mmap() = 0x7fd30106c000\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106c00f in main(): A\n" "Read address 0x7fd30106c40f in main(): A\n" "Read address 0x7fd30106c80f in main(): A\n" "Read address 0x7fd30106cc0f in main(): A\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106d00f in main(): B\n" "Read address 0x7fd30106d40f in main(): B\n" "Read address 0x7fd30106d80f in main(): B\n" "Read address 0x7fd30106dc0f in main(): B\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106e00f in main(): C\n" "Read address 0x7fd30106e40f in main(): C\n" "Read address 0x7fd30106e80f in main(): C\n" "Read address 0x7fd30106ec0f in main(): C\n" msgstr "" "$B< ./userfaultfd_demo 3>;\n" "Address returned by mmap() = 0x7fd30106c000\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106c00f in main(): A\n" "Read address 0x7fd30106c40f in main(): A\n" "Read address 0x7fd30106c80f in main(): A\n" "Read address 0x7fd30106cc0f in main(): A\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106d00f in main(): B\n" "Read address 0x7fd30106d40f in main(): B\n" "Read address 0x7fd30106d80f in main(): B\n" "Read address 0x7fd30106dc0f in main(): B\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106e00f in main(): C\n" "Read address 0x7fd30106e40f in main(): C\n" "Read address 0x7fd30106e80f in main(): C\n" "Read address 0x7fd30106ec0f in main(): C\n" #. type: SS #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Program source" msgstr "مصدر البرنامج" #. type: Plain text #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "" "/* userfaultfd_demo.c\n" "\\&\n" " Licensed under the GNU General Public License version 2 or later.\n" "*/\n" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Efcntl.hE\n" "#include Einttypes.hE\n" "#include Elinux/userfaultfd.hE\n" "#include Epoll.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/ioctl.hE\n" "#include Esys/mman.hE\n" "#include Esys/syscall.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int page_size;\n" "\\&\n" "static void *\n" "fault_handler_thread(void *arg)\n" "{\n" " long uffd; /* userfaultfd file descriptor */\n" "\\&\n" " static int fault_cnt = 0; /* Number of faults so far handled */\n" " static char *page = NULL;\n" " static struct uffd_msg msg; /* Data read from userfaultfd */\n" "\\&\n" " uffd = (long) arg;\n" "\\&\n" " /* Create a page that will be copied into the faulting region. */\n" "\\&\n" " if (page == NULL) {\n" " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (page == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" " }\n" "\\&\n" " /* Loop, handling incoming events on the userfaultfd\n" " file descriptor. */\n" "\\&\n" " for (;;) {\n" " int nready;\n" " ssize_t nread;\n" " struct pollfd pollfd;\n" " struct uffdio_copy uffdio_copy;\n" "\\&\n" " /* See what poll() tells us about the userfaultfd. */\n" "\\&\n" " pollfd.fd = uffd;\n" " pollfd.events = POLLIN;\n" " nready = poll(&pollfd, 1, -1);\n" " if (nready == -1)\n" " err(EXIT_FAILURE, \"poll\");\n" "\\&\n" " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n" " printf(\" poll() returns: nready = %d; \"\n" " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n" " (pollfd.revents & POLLIN) != 0,\n" " (pollfd.revents & POLLERR) != 0);\n" "\\&\n" " /* Read an event from the userfaultfd. */\n" "\\&\n" " nread = read(uffd, &msg, sizeof(msg));\n" " if (nread == 0) {\n" " printf(\"EOF on userfaultfd!\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " if (nread == -1)\n" " err(EXIT_FAILURE, \"read\");\n" "\\&\n" " /* We expect only one kind of event; verify that assumption. */\n" "\\&\n" " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n" " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " /* Display info about the page-fault event. */\n" "\\&\n" " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n" " printf(\"flags = %w64x; \", msg.arg.pagefault.flags);\n" " printf(\"address = %w64x\\[rs]n\", msg.arg.pagefault.address);\n" "\\&\n" " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n" " region. Vary the contents that are copied in, so that it\n" " is more obvious that each fault is handled separately. */\n" "\\&\n" " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n" " fault_cnt++;\n" "\\&\n" " uffdio_copy.src = (unsigned long) page;\n" "\\&\n" " /* We need to handle page faults in units of pages(!).\n" " So, round faulting address down to page boundary. */\n" "\\&\n" " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n" " \\[ti](page_size - 1);\n" " uffdio_copy.len = page_size;\n" " uffdio_copy.mode = 0;\n" " uffdio_copy.copy = 0;\n" " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n" "\\&\n" " printf(\" (uffdio_copy.copy returned %w64d)\\[rs]n\",\n" " uffdio_copy.copy);\n" " }\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s;\n" " char *addr; /* Start of region handled by userfaultfd */\n" " long uffd; /* userfaultfd file descriptor */\n" " size_t size, i; /* Size of region handled by userfaultfd */\n" " pthread_t thr; /* ID of thread that handles page faults */\n" " struct uffdio_api uffdio_api;\n" " struct uffdio_register uffdio_register;\n" "\\&\n" " if (argc != 2) {\n" " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " page_size = sysconf(_SC_PAGE_SIZE);\n" " size = strtoull(argv[1], NULL, 0) * page_size;\n" "\\&\n" " /* Create and enable userfaultfd object. */\n" "\\&\n" " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n" " if (uffd == -1)\n" " err(EXIT_FAILURE, \"userfaultfd\");\n" "\\&\n" " /* NOTE: Two-step feature handshake is not needed here, since this\n" " example doesn't require any specific features.\n" "\\&\n" " Programs that *do* should call UFFDIO_API twice: once with\n" " `features = 0` to detect features supported by this kernel, and\n" " again with the subset of features the program actually wants to\n" " enable. */\n" " uffdio_api.api = UFFD_API;\n" " uffdio_api.features = 0;\n" " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n" "\\&\n" " /* Create a private anonymous mapping. The memory will be\n" " demand-zero paged--that is, not yet allocated. When we\n" " actually touch the memory, it will be allocated via\n" " the userfaultfd. */\n" "\\&\n" " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (addr == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" "\\&\n" " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n" "\\&\n" " /* Register the memory range of the mapping we just created for\n" " handling by the userfaultfd object. In mode, we request to track\n" " missing pages (i.e., pages that have not yet been faulted in). */\n" "\\&\n" " uffdio_register.range.start = (unsigned long) addr;\n" " uffdio_register.range.len = size;\n" " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n" " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n" "\\&\n" " /* Create a thread that will process the userfaultfd events. */\n" "\\&\n" " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n" " if (s != 0) {\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Main thread now touches memory in the mapping, touching\n" " locations 1024 bytes apart. This will trigger userfaultfd\n" " events for all pages in the region. */\n" "\\&\n" " i = 0xf; /* Ensure that faulting address is not on a page\n" " boundary, in order to test that we correctly\n" " handle that case in fault_handling_thread(). */\n" " while (i E size) {\n" " char c;\n" "\\&\n" " c = addr[i];\n" " printf(\"Read address %p in %s(): \", addr + i, __func__);\n" " printf(\"%c\\[rs]n\", c);\n" " i += 1024;\n" " usleep(100000); /* Slow things down a little */\n" " }\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" "/* userfaultfd_demo.c\n" "\\&\n" " Licensed under the GNU General Public License version 2 or later.\n" "*/\n" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Efcntl.hE\n" "#include Einttypes.hE\n" "#include Elinux/userfaultfd.hE\n" "#include Epoll.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/ioctl.hE\n" "#include Esys/mman.hE\n" "#include Esys/syscall.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int page_size;\n" "\\&\n" "static void *\n" "fault_handler_thread(void *arg)\n" "{\n" " long uffd; /* userfaultfd file descriptor */\n" "\\&\n" " static int fault_cnt = 0; /* Number of faults so far handled */\n" " static char *page = NULL;\n" " static struct uffd_msg msg; /* Data read from userfaultfd */\n" "\\&\n" " uffd = (long) arg;\n" "\\&\n" " /* Create a page that will be copied into the faulting region. */\n" "\\&\n" " if (page == NULL) {\n" " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (page == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" " }\n" "\\&\n" " /* Loop, handling incoming events on the userfaultfd\n" " file descriptor. */\n" "\\&\n" " for (;;) {\n" " int nready;\n" " ssize_t nread;\n" " struct pollfd pollfd;\n" " struct uffdio_copy uffdio_copy;\n" "\\&\n" " /* See what poll() tells us about the userfaultfd. */\n" "\\&\n" " pollfd.fd = uffd;\n" " pollfd.events = POLLIN;\n" " nready = poll(&pollfd, 1, -1);\n" " if (nready == -1)\n" " err(EXIT_FAILURE, \"poll\");\n" "\\&\n" " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n" " printf(\" poll() returns: nready = %d; \"\n" " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n" " (pollfd.revents & POLLIN) != 0,\n" " (pollfd.revents & POLLERR) != 0);\n" "\\&\n" " /* Read an event from the userfaultfd. */\n" "\\&\n" " nread = read(uffd, &msg, sizeof(msg));\n" " if (nread == 0) {\n" " printf(\"EOF on userfaultfd!\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " if (nread == -1)\n" " err(EXIT_FAILURE, \"read\");\n" "\\&\n" " /* We expect only one kind of event; verify that assumption. */\n" "\\&\n" " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n" " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " /* Display info about the page-fault event. */\n" "\\&\n" " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n" " printf(\"flags = %w64x; \", msg.arg.pagefault.flags);\n" " printf(\"address = %w64x\\[rs]n\", msg.arg.pagefault.address);\n" "\\&\n" " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n" " region. Vary the contents that are copied in, so that it\n" " is more obvious that each fault is handled separately. */\n" "\\&\n" " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n" " fault_cnt++;\n" "\\&\n" " uffdio_copy.src = (unsigned long) page;\n" "\\&\n" " /* We need to handle page faults in units of pages(!).\n" " So, round faulting address down to page boundary. */\n" "\\&\n" " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n" " \\[ti](page_size - 1);\n" " uffdio_copy.len = page_size;\n" " uffdio_copy.mode = 0;\n" " uffdio_copy.copy = 0;\n" " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n" "\\&\n" " printf(\" (uffdio_copy.copy returned %w64d)\\[rs]n\",\n" " uffdio_copy.copy);\n" " }\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s;\n" " char *addr; /* Start of region handled by userfaultfd */\n" " long uffd; /* userfaultfd file descriptor */\n" " size_t size, i; /* Size of region handled by userfaultfd */\n" " pthread_t thr; /* ID of thread that handles page faults */\n" " struct uffdio_api uffdio_api;\n" " struct uffdio_register uffdio_register;\n" "\\&\n" " if (argc != 2) {\n" " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " page_size = sysconf(_SC_PAGE_SIZE);\n" " size = strtoull(argv[1], NULL, 0) * page_size;\n" "\\&\n" " /* Create and enable userfaultfd object. */\n" "\\&\n" " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n" " if (uffd == -1)\n" " err(EXIT_FAILURE, \"userfaultfd\");\n" "\\&\n" " /* NOTE: Two-step feature handshake is not needed here, since this\n" " example doesn't require any specific features.\n" "\\&\n" " Programs that *do* should call UFFDIO_API twice: once with\n" " `features = 0` to detect features supported by this kernel, and\n" " again with the subset of features the program actually wants to\n" " enable. */\n" " uffdio_api.api = UFFD_API;\n" " uffdio_api.features = 0;\n" " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n" "\\&\n" " /* Create a private anonymous mapping. The memory will be\n" " demand-zero paged--that is, not yet allocated. When we\n" " actually touch the memory, it will be allocated via\n" " the userfaultfd. */\n" "\\&\n" " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (addr == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" "\\&\n" " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n" "\\&\n" " /* Register the memory range of the mapping we just created for\n" " handling by the userfaultfd object. In mode, we request to track\n" " missing pages (i.e., pages that have not yet been faulted in). */\n" "\\&\n" " uffdio_register.range.start = (unsigned long) addr;\n" " uffdio_register.range.len = size;\n" " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n" " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n" "\\&\n" " /* Create a thread that will process the userfaultfd events. */\n" "\\&\n" " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n" " if (s != 0) {\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Main thread now touches memory in the mapping, touching\n" " locations 1024 bytes apart. This will trigger userfaultfd\n" " events for all pages in the region. */\n" "\\&\n" " i = 0xf; /* Ensure that faulting address is not on a page\n" " boundary, in order to test that we correctly\n" " handle that case in fault_handling_thread(). */\n" " while (i E size) {\n" " char c;\n" "\\&\n" " c = addr[i];\n" " printf(\"Read address %p in %s(): \", addr + i, __func__);\n" " printf(\"%c\\[rs]n\", c);\n" " i += 1024;\n" " usleep(100000); /* Slow things down a little */\n" " }\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" #. SRC END #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "SEE ALSO" msgstr "انظر أيضًا" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "B(2), B(2), B(2), B(2), B(2)" msgstr "" "B(2), B(2), B(2), B(2), B(2)" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "I in the Linux kernel source " "tree" msgstr "" "الملف I في شجرة مصدر نواة لينكس" #. type: TH #: debian-trixie #, no-wrap msgid "2024-06-15" msgstr "15 يونيو 2024" #. type: TH #: debian-trixie #, no-wrap msgid "Linux man-pages 6.9.1" msgstr "صفحات دليل لينكس 6.9.1" #. type: Plain text #: debian-trixie msgid "Standard C library (I, I<-lc>)" msgstr "مكتبة سي المعيارية (I، I<-lc>)" #. type: Plain text #: debian-trixie #, no-wrap msgid "" "struct uffd_msg {\n" " __u8 event; /* Type of event */\n" " ...\n" " union {\n" " struct {\n" " __u64 flags; /* Flags describing fault */\n" " __u64 address; /* Faulting address */\n" " union {\n" " __u32 ptid; /* Thread ID of the fault */\n" " } feat;\n" " } pagefault;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u32 ufd; /* Userfault file descriptor\n" " of the child process */\n" " } fork;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u64 from; /* Old address of remapped area */\n" " __u64 to; /* New address of remapped area */\n" " __u64 len; /* Original mapping length */\n" " } remap;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u64 start; /* Start address of removed area */\n" " __u64 end; /* End address of removed area */\n" " } remove;\n" " ...\n" " } arg;\n" "\\&\n" " /* Padding fields omitted */\n" "} __packed;\n" msgstr "" "struct uffd_msg {\n" " __u8 event; /* Type of event */\n" " ...\n" " union {\n" " struct {\n" " __u64 flags; /* Flags describing fault */\n" " __u64 address; /* Faulting address */\n" " union {\n" " __u32 ptid; /* Thread ID of the fault */\n" " } feat;\n" " } pagefault;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u32 ufd; /* Userfault file descriptor\n" " of the child process */\n" " } fork;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u64 from; /* Old address of remapped area */\n" " __u64 to; /* New address of remapped area */\n" " __u64 len; /* Original mapping length */\n" " } remap;\n" "\\&\n" " struct { /* Since Linux 4.11 */\n" " __u64 start; /* Start address of removed area */\n" " __u64 end; /* End address of removed area */\n" " } remove;\n" " ...\n" " } arg;\n" "\\&\n" " /* Padding fields omitted */\n" "} __packed;\n" #. type: Plain text #: debian-trixie msgid "" "The original length of the memory range that was remapped using B(2)." msgstr "الطول الأصلي لنطاق الذاكرة الذي أُعيد تعيينه باستخدام B(2)." #. type: Plain text #: debian-trixie fedora-44 fedora-rawhide #, no-wrap msgid "" "$ B<./userfaultfd_demo 3>\n" "Address returned by mmap() = 0x7fd30106c000\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106c00f in main(): A\n" "Read address 0x7fd30106c40f in main(): A\n" "Read address 0x7fd30106c80f in main(): A\n" "Read address 0x7fd30106cc0f in main(): A\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106d00f in main(): B\n" "Read address 0x7fd30106d40f in main(): B\n" "Read address 0x7fd30106d80f in main(): B\n" "Read address 0x7fd30106dc0f in main(): B\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106e00f in main(): C\n" "Read address 0x7fd30106e40f in main(): C\n" "Read address 0x7fd30106e80f in main(): C\n" "Read address 0x7fd30106ec0f in main(): C\n" msgstr "" "$ B<./userfaultfd_demo 3>\n" "Address returned by mmap() = 0x7fd30106c000\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106c00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106c00f in main(): A\n" "Read address 0x7fd30106c40f in main(): A\n" "Read address 0x7fd30106c80f in main(): A\n" "Read address 0x7fd30106cc0f in main(): A\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106d00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106d00f in main(): B\n" "Read address 0x7fd30106d40f in main(): B\n" "Read address 0x7fd30106d80f in main(): B\n" "Read address 0x7fd30106dc0f in main(): B\n" "\\&\n" "fault_handler_thread():\n" " poll() returns: nready = 1; POLLIN = 1; POLLERR = 0\n" " UFFD_EVENT_PAGEFAULT event: flags = 0; address = 7fd30106e00f\n" " (uffdio_copy.copy returned 4096)\n" "Read address 0x7fd30106e00f in main(): C\n" "Read address 0x7fd30106e40f in main(): C\n" "Read address 0x7fd30106e80f in main(): C\n" "Read address 0x7fd30106ec0f in main(): C\n" #. type: Plain text #: debian-trixie #, no-wrap msgid "" "/* userfaultfd_demo.c\n" "\\&\n" " Licensed under the GNU General Public License version 2 or later.\n" "*/\n" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Efcntl.hE\n" "#include Einttypes.hE\n" "#include Elinux/userfaultfd.hE\n" "#include Epoll.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/ioctl.hE\n" "#include Esys/mman.hE\n" "#include Esys/syscall.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int page_size;\n" "\\&\n" "static void *\n" "fault_handler_thread(void *arg)\n" "{\n" " int nready;\n" " long uffd; /* userfaultfd file descriptor */\n" " ssize_t nread;\n" " struct pollfd pollfd;\n" " struct uffdio_copy uffdio_copy;\n" "\\&\n" " static int fault_cnt = 0; /* Number of faults so far handled */\n" " static char *page = NULL;\n" " static struct uffd_msg msg; /* Data read from userfaultfd */\n" "\\&\n" " uffd = (long) arg;\n" "\\&\n" " /* Create a page that will be copied into the faulting region. */\n" "\\&\n" " if (page == NULL) {\n" " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (page == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" " }\n" "\\&\n" " /* Loop, handling incoming events on the userfaultfd\n" " file descriptor. */\n" "\\&\n" " for (;;) {\n" "\\&\n" " /* See what poll() tells us about the userfaultfd. */\n" "\\&\n" " pollfd.fd = uffd;\n" " pollfd.events = POLLIN;\n" " nready = poll(&pollfd, 1, -1);\n" " if (nready == -1)\n" " err(EXIT_FAILURE, \"poll\");\n" "\\&\n" " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n" " printf(\" poll() returns: nready = %d; \"\n" " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n" " (pollfd.revents & POLLIN) != 0,\n" " (pollfd.revents & POLLERR) != 0);\n" "\\&\n" " /* Read an event from the userfaultfd. */\n" "\\&\n" " nread = read(uffd, &msg, sizeof(msg));\n" " if (nread == 0) {\n" " printf(\"EOF on userfaultfd!\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " if (nread == -1)\n" " err(EXIT_FAILURE, \"read\");\n" "\\&\n" " /* We expect only one kind of event; verify that assumption. */\n" "\\&\n" " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n" " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " /* Display info about the page-fault event. */\n" "\\&\n" " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n" " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n" " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n" "\\&\n" " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n" " region. Vary the contents that are copied in, so that it\n" " is more obvious that each fault is handled separately. */\n" "\\&\n" " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n" " fault_cnt++;\n" "\\&\n" " uffdio_copy.src = (unsigned long) page;\n" "\\&\n" " /* We need to handle page faults in units of pages(!).\n" " So, round faulting address down to page boundary. */\n" "\\&\n" " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n" " \\[ti](page_size - 1);\n" " uffdio_copy.len = page_size;\n" " uffdio_copy.mode = 0;\n" " uffdio_copy.copy = 0;\n" " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n" "\\&\n" " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n" " uffdio_copy.copy);\n" " }\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s;\n" " char c;\n" " char *addr; /* Start of region handled by userfaultfd */\n" " long uffd; /* userfaultfd file descriptor */\n" " size_t len, l; /* Length of region handled by userfaultfd */\n" " pthread_t thr; /* ID of thread that handles page faults */\n" " struct uffdio_api uffdio_api;\n" " struct uffdio_register uffdio_register;\n" "\\&\n" " if (argc != 2) {\n" " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " page_size = sysconf(_SC_PAGE_SIZE);\n" " len = strtoull(argv[1], NULL, 0) * page_size;\n" "\\&\n" " /* Create and enable userfaultfd object. */\n" "\\&\n" " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n" " if (uffd == -1)\n" " err(EXIT_FAILURE, \"userfaultfd\");\n" "\\&\n" " /* NOTE: Two-step feature handshake is not needed here, since this\n" " example doesn't require any specific features.\n" "\\&\n" " Programs that *do* should call UFFDIO_API twice: once with\n" " `features = 0` to detect features supported by this kernel, and\n" " again with the subset of features the program actually wants to\n" " enable. */\n" " uffdio_api.api = UFFD_API;\n" " uffdio_api.features = 0;\n" " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n" "\\&\n" " /* Create a private anonymous mapping. The memory will be\n" " demand-zero paged--that is, not yet allocated. When we\n" " actually touch the memory, it will be allocated via\n" " the userfaultfd. */\n" "\\&\n" " addr = mmap(NULL, len, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (addr == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" "\\&\n" " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n" "\\&\n" " /* Register the memory range of the mapping we just created for\n" " handling by the userfaultfd object. In mode, we request to track\n" " missing pages (i.e., pages that have not yet been faulted in). */\n" "\\&\n" " uffdio_register.range.start = (unsigned long) addr;\n" " uffdio_register.range.len = len;\n" " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n" " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n" "\\&\n" " /* Create a thread that will process the userfaultfd events. */\n" "\\&\n" " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n" " if (s != 0) {\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Main thread now touches memory in the mapping, touching\n" " locations 1024 bytes apart. This will trigger userfaultfd\n" " events for all pages in the region. */\n" "\\&\n" " l = 0xf; /* Ensure that faulting address is not on a page\n" " boundary, in order to test that we correctly\n" " handle that case in fault_handling_thread(). */\n" " while (l E len) {\n" " c = addr[l];\n" " printf(\"Read address %p in %s(): \", addr + l, __func__);\n" " printf(\"%c\\[rs]n\", c);\n" " l += 1024;\n" " usleep(100000); /* Slow things down a little */\n" " }\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" "/* userfaultfd_demo.c\n" "\\&\n" " Licensed under the GNU General Public License version 2 or later.\n" "*/\n" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Efcntl.hE\n" "#include Einttypes.hE\n" "#include Elinux/userfaultfd.hE\n" "#include Epoll.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/ioctl.hE\n" "#include Esys/mman.hE\n" "#include Esys/syscall.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int page_size;\n" "\\&\n" "static void *\n" "fault_handler_thread(void *arg)\n" "{\n" " int nready;\n" " long uffd; /* userfaultfd file descriptor */\n" " ssize_t nread;\n" " struct pollfd pollfd;\n" " struct uffdio_copy uffdio_copy;\n" "\\&\n" " static int fault_cnt = 0; /* Number of faults so far handled */\n" " static char *page = NULL;\n" " static struct uffd_msg msg; /* Data read from userfaultfd */\n" "\\&\n" " uffd = (long) arg;\n" "\\&\n" " /* Create a page that will be copied into the faulting region. */\n" "\\&\n" " if (page == NULL) {\n" " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (page == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" " }\n" "\\&\n" " /* Loop, handling incoming events on the userfaultfd\n" " file descriptor. */\n" "\\&\n" " for (;;) {\n" "\\&\n" " /* See what poll() tells us about the userfaultfd. */\n" "\\&\n" " pollfd.fd = uffd;\n" " pollfd.events = POLLIN;\n" " nready = poll(&pollfd, 1, -1);\n" " if (nready == -1)\n" " err(EXIT_FAILURE, \"poll\");\n" "\\&\n" " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n" " printf(\" poll() returns: nready = %d; \"\n" " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n" " (pollfd.revents & POLLIN) != 0,\n" " (pollfd.revents & POLLERR) != 0);\n" "\\&\n" " /* Read an event from the userfaultfd. */\n" "\\&\n" " nread = read(uffd, &msg, sizeof(msg));\n" " if (nread == 0) {\n" " printf(\"EOF on userfaultfd!\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " if (nread == -1)\n" " err(EXIT_FAILURE, \"read\");\n" "\\&\n" " /* We expect only one kind of event; verify that assumption. */\n" "\\&\n" " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n" " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " /* Display info about the page-fault event. */\n" "\\&\n" " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n" " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n" " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n" "\\&\n" " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n" " region. Vary the contents that are copied in, so that it\n" " is more obvious that each fault is handled separately. */\n" "\\&\n" " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n" " fault_cnt++;\n" "\\&\n" " uffdio_copy.src = (unsigned long) page;\n" "\\&\n" " /* We need to handle page faults in units of pages(!).\n" " So, round faulting address down to page boundary. */\n" "\\&\n" " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n" " \\[ti](page_size - 1);\n" " uffdio_copy.len = page_size;\n" " uffdio_copy.mode = 0;\n" " uffdio_copy.copy = 0;\n" " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n" "\\&\n" " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n" " uffdio_copy.copy);\n" " }\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s;\n" " char c;\n" " char *addr; /* Start of region handled by userfaultfd */\n" " long uffd; /* userfaultfd file descriptor */\n" " size_t len, l; /* Length of region handled by userfaultfd */\n" " pthread_t thr; /* ID of thread that handles page faults */\n" " struct uffdio_api uffdio_api;\n" " struct uffdio_register uffdio_register;\n" "\\&\n" " if (argc != 2) {\n" " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " page_size = sysconf(_SC_PAGE_SIZE);\n" " len = strtoull(argv[1], NULL, 0) * page_size;\n" "\\&\n" " /* Create and enable userfaultfd object. */\n" "\\&\n" " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n" " if (uffd == -1)\n" " err(EXIT_FAILURE, \"userfaultfd\");\n" "\\&\n" " /* NOTE: Two-step feature handshake is not needed here, since this\n" " example doesn't require any specific features.\n" "\\&\n" " Programs that *do* should call UFFDIO_API twice: once with\n" " `features = 0` to detect features supported by this kernel, and\n" " again with the subset of features the program actually wants to\n" " enable. */\n" " uffdio_api.api = UFFD_API;\n" " uffdio_api.features = 0;\n" " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n" "\\&\n" " /* Create a private anonymous mapping. The memory will be\n" " demand-zero paged--that is, not yet allocated. When we\n" " actually touch the memory, it will be allocated via\n" " the userfaultfd. */\n" "\\&\n" " addr = mmap(NULL, len, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (addr == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" "\\&\n" " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n" "\\&\n" " /* Register the memory range of the mapping we just created for\n" " handling by the userfaultfd object. In mode, we request to track\n" " missing pages (i.e., pages that have not yet been faulted in). */\n" "\\&\n" " uffdio_register.range.start = (unsigned long) addr;\n" " uffdio_register.range.len = len;\n" " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n" " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n" "\\&\n" " /* Create a thread that will process the userfaultfd events. */\n" "\\&\n" " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n" " if (s != 0) {\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Main thread now touches memory in the mapping, touching\n" " locations 1024 bytes apart. This will trigger userfaultfd\n" " events for all pages in the region. */\n" "\\&\n" " l = 0xf; /* Ensure that faulting address is not on a page\n" " boundary, in order to test that we correctly\n" " handle that case in fault_handling_thread(). */\n" " while (l E len) {\n" " c = addr[l];\n" " printf(\"Read address %p in %s(): \", addr + l, __func__);\n" " printf(\"%c\\[rs]n\", c);\n" " l += 1024;\n" " usleep(100000); /* Slow things down a little */\n" " }\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" #. type: TH #: fedora-44 fedora-rawhide #, no-wrap msgid "2024-11-17" msgstr "17 نوفمبر 2024" #. type: TH #: fedora-44 fedora-rawhide #, no-wrap msgid "Linux man-pages 6.13" msgstr "صفحات دليل لينكس 6.13" #. type: Plain text #: fedora-44 fedora-rawhide #, no-wrap msgid "" "/* userfaultfd_demo.c\n" "\\&\n" " Licensed under the GNU General Public License version 2 or later.\n" "*/\n" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Efcntl.hE\n" "#include Einttypes.hE\n" "#include Elinux/userfaultfd.hE\n" "#include Epoll.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/ioctl.hE\n" "#include Esys/mman.hE\n" "#include Esys/syscall.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int page_size;\n" "\\&\n" "static void *\n" "fault_handler_thread(void *arg)\n" "{\n" " int nready;\n" " long uffd; /* userfaultfd file descriptor */\n" " ssize_t nread;\n" " struct pollfd pollfd;\n" " struct uffdio_copy uffdio_copy;\n" "\\&\n" " static int fault_cnt = 0; /* Number of faults so far handled */\n" " static char *page = NULL;\n" " static struct uffd_msg msg; /* Data read from userfaultfd */\n" "\\&\n" " uffd = (long) arg;\n" "\\&\n" " /* Create a page that will be copied into the faulting region. */\n" "\\&\n" " if (page == NULL) {\n" " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (page == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" " }\n" "\\&\n" " /* Loop, handling incoming events on the userfaultfd\n" " file descriptor. */\n" "\\&\n" " for (;;) {\n" "\\&\n" " /* See what poll() tells us about the userfaultfd. */\n" "\\&\n" " pollfd.fd = uffd;\n" " pollfd.events = POLLIN;\n" " nready = poll(&pollfd, 1, -1);\n" " if (nready == -1)\n" " err(EXIT_FAILURE, \"poll\");\n" "\\&\n" " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n" " printf(\" poll() returns: nready = %d; \"\n" " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n" " (pollfd.revents & POLLIN) != 0,\n" " (pollfd.revents & POLLERR) != 0);\n" "\\&\n" " /* Read an event from the userfaultfd. */\n" "\\&\n" " nread = read(uffd, &msg, sizeof(msg));\n" " if (nread == 0) {\n" " printf(\"EOF on userfaultfd!\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " if (nread == -1)\n" " err(EXIT_FAILURE, \"read\");\n" "\\&\n" " /* We expect only one kind of event; verify that assumption. */\n" "\\&\n" " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n" " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " /* Display info about the page-fault event. */\n" "\\&\n" " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n" " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n" " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n" "\\&\n" " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n" " region. Vary the contents that are copied in, so that it\n" " is more obvious that each fault is handled separately. */\n" "\\&\n" " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n" " fault_cnt++;\n" "\\&\n" " uffdio_copy.src = (unsigned long) page;\n" "\\&\n" " /* We need to handle page faults in units of pages(!).\n" " So, round faulting address down to page boundary. */\n" "\\&\n" " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n" " \\[ti](page_size - 1);\n" " uffdio_copy.len = page_size;\n" " uffdio_copy.mode = 0;\n" " uffdio_copy.copy = 0;\n" " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n" "\\&\n" " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n" " uffdio_copy.copy);\n" " }\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s;\n" " char c;\n" " char *addr; /* Start of region handled by userfaultfd */\n" " long uffd; /* userfaultfd file descriptor */\n" " size_t size, i; /* Size of region handled by userfaultfd */\n" " pthread_t thr; /* ID of thread that handles page faults */\n" " struct uffdio_api uffdio_api;\n" " struct uffdio_register uffdio_register;\n" "\\&\n" " if (argc != 2) {\n" " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " page_size = sysconf(_SC_PAGE_SIZE);\n" " size = strtoull(argv[1], NULL, 0) * page_size;\n" "\\&\n" " /* Create and enable userfaultfd object. */\n" "\\&\n" " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n" " if (uffd == -1)\n" " err(EXIT_FAILURE, \"userfaultfd\");\n" "\\&\n" " /* NOTE: Two-step feature handshake is not needed here, since this\n" " example doesn't require any specific features.\n" "\\&\n" " Programs that *do* should call UFFDIO_API twice: once with\n" " `features = 0` to detect features supported by this kernel, and\n" " again with the subset of features the program actually wants to\n" " enable. */\n" " uffdio_api.api = UFFD_API;\n" " uffdio_api.features = 0;\n" " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n" "\\&\n" " /* Create a private anonymous mapping. The memory will be\n" " demand-zero paged--that is, not yet allocated. When we\n" " actually touch the memory, it will be allocated via\n" " the userfaultfd. */\n" "\\&\n" " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (addr == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" "\\&\n" " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n" "\\&\n" " /* Register the memory range of the mapping we just created for\n" " handling by the userfaultfd object. In mode, we request to track\n" " missing pages (i.e., pages that have not yet been faulted in). */\n" "\\&\n" " uffdio_register.range.start = (unsigned long) addr;\n" " uffdio_register.range.len = size;\n" " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n" " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n" "\\&\n" " /* Create a thread that will process the userfaultfd events. */\n" "\\&\n" " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n" " if (s != 0) {\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Main thread now touches memory in the mapping, touching\n" " locations 1024 bytes apart. This will trigger userfaultfd\n" " events for all pages in the region. */\n" "\\&\n" " i = 0xf; /* Ensure that faulting address is not on a page\n" " boundary, in order to test that we correctly\n" " handle that case in fault_handling_thread(). */\n" " while (i E size) {\n" " c = addr[i];\n" " printf(\"Read address %p in %s(): \", addr + i, __func__);\n" " printf(\"%c\\[rs]n\", c);\n" " i += 1024;\n" " usleep(100000); /* Slow things down a little */\n" " }\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" "/* userfaultfd_demo.c\n" "\\&\n" " Licensed under the GNU General Public License version 2 or later.\n" "*/\n" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Efcntl.hE\n" "#include Einttypes.hE\n" "#include Elinux/userfaultfd.hE\n" "#include Epoll.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/ioctl.hE\n" "#include Esys/mman.hE\n" "#include Esys/syscall.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int page_size;\n" "\\&\n" "static void *\n" "fault_handler_thread(void *arg)\n" "{\n" " int nready;\n" " long uffd; /* userfaultfd file descriptor */\n" " ssize_t nread;\n" " struct pollfd pollfd;\n" " struct uffdio_copy uffdio_copy;\n" "\\&\n" " static int fault_cnt = 0; /* Number of faults so far handled */\n" " static char *page = NULL;\n" " static struct uffd_msg msg; /* Data read from userfaultfd */\n" "\\&\n" " uffd = (long) arg;\n" "\\&\n" " /* Create a page that will be copied into the faulting region. */\n" "\\&\n" " if (page == NULL) {\n" " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (page == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" " }\n" "\\&\n" " /* Loop, handling incoming events on the userfaultfd\n" " file descriptor. */\n" "\\&\n" " for (;;) {\n" "\\&\n" " /* See what poll() tells us about the userfaultfd. */\n" "\\&\n" " pollfd.fd = uffd;\n" " pollfd.events = POLLIN;\n" " nready = poll(&pollfd, 1, -1);\n" " if (nready == -1)\n" " err(EXIT_FAILURE, \"poll\");\n" "\\&\n" " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n" " printf(\" poll() returns: nready = %d; \"\n" " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n" " (pollfd.revents & POLLIN) != 0,\n" " (pollfd.revents & POLLERR) != 0);\n" "\\&\n" " /* Read an event from the userfaultfd. */\n" "\\&\n" " nread = read(uffd, &msg, sizeof(msg));\n" " if (nread == 0) {\n" " printf(\"EOF on userfaultfd!\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " if (nread == -1)\n" " err(EXIT_FAILURE, \"read\");\n" "\\&\n" " /* We expect only one kind of event; verify that assumption. */\n" "\\&\n" " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n" " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " /* Display info about the page-fault event. */\n" "\\&\n" " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n" " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n" " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n" "\\&\n" " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n" " region. Vary the contents that are copied in, so that it\n" " is more obvious that each fault is handled separately. */\n" "\\&\n" " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n" " fault_cnt++;\n" "\\&\n" " uffdio_copy.src = (unsigned long) page;\n" "\\&\n" " /* We need to handle page faults in units of pages(!).\n" " So, round faulting address down to page boundary. */\n" "\\&\n" " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n" " \\[ti](page_size - 1);\n" " uffdio_copy.len = page_size;\n" " uffdio_copy.mode = 0;\n" " uffdio_copy.copy = 0;\n" " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n" "\\&\n" " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n" " uffdio_copy.copy);\n" " }\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s;\n" " char c;\n" " char *addr; /* Start of region handled by userfaultfd */\n" " long uffd; /* userfaultfd file descriptor */\n" " size_t size, i; /* Size of region handled by userfaultfd */\n" " pthread_t thr; /* ID of thread that handles page faults */\n" " struct uffdio_api uffdio_api;\n" " struct uffdio_register uffdio_register;\n" "\\&\n" " if (argc != 2) {\n" " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " page_size = sysconf(_SC_PAGE_SIZE);\n" " size = strtoull(argv[1], NULL, 0) * page_size;\n" "\\&\n" " /* Create and enable userfaultfd object. */\n" "\\&\n" " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n" " if (uffd == -1)\n" " err(EXIT_FAILURE, \"userfaultfd\");\n" "\\&\n" " /* NOTE: Two-step feature handshake is not needed here, since this\n" " example doesn't require any specific features.\n" "\\&\n" " Programs that *do* should call UFFDIO_API twice: once with\n" " `features = 0` to detect features supported by this kernel, and\n" " again with the subset of features the program actually wants to\n" " enable. */\n" " uffdio_api.api = UFFD_API;\n" " uffdio_api.features = 0;\n" " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n" "\\&\n" " /* Create a private anonymous mapping. The memory will be\n" " demand-zero paged--that is, not yet allocated. When we\n" " actually touch the memory, it will be allocated via\n" " the userfaultfd. */\n" "\\&\n" " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (addr == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" "\\&\n" " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n" "\\&\n" " /* Register the memory range of the mapping we just created for\n" " handling by the userfaultfd object. In mode, we request to track\n" " missing pages (i.e., pages that have not yet been faulted in). */\n" "\\&\n" " uffdio_register.range.start = (unsigned long) addr;\n" " uffdio_register.range.len = size;\n" " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n" " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n" "\\&\n" " /* Create a thread that will process the userfaultfd events. */\n" "\\&\n" " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n" " if (s != 0) {\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Main thread now touches memory in the mapping, touching\n" " locations 1024 bytes apart. This will trigger userfaultfd\n" " events for all pages in the region. */\n" "\\&\n" " i = 0xf; /* Ensure that faulting address is not on a page\n" " boundary, in order to test that we correctly\n" " handle that case in fault_handling_thread(). */\n" " while (i E size) {\n" " c = addr[i];\n" " printf(\"Read address %p in %s(): \", addr + i, __func__);\n" " printf(\"%c\\[rs]n\", c);\n" " i += 1024;\n" " usleep(100000); /* Slow things down a little */\n" " }\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" #. type: TH #: mageia-cauldron #, no-wrap msgid "2026-02-08" msgstr "8 فبراير 2026" #. type: TH #: mageia-cauldron #, no-wrap msgid "Linux man-pages 6.17" msgstr "صفحات دليل لينكس 6.17" #. type: Plain text #: mageia-cauldron #, no-wrap msgid "" "/* userfaultfd_demo.c\n" "\\&\n" " Licensed under the GNU General Public License version 2 or later.\n" "*/\n" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Efcntl.hE\n" "#include Einttypes.hE\n" "#include Elinux/userfaultfd.hE\n" "#include Epoll.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/ioctl.hE\n" "#include Esys/mman.hE\n" "#include Esys/syscall.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int page_size;\n" "\\&\n" "static void *\n" "fault_handler_thread(void *arg)\n" "{\n" " long uffd; /* userfaultfd file descriptor */\n" "\\&\n" " static int fault_cnt = 0; /* Number of faults so far handled */\n" " static char *page = NULL;\n" " static struct uffd_msg msg; /* Data read from userfaultfd */\n" "\\&\n" " uffd = (long) arg;\n" "\\&\n" " /* Create a page that will be copied into the faulting region. */\n" "\\&\n" " if (page == NULL) {\n" " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (page == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" " }\n" "\\&\n" " /* Loop, handling incoming events on the userfaultfd\n" " file descriptor. */\n" "\\&\n" " for (;;) {\n" " int nready;\n" " ssize_t nread;\n" " struct pollfd pollfd;\n" " struct uffdio_copy uffdio_copy;\n" "\\&\n" " /* See what poll() tells us about the userfaultfd. */\n" "\\&\n" " pollfd.fd = uffd;\n" " pollfd.events = POLLIN;\n" " nready = poll(&pollfd, 1, -1);\n" " if (nready == -1)\n" " err(EXIT_FAILURE, \"poll\");\n" "\\&\n" " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n" " printf(\" poll() returns: nready = %d; \"\n" " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n" " (pollfd.revents & POLLIN) != 0,\n" " (pollfd.revents & POLLERR) != 0);\n" "\\&\n" " /* Read an event from the userfaultfd. */\n" "\\&\n" " nread = read(uffd, &msg, sizeof(msg));\n" " if (nread == 0) {\n" " printf(\"EOF on userfaultfd!\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " if (nread == -1)\n" " err(EXIT_FAILURE, \"read\");\n" "\\&\n" " /* We expect only one kind of event; verify that assumption. */\n" "\\&\n" " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n" " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " /* Display info about the page-fault event. */\n" "\\&\n" " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n" " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n" " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n" "\\&\n" " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n" " region. Vary the contents that are copied in, so that it\n" " is more obvious that each fault is handled separately. */\n" "\\&\n" " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n" " fault_cnt++;\n" "\\&\n" " uffdio_copy.src = (unsigned long) page;\n" "\\&\n" " /* We need to handle page faults in units of pages(!).\n" " So, round faulting address down to page boundary. */\n" "\\&\n" " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n" " \\[ti](page_size - 1);\n" " uffdio_copy.len = page_size;\n" " uffdio_copy.mode = 0;\n" " uffdio_copy.copy = 0;\n" " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n" "\\&\n" " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n" " uffdio_copy.copy);\n" " }\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s;\n" " char *addr; /* Start of region handled by userfaultfd */\n" " long uffd; /* userfaultfd file descriptor */\n" " size_t size, i; /* Size of region handled by userfaultfd */\n" " pthread_t thr; /* ID of thread that handles page faults */\n" " struct uffdio_api uffdio_api;\n" " struct uffdio_register uffdio_register;\n" "\\&\n" " if (argc != 2) {\n" " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " page_size = sysconf(_SC_PAGE_SIZE);\n" " size = strtoull(argv[1], NULL, 0) * page_size;\n" "\\&\n" " /* Create and enable userfaultfd object. */\n" "\\&\n" " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n" " if (uffd == -1)\n" " err(EXIT_FAILURE, \"userfaultfd\");\n" "\\&\n" " /* NOTE: Two-step feature handshake is not needed here, since this\n" " example doesn't require any specific features.\n" "\\&\n" " Programs that *do* should call UFFDIO_API twice: once with\n" " `features = 0` to detect features supported by this kernel, and\n" " again with the subset of features the program actually wants to\n" " enable. */\n" " uffdio_api.api = UFFD_API;\n" " uffdio_api.features = 0;\n" " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n" "\\&\n" " /* Create a private anonymous mapping. The memory will be\n" " demand-zero paged--that is, not yet allocated. When we\n" " actually touch the memory, it will be allocated via\n" " the userfaultfd. */\n" "\\&\n" " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (addr == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" "\\&\n" " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n" "\\&\n" " /* Register the memory range of the mapping we just created for\n" " handling by the userfaultfd object. In mode, we request to track\n" " missing pages (i.e., pages that have not yet been faulted in). */\n" "\\&\n" " uffdio_register.range.start = (unsigned long) addr;\n" " uffdio_register.range.len = size;\n" " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n" " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n" "\\&\n" " /* Create a thread that will process the userfaultfd events. */\n" "\\&\n" " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n" " if (s != 0) {\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Main thread now touches memory in the mapping, touching\n" " locations 1024 bytes apart. This will trigger userfaultfd\n" " events for all pages in the region. */\n" "\\&\n" " i = 0xf; /* Ensure that faulting address is not on a page\n" " boundary, in order to test that we correctly\n" " handle that case in fault_handling_thread(). */\n" " while (i E size) {\n" " char c;\n" "\\&\n" " c = addr[i];\n" " printf(\"Read address %p in %s(): \", addr + i, __func__);\n" " printf(\"%c\\[rs]n\", c);\n" " i += 1024;\n" " usleep(100000); /* Slow things down a little */\n" " }\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" "/* userfaultfd_demo.c\n" "\\&\n" " Licensed under the GNU General Public License version 2 or later.\n" "*/\n" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Eerrno.hE\n" "#include Efcntl.hE\n" "#include Einttypes.hE\n" "#include Elinux/userfaultfd.hE\n" "#include Epoll.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/ioctl.hE\n" "#include Esys/mman.hE\n" "#include Esys/syscall.hE\n" "#include Eunistd.hE\n" "\\&\n" "static int page_size;\n" "\\&\n" "static void *\n" "fault_handler_thread(void *arg)\n" "{\n" " long uffd; /* userfaultfd file descriptor */\n" "\\&\n" " static int fault_cnt = 0; /* Number of faults so far handled */\n" " static char *page = NULL;\n" " static struct uffd_msg msg; /* Data read from userfaultfd */\n" "\\&\n" " uffd = (long) arg;\n" "\\&\n" " /* Create a page that will be copied into the faulting region. */\n" "\\&\n" " if (page == NULL) {\n" " page = mmap(NULL, page_size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (page == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" " }\n" "\\&\n" " /* Loop, handling incoming events on the userfaultfd\n" " file descriptor. */\n" "\\&\n" " for (;;) {\n" " int nready;\n" " ssize_t nread;\n" " struct pollfd pollfd;\n" " struct uffdio_copy uffdio_copy;\n" "\\&\n" " /* See what poll() tells us about the userfaultfd. */\n" "\\&\n" " pollfd.fd = uffd;\n" " pollfd.events = POLLIN;\n" " nready = poll(&pollfd, 1, -1);\n" " if (nready == -1)\n" " err(EXIT_FAILURE, \"poll\");\n" "\\&\n" " printf(\"\\[rs]nfault_handler_thread():\\[rs]n\");\n" " printf(\" poll() returns: nready = %d; \"\n" " \"POLLIN = %d; POLLERR = %d\\[rs]n\", nready,\n" " (pollfd.revents & POLLIN) != 0,\n" " (pollfd.revents & POLLERR) != 0);\n" "\\&\n" " /* Read an event from the userfaultfd. */\n" "\\&\n" " nread = read(uffd, &msg, sizeof(msg));\n" " if (nread == 0) {\n" " printf(\"EOF on userfaultfd!\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " if (nread == -1)\n" " err(EXIT_FAILURE, \"read\");\n" "\\&\n" " /* We expect only one kind of event; verify that assumption. */\n" "\\&\n" " if (msg.event != UFFD_EVENT_PAGEFAULT) {\n" " fprintf(stderr, \"Unexpected event on userfaultfd\\[rs]n\");\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " /* Display info about the page-fault event. */\n" "\\&\n" " printf(\" UFFD_EVENT_PAGEFAULT event: \");\n" " printf(\"flags = %\"PRIx64\"; \", msg.arg.pagefault.flags);\n" " printf(\"address = %\"PRIx64\"\\[rs]n\", msg.arg.pagefault.address);\n" "\\&\n" " /* Copy the page pointed to by \\[aq]page\\[aq] into the faulting\n" " region. Vary the contents that are copied in, so that it\n" " is more obvious that each fault is handled separately. */\n" "\\&\n" " memset(page, \\[aq]A\\[aq] + fault_cnt % 20, page_size);\n" " fault_cnt++;\n" "\\&\n" " uffdio_copy.src = (unsigned long) page;\n" "\\&\n" " /* We need to handle page faults in units of pages(!).\n" " So, round faulting address down to page boundary. */\n" "\\&\n" " uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address &\n" " \\[ti](page_size - 1);\n" " uffdio_copy.len = page_size;\n" " uffdio_copy.mode = 0;\n" " uffdio_copy.copy = 0;\n" " if (ioctl(uffd, UFFDIO_COPY, &uffdio_copy) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_COPY\");\n" "\\&\n" " printf(\" (uffdio_copy.copy returned %\"PRId64\")\\[rs]n\",\n" " uffdio_copy.copy);\n" " }\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s;\n" " char *addr; /* Start of region handled by userfaultfd */\n" " long uffd; /* userfaultfd file descriptor */\n" " size_t size, i; /* Size of region handled by userfaultfd */\n" " pthread_t thr; /* ID of thread that handles page faults */\n" " struct uffdio_api uffdio_api;\n" " struct uffdio_register uffdio_register;\n" "\\&\n" " if (argc != 2) {\n" " fprintf(stderr, \"Usage: %s num-pages\\[rs]n\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " page_size = sysconf(_SC_PAGE_SIZE);\n" " size = strtoull(argv[1], NULL, 0) * page_size;\n" "\\&\n" " /* Create and enable userfaultfd object. */\n" "\\&\n" " uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);\n" " if (uffd == -1)\n" " err(EXIT_FAILURE, \"userfaultfd\");\n" "\\&\n" " /* NOTE: Two-step feature handshake is not needed here, since this\n" " example doesn't require any specific features.\n" "\\&\n" " Programs that *do* should call UFFDIO_API twice: once with\n" " `features = 0` to detect features supported by this kernel, and\n" " again with the subset of features the program actually wants to\n" " enable. */\n" " uffdio_api.api = UFFD_API;\n" " uffdio_api.features = 0;\n" " if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_API\");\n" "\\&\n" " /* Create a private anonymous mapping. The memory will be\n" " demand-zero paged--that is, not yet allocated. When we\n" " actually touch the memory, it will be allocated via\n" " the userfaultfd. */\n" "\\&\n" " addr = mmap(NULL, size, PROT_READ | PROT_WRITE,\n" " MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n" " if (addr == MAP_FAILED)\n" " err(EXIT_FAILURE, \"mmap\");\n" "\\&\n" " printf(\"Address returned by mmap() = %p\\[rs]n\", addr);\n" "\\&\n" " /* Register the memory range of the mapping we just created for\n" " handling by the userfaultfd object. In mode, we request to track\n" " missing pages (i.e., pages that have not yet been faulted in). */\n" "\\&\n" " uffdio_register.range.start = (unsigned long) addr;\n" " uffdio_register.range.len = size;\n" " uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n" " if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1)\n" " err(EXIT_FAILURE, \"ioctl-UFFDIO_REGISTER\");\n" "\\&\n" " /* Create a thread that will process the userfaultfd events. */\n" "\\&\n" " s = pthread_create(&thr, NULL, fault_handler_thread, (void *) uffd);\n" " if (s != 0) {\n" " errc(EXIT_FAILURE, s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Main thread now touches memory in the mapping, touching\n" " locations 1024 bytes apart. This will trigger userfaultfd\n" " events for all pages in the region. */\n" "\\&\n" " i = 0xf; /* Ensure that faulting address is not on a page\n" " boundary, in order to test that we correctly\n" " handle that case in fault_handling_thread(). */\n" " while (i E size) {\n" " char c;\n" "\\&\n" " c = addr[i];\n" " printf(\"Read address %p in %s(): \", addr + i, __func__);\n" " printf(\"%c\\[rs]n\", c);\n" " i += 1024;\n" " usleep(100000); /* Slow things down a little */\n" " }\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" #. type: TH #: opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Linux man-pages (unreleased)" msgstr "صفحات دليل لينكس (لم تصدر بعد)"