Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ func configureCrossProcessTest(t *testing.T, tt testConfig) (*testHandler, error
waitErr == nil,
"unexpected error: %v", waitErr,
)

// Tear down the UFFD registration before the early uffdFd.close()
// cleanup runs. Today this is a no-op (no test enables
// UFFD_FEATURE_EVENT_REMOVE) but a follow-up that does will
// otherwise see munmap block on un-acked REMOVE events queued
// against the still-registered range. Cleanups run LIFO, so
// this fires before the close registered earlier.
assert.NoError(t, unregister(uffdFd, memoryStart, uint64(size)))
})

// pageStatesOnce asks the serving process for a snapshot of its pageTracker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ func configureApi(f Fd, pagesize uint64) error {
return nil
}

// unregister tears down the UFFD registration over [addr, addr+size).
// Used in test cleanup so that any in-flight REMOVE events the kernel
// may have queued (once UFFD_FEATURE_EVENT_REMOVE is enabled in a
// follow-up) don't keep munmap blocked on un-acked events.
func unregister(f Fd, addr uintptr, size uint64) error {
r := newUffdioRange(CULong(addr), CULong(size))

ret, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(f), UFFDIO_UNREGISTER, uintptr(unsafe.Pointer(&r)))
if errno != 0 {
return fmt.Errorf("UFFDIO_UNREGISTER ioctl failed: %w (ret=%d)", errno, ret)
}

return nil
}

// mode: UFFDIO_REGISTER_MODE_WP|UFFDIO_REGISTER_MODE_MISSING
// This is already called by the FC, but only with the UFFDIO_REGISTER_MODE_MISSING
// We need to call it with UFFDIO_REGISTER_MODE_WP when we use both missing and wp
Expand Down
Loading