uffd: serve firecracker page faults from a shared template mem-file#216
Draft
sjmiller609 wants to merge 1 commit intohypeship/fork-shared-memfilefrom
Draft
uffd: serve firecracker page faults from a shared template mem-file#216sjmiller609 wants to merge 1 commit intohypeship/fork-shared-memfilefrom
sjmiller609 wants to merge 1 commit intohypeship/fork-shared-memfilefrom
Conversation
Adds lib/uffd, a userfaultfd page server that backs many concurrent fan-out forks against a single read-only template mem-file instead of letting each fork mmap it privately. Firecracker connects to a per-fork UDS, hands us its userfaultfd via SCM_RIGHTS along with a JSON mappings handshake, and the server then services UFFD_EVENT_PAGEFAULT events with UFFDIO_COPY reads from the template. The Linux hot path lives behind a build tag; non-Linux builds return ErrUnsupported so callers can fall back to MAP_PRIVATE. Cross-platform tests cover the handshake parser and the server lifecycle. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This was referenced May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on: #214 (shared mem-file) — review #213 → #214 first.
Summary
lib/uffdpackage: a userfaultfd page server that backs many concurrent fan-out forks against a single read-only template mem-file.SCM_RIGHTSplus a JSON mappings handshake; the server then servicesUFFD_EVENT_PAGEFAULTwithUFFDIO_COPYreads from the template.server_linux.gobehind a build tag; non-Linux builds returnErrUnsupportedso callers can fall back to MAP_PRIVATE.Why
Symlinking the mem-file (the prior PR) avoids the copy but still forces firecracker to MAP_PRIVATE the file, so every page is COW'd on first touch. UFFD lets all forks share the read-only template extents and only allocate guest pages on actual writes — the canonical fan-out memory model for firecracker.
Test plan
go test ./lib/uffd/...(cross-platform parser/lifecycle)pmapto confirm pages are shared🤖 Generated with Claude Code