An alternative to D36038 -- experimental, works for me (tm).
I have to say I don't know the requirements to safely traverse the object chain list. However, vm_fault_object at some point can wunlock and wlock the object again, all while only having "paging in progress" on it. Assuming this is correct, the patch below should also be fine in that regard. That is the object used is still protected with PIP and after the page is busied and re-checked for identity + validity + the object not being dead, the guarantees should be the same as with the current code *after* the lock is dropped when FAULT_SOFT is returned. Finally, if the aforementioned wunlock/wlock is indeed fine, it should also be fine to just wlock as fallback.
I did not use vm_page_grab_unlocked(..., VM_ALLOC_NOCREAT) because it would mean the vm_page_all_valid check could only be performed after busying -- for pages which are not valid this only increases contention, all while it is avoidable. Additionally the sleeping mechanism is different so I would have to add VM_ALLOC_NOWAIT and handle it on my own anyway.
I also added vm_page_trybusy_unlocked for safe checks.
commit dc4bdbab0efd09ae608c2d54adaf48f49879a1b1
Author: Mateusz Guzik <mjg@FreeBSD.org>
Date: Sun Aug 7 13:12:43 2022 +0000
vm: unlocked lookup in fault handling against backing objects
commit bf1c404924185a097fdae38da6ada97faca2cb64
Author: Mateusz Guzik <mjg@FreeBSD.org>
Date: Sun Aug 7 13:07:59 2022 +0000
vm: include function name when checking vm_fault_object retval
Reviewed by:
Differential Revision:
commit 901fb82296bc540b956d4f99d72c65c3d1dfe7fb
Author: Mateusz Guzik <mjg@FreeBSD.org>
Date: Sun Aug 7 13:05:47 2022 +0000
vm: move up object lock asserts in fault functions
No functional changes.
Reviewed by:
Differential Revision:
commit d65823d4d93b1c749dcd94d34763d94b73734e40
Author: Mateusz Guzik <mjg@FreeBSD.org>
Date: Fri Aug 12 14:16:46 2022 +0000
vm: add vm_page_trybusy_unlocked
This allows consumers to find the page and safely busy without holding
the object lock.
Reviewed by:
Differential Revision: