Concurrent page-fault handling with per-VMA locks
Concurrent page-fault handling with per-VMA locks
Posted Sep 6, 2022 2:20 UTC (Tue) by calumapplepie (guest, #143655)In reply to: Concurrent page-fault handling with per-VMA locks by developer122
Parent article: Concurrent page-fault handling with per-VMA locks
Or maybe the authors didn't think of this case, which would be concerning, since there exists a potential for a deadlock if they did it wrong. We probably can't assume that there even is a current write operation which can complete, since I thin the number is only incremented on write operation completion. If it was incremented on both operation completion and initiation, you'd get that property of no-deadlocks. All VMAs would be unlocked if there is no write operation, regardless of rollover, because the mmap sequence number would be odd if there are modifications occurring and even otherwise, and VMA sequence numbers would only ever be set to odd values.
Both of these are fairly inexpensive solutions, as an extra increment isn't much compared to handling a page fault, and the structure in question will already be loaded into the L1 cache for modification. Similarly, I believe the first solution boils down to an additional decrement as well, since the mmap_lock must be acquired anyways in the fallback case. They also aren't mutually exclusive; just make the fallback path decrement the VMA sequence number by 2 to keep the pattern of odds/evens. I'd encourage the devs to implement both, given the impact that a bug in this could have: at worse, an unpredictable deadlock that only occurs in long-running processes and is virtually impossible to reproduce; at best, degraded performance in long-running processes due to constantly falling back on the worst-case code. I'm willing to bet that *some* process's architecture involves setting up a few large VMAs full of pages being faulted in and out but which never itself gets modified.
Posted Sep 6, 2022 6:28 UTC (Tue)
by kilobyte (subscriber, #108024)
[Link]
Posted Sep 6, 2022 10:56 UTC (Tue)
by developer122 (guest, #152928)
[Link]
Concurrent page-fault handling with per-VMA locks
Concurrent page-fault handling with per-VMA locks