Ensure the background laundering threshold is positive after a scan.

The division added in r331732 meant that we wouldn't attempt a
background laundering until at least v_free_target - v_free_min clean
pages had been freed by the page daemon since the last laundering. If
the inactive queue is depleted but not completely empty (e.g., because
it contains busy pages), it can thus take a long time to meet this
threshold. Restore the pre-r331732 behaviour of using a non-zero
background laundering threshold if at least one inactive queue scan has
elapsed since the last attempt at background laundering.

Submitted by:	tijl (original version)
This commit is contained in:
Mark Johnston 2018-04-02 15:07:41 +00:00
parent 8428d0f154
commit c098768e4d

View File

@ -1015,14 +1015,16 @@ vm_pageout_laundry_worker(void *arg)
* clean pages freed by the page daemon since the last
* background laundering. Thus, as the ratio of dirty to
* clean inactive pages grows, the amount of memory pressure
* required to trigger laundering decreases.
* required to trigger laundering decreases. We ensure
* that the threshold is non-zero after an inactive queue
* scan, even if that scan failed to free a single clean page.
*/
trybackground:
nclean = vmd->vmd_free_count +
vmd->vmd_pagequeues[PQ_INACTIVE].pq_cnt;
ndirty = vmd->vmd_pagequeues[PQ_LAUNDRY].pq_cnt;
if (target == 0 && ndirty * isqrt(nfreed /
(vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
if (target == 0 && ndirty * isqrt(howmany(nfreed + 1,
vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) {
target = vmd->vmd_background_launder_target;
}