This is the work of the page daemon. Now that the page daemon does slow
and steady scanning of the active queue, I don't think it makes much
sense to replicate that algorithm here. Moreover, it was doing so
inconsistently:
- PGA_REFERENCED is not counted in act_count unless pmap_ts_referenced() returned 0, but the page daemon always counts PGA_REFERENCED.
- The swapout daemon always activates a referenced page, but the page daemon only does so when the containing object is mapped at least once.
The main purpose of swapout_deactivate_pages() is to shrink the number
of pages mapped into a given pmap. To do this without unmapping active
pages, use the non-destructive pmap_is_referenced() instead of the
destructive pmap_ts_referenced() and deactivate pages accordingly.
This function is racy before and after this change: a reference bit
which is set between the pmap_is_referenced() and
vm_page_try_remove_all() calls is lost. We do not have a pmap interface
for removing only unreferenced mappings.