-
Notifications
You must be signed in to change notification settings - Fork 175
Extract low level UFFD handler to a separate package #973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c85fec0
to
855369b
Compare
I'll improve the tests a little, but the rest should be ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extracts the low-level user fault file descriptor (UFFD) handler into a separate userfaultfd package, improving code organization and modularity. The extraction refactors the UFFD functionality out of the main uffd package into a dedicated userfaultfd subpackage.
- Moved UFFD handling logic from uffd package to new userfaultfd package
- Created abstraction layer with memory mapping interfaces
- Added comprehensive test coverage for UFFD functionality including cross-process scenarios
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_test.go | Comprehensive test suite for UFFD missing page and write protection scenarios |
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_cross_process_test.go | Cross-process UFFD tests simulating FC-orchestrator interaction |
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd.go | Core UFFD operations including registration and copy functionality |
packages/orchestrator/internal/sandbox/uffd/userfaultfd/serve.go | UFFD event handling and page fault processing logic |
packages/orchestrator/internal/sandbox/uffd/userfaultfd/constants.go | UFFD constants and helper functions with improved address handling |
packages/orchestrator/internal/sandbox/uffd/uffd.go | Updated to use new userfaultfd package and memory interfaces |
packages/orchestrator/internal/sandbox/uffd/testutils/ | Test utilities for memory mapping and data preparation |
packages/orchestrator/internal/sandbox/uffd/memory/ | Memory mapping interfaces and Firecracker-specific implementations |
Comments suppressed due to low confidence (2)
packages/orchestrator/internal/sandbox/uffd/userfaultfd/constants.go:1
- The constant
UFFD_FEATURE_WP_HUGETLBFS_SHMEM
is being removed but may be needed for write protection features. Verify this removal is intentional and doesn't break functionality.
package userfaultfd
packages/orchestrator/internal/sandbox/uffd/uffd.go:1
- The
TrackAndReturnNil
method is being removed. Ensure all callers of this method have been updated to handle its removal.
package uffd
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_cross_process_test.go
Outdated
Show resolved
Hide resolved
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_cross_process_test.go
Outdated
Show resolved
Hide resolved
bugbot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no bugs!
✅ Extracted all non-relevant (mostly write-protection and direct memory access related) code to separate PRs so it can be merged in steps. |
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_test.go
Show resolved
Hide resolved
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_test.go
Outdated
Show resolved
Hide resolved
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_test.go
Outdated
Show resolved
Hide resolved
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_test.go
Show resolved
Hide resolved
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_test.go
Outdated
Show resolved
Hide resolved
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd_test.go
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just added some opinions, none of which are critical.
…el uffd handling to a subpackage
1d37eef
to
c11e5ef
Compare
Note
Extracts UFFD logic into a new
userfaultfd
package with memory mapping abstractions, updates orchestrator integration, and adds comprehensive tests and helpers.packages/orchestrator/internal/sandbox/uffd/userfaultfd
with auserfaultfd
wrapper (Serve
,Register
,AddWriteProtection
,Close
,copy
).mapping
withmemory
module: introduceMemoryMap
interface andMemfileMap
withGetOffset
; update Firecracker mapping topackage memory
.uffd.go
to usememory.MemfileMap
and the newuserfaultfd
instance (fd management via wrapper,Serve
method); addwriteProtection
field.UFFDIO_COPY_MODE_DONTWAKE
,UFFDIO_WAKE
; adjust address types and copy dst handling).testutils
(contiguous map, mmap creators, test data helpers).userfaultfd
tests for missing, write-protect, combined modes, and cross-process double registration.Written by Cursor Bugbot for commit 67b1bfb. This will update automatically on new commits. Configure here.