Commit e5274b5
committed
fix(uffd): re-read page state inside worker goroutine under settleRequests.RLock
The Serve() loop previously read pageTracker state and captured
`source = u.src` in the parent loop, then dispatched a worker
goroutine. A REMOVE event for the same page that arrived between the
state read and the worker actually acquiring settleRequests.RLock()
would silently leave the worker with a stale `source = u.src`
snapshot. The worker would then UFFDIO_COPY src bytes into a page the
kernel had just MADV_DONTNEED'd, leaving pageTracker == removed and
the kernel page mapped with stale src data — and observably
deadlocking parent madvise() in the orchestrator unit-test suite.
Move the state lookup and source capture inside the goroutine, after
RLock(). The read+act+commit sequence is now atomic with respect to
the REMOVE batch (which takes settleRequests.Lock()).
Makes the three deterministic race tests added in the parent PR pass:
- TestStaleSourceRaceMissingAndRemove (the one that intentionally
failed on the parent PR with `page 1 first byte: want 0 ... got 0xc3`)
- TestNoMadviseDeadlockWithInflightCopy (already passed; now stays green)
- TestFaultedShortCircuitOrdering (already passed; now stays green)
Soak: -count=20 -timeout=30s passes deterministically on this branch.1 parent 1e978ee commit e5274b5
1 file changed
Lines changed: 24 additions & 22 deletions
Lines changed: 24 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | 326 | | |
346 | 327 | | |
347 | 328 | | |
348 | 329 | | |
349 | 330 | | |
350 | | - | |
351 | | - | |
352 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
353 | 338 | | |
354 | 339 | | |
355 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
356 | 358 | | |
357 | 359 | | |
358 | 360 | | |
| |||
0 commit comments