Don't FREE pages in a shadowing object. While this degrades MADV_FREE to a no-op (and we could, instead, choose to fall back to MADV_DONTNEED, at the cost of changing pmap_madvise), this is presently considered a temporary fix. We may prefer to risk a little fragmentation of the map by creating a zero/OBJT_DEFAULT entry over top of the existing object and, simultaneously, revert to the existing marking any pages in the former shadowing object in the advised region as reclaimable. At least one consumer of MADV_FREE (snmalloc) may use mmap() to construct zeroed pages "eventually" here anyway, so the fragmentation may be coming anyway.
|2786 ↗||(On Diff #61642)|
I suggest to leave only the first sentence in the comment. You can write more in the commit message (AKA the review summary).
On the other hand, it might be worth noting that (even) read-only map lock prevents both object.vm_object and its backing_object from changing under us, so the test is valid after being performed.