As a step towards the removal of PG_CACHED pages, we'd like to remove
the call to vm_object_page_cache() in vop_stdadvise(). The first
iteration of this change effectively replaced the call with one to
vm_page_advise(MADV_DONTNEED) for each resident page in the specified
range. However, this interacts badly with the current implementation of
POSIX_FADV_DONTNEED: as a thread reads or writes a file sequentially,
vn_read() and vn_write() coalesce the consecutive file ranges so that
the range passed to VOP_ADVISE grows to cover the entire file. Unlike
page caching, page deactivation does not remove the page from the
object, so each call to VOP_ADVISE ends up duplicating the work of the
previous call.
This change modifies vop_stdadvise() so that it deactivates pages
without running into this problem. In particular, it
- removes the range coalescing code from vn_read() and vn_write(), and
- introduces a new buf flag, B_NOREUSE, which is a hint to vfs_vmio_release() that indicates that LRU operation may be bypassed when deactivating pages.
This change adds a new VM function, vm_page_deactivate_noreuse(), to
perform B_NOREUSE deactivations in vfs_vmio_release(). This is done
instead of calling vm_page_advise(MADV_DONTNEED) since the latter has
some mildly undesirable side effects here: it'll clear the
PGA_REFERENCED bit on the page, which could have been caused by a
userspace mapping of the file, and it needlessly checks whether the page
is dirty.