-
Notifications
You must be signed in to change notification settings - Fork 182
Refactor dirty page tracking #1432
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: uffd-refactor
Are you sure you want to change the base?
Conversation
|
I want to do a few more end to end tests, but it should be ready to merge right after https://github.com/e2b-dev/infra/tree/uffd-refactor |
|
@codex review |
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.
💡 Codex Review
infra/packages/orchestrator/internal/sandbox/uffd/userfaultfd/serve.go
Lines 109 to 113 in 116062b
| msg := *(*UffdMsg)(unsafe.Pointer(&buf[0])) | |
| if GetMsgEvent(&msg) != UFFD_EVENT_PAGEFAULT { | |
| u.logger.Error("UFFD serve unexpected event type", zap.Any("event_type", GetMsgEvent(&msg))) | |
| return ErrUnexpectedEventType |
The new Disable(ctx) issues UFFDIO_UNREGISTER, which causes the kernel to emit UFFD_EVENT_REMOVE notifications on the userfaultfd. The serve loop still treats every non‑UFFD_EVENT_PAGEFAULT as an error and immediately returns ErrUnexpectedEventType. After disabling memory this will report a failure, tear down the goroutine and mark the backend as errored even though the event is expected. The loop should explicitly ignore or handle UFFD_EVENT_REMOVE (and possibly other control events) once unregistering is supported.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Isn't |
|
Summary
Testing
|
Note
Replace dirty-page tracking with a thread-safe bitset
Tracker, add UFFD unregister support, and make memory backendDisable/Dirtycontext-aware across sandbox and UFFD.block.Tracker(thread-safe bitset) withAdd,Has,Reset,BitSet,Clone,BlockSize; add comprehensive tests.sync.Map/TrackedSliceDevicewithTrackerformissingRequests; useAddto de-dup faults.UFFDIO_UNREGISTERandunregister(); exposeUserfaultfd.Unregister()and wire throughUffd.Disable(ctx).Tracker.MemoryBackendtoDisable(ctx)andDirty(ctx) (*block.Tracker, error); migrateNoopMemoryandUffdaccordingly.memory.Disable(ctx)andmemory.Dirty(ctx); passdirty.BitSet()to memory diff creation.Written by Cursor Bugbot for commit 116062b. This will update automatically on new commits. Configure here.