From 86fa24710e94d69213db3f7f722db3f1f2e61790 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 18 Jan 2014 20:02:59 +0000 Subject: [PATCH] Style changes in vm_pageout_scan(): 1. Be consistent in the style of "act_delta" manipulations between the inactive and active queue scans. 2. Explicitly compare to zero. 3. The deactivation of a page is based is based on its recent history and not just the current call to vm_pageout_scan(). The variable "act_delta" represents the current state of the page, and not its history. Avoid possible confusion by not (ab)using "act_delta" for the making the deactivation decision. Submitted by: kib [1] Reviewed by: kib [2,3] --- sys/vm/vm_pageout.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index d2ccfa0f16d8..517491fe7efb 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -1047,11 +1047,11 @@ vm_pageout_scan(struct vm_domain *vmd, int pass) * level VM system not knowing anything about existing * references. */ - act_delta = 0; if ((m->aflags & PGA_REFERENCED) != 0) { vm_page_aflag_clear(m, PGA_REFERENCED); act_delta = 1; - } + } else + act_delta = 0; if (object->ref_count != 0) { act_delta += pmap_ts_referenced(m); } else { @@ -1064,7 +1064,7 @@ vm_pageout_scan(struct vm_domain *vmd, int pass) * references, we reactivate the page or requeue it. */ if (act_delta != 0) { - if (object->ref_count) { + if (object->ref_count != 0) { vm_page_activate(m); m->act_count += act_delta + ACT_ADVANCE; } else { @@ -1361,11 +1361,12 @@ vm_pageout_scan(struct vm_domain *vmd, int pass) /* * Check to see "how much" the page has been used. */ - act_delta = 0; - if (m->aflags & PGA_REFERENCED) { + if ((m->aflags & PGA_REFERENCED) != 0) { vm_page_aflag_clear(m, PGA_REFERENCED); - act_delta += 1; - } + act_delta = 1; + } else + act_delta = 0; + /* * Unlocked object ref count check. Two races are possible. * 1) The ref was transitioning to zero and we saw non-zero, @@ -1380,20 +1381,18 @@ vm_pageout_scan(struct vm_domain *vmd, int pass) /* * Advance or decay the act_count based on recent usage. */ - if (act_delta) { + if (act_delta != 0) { m->act_count += ACT_ADVANCE + act_delta; if (m->act_count > ACT_MAX) m->act_count = ACT_MAX; - } else { + } else m->act_count -= min(m->act_count, ACT_DECLINE); - act_delta = m->act_count; - } /* * Move this page to the tail of the active or inactive * queue depending on usage. */ - if (act_delta == 0) { + if (m->act_count == 0) { /* Dequeue to avoid later lock recursion. */ vm_page_dequeue_locked(m); vm_page_deactivate(m);