This publication describes techniques for utilizing the Linux userfaultfd system call in a garbage collection process performed concurrently with the execution of application threads (mutators) in a software application. During the garbage collection process, a stop-the-world pause occurs where currently mapped physical pages of a heap are moved to a temporary location (e.g., temp-space) and a new memory range of the heap is registered with userfaultfd. During a concurrent compaction phase of the garbage collection process, if a mutator accesses an area (e.g., a to-space page) in the heap that has not yet been processed by the garbage collector thread, and thus does not have a page allocated, the mutator will receive a SIGBUS signal (bus error) indicating a page fault. Responsive to receiving the registered page fault, a page buffer (e.g., 4KB page buffer) is created. All the reachable objects that should be located on the missing page are copied to the page buffer and the references inside these objects are updated to the corresponding new addresses. Finally, the userfaultfd input/output control (ioctl) system call is invoked by the user space to hand over the page buffer to the kernel, including an indication of the page to make visible on the faulting address. In response, the kernel can copy the contents of the page buffer to a page and map that page.

Creative Commons License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 License.