refactor(uffd): store pageSize on struct#2419
Conversation
PR SummaryLow Risk Overview Reviewed by Cursor Bugbot for commit be402d1. Bugbot is set up for automated code reviews on this repo. Configure here. |
355b9f1 to
563aee3
Compare
- Store pageSize on Userfaultfd struct instead of retrieving it from mapping functions on every fault - Drop pagesize return value from GetOffset and GetHostVirtAddr; callers now read u.pageSize (already validated to be uniform across regions in NewUserfaultfdFromFd) - Drop pagesize parameter from faultPage - Update mapping offset tests for the new signatures Pure refactor, no behavior change.
563aee3 to
1a86243
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 754ef36. Configure here.
GetOffset no longer returns pagesize, so the expectedPagesize field and its per-case values in TestMapping_GetOffset were dead.

Summary
pageSizeon theUserfaultfdstruct instead of retrieving it from mapping functions on every fault.pagesizereturn value fromMapping.GetOffsetandMapping.GetHostVirtAddr; callers now readu.pageSize.pagesizeparameter fromfaultPage.All regions in a mapping are already validated to share the same page size in
NewUserfaultfdFromFd, so a single stored value is sufficient.Pure refactor, no behavior change.
Split out of this PR
Prefault/directDataSourceextraction intoprefault.go→ refactor(uffd): extract Prefault to its own file #2441safeInvokehelper extraction → refactor(uffd): extract safeInvoke helper #2442Test plan
go build ./...passesgo vet ./pkg/sandbox/uffd/...cleangolangci-lint run ./pkg/sandbox/uffd/...clean