Flow Handling Page Fault - EDM-Project/EDM GitHub Wiki
Top view - resolving page fault in EDM
Sequence diagram to show the interactions between modules in sequential order.
steps:
- App accesses page that its present bit in PTE is 0, which causes to page fault.
- mm start handle_mm_fault(). The following functions are called: handle_mm_fault() -> __handle_mm_fault()-> handle_pte_fault()->do_anonymous_page() which detect that page belong to userfaultfd and calls handle_userfaultfd()
- handle_userfaultfd() function builds the event message and writes it to userfaultfd object(file descriptor).
- handle_userfaultfd() make the event visible to userspace.
- DM_Handler, which polls userfaultfd, reads the message and starts handling page fault. It sends a request to DMS via MPI.
- if the page exists in SPT, DMS fetches the page from the disc
- DMS gets the page data from the disc
- DMS sets the request status = existing_page.
- else, the page is new, DMS sets the request status= new_page.
- DMS updates SPT - the up-to-date location of the page is the instance that sends the request.
- DMS sends the request structure via MPI back to DM-handler.
- According to the status, if new_page is new, DM-Handler calls ioctl UFFDIO_ZEROPAGE() (the function in the kernel is userfaultfd_zeropage()).
- if the status is existing_page, DM-Handler calls ioctl UFFDIO_COPY() (the function in the kernel is userfaultfd_copy()).
- DM-Handler add the page to LSPT (with its pfn)
- Userfaultfd wakes up the faulting thread. The page fault was resolved and the app can continue running.
Notes:
-
The diagram is divided into user space and kernel space. The userfaultfd participant in the diagram refers to userfaultfd mechanism in the kernel. DM-Handler refers to the monitoring thread that calls to ioctls (of userfaultfd).
-
The diagram doesn't contain the validations, connections, error handlings, etc., and is meant to explain the big picture of the flow of the interaction between modules in EDM.