Make collapse synchronization more explicit and allow it to complete during
authorjeff <jeff@FreeBSD.org>
Sun, 19 Jan 2020 18:30:23 +0000 (18:30 +0000)
committerjeff <jeff@FreeBSD.org>
Sun, 19 Jan 2020 18:30:23 +0000 (18:30 +0000)
commit065795cf7c0fc59f6c33d9c7daa0c9914f83a2af
tree83aa7b0d57ed4adde9909183652edeec23bba9a7
parenta96403f7155100bd83a4598ee07eb9afc17b65f0
Make collapse synchronization more explicit and allow it to complete during
paging.

Shadow objects are marked with a COLLAPSING flag while they are collapsing with
their backing object.  This gives us an explicit test rather than overloading
paging-in-progress.  While split is on-going we mark an object with SPLIT.
These two operations will modify the swap tree so they must be serialized
and swap_pager_getpages() can now directly detect these conditions and page
more conservatively.

Callers to vm_object_collapse() now will reliably wait for a collapse to finish
so that the backing chain is as short as possible before other decisions are
made that may inflate the object chain.  For example, split, coalesce, etc.
It is now safe to run fault concurrently with collapse.  It is safe to increase
or decrease paging in progress with no lock so long as there is another valid
ref on increase.

This change makes collapse more reliable as a secondary benefit.  The primary
benefit is making it safe to drop the object lock much earlier in fault or
never acquire it at all.

This was tested with a new shadow chain test script that uncovered long
standing bugs and will be integrated with stress2.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22908
sys/vm/swap_pager.c
sys/vm/vm_object.c
sys/vm/vm_object.h