From owner-svn-src-stable-10@FreeBSD.ORG Tue May 13 05:21:55 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 123D4B29; Tue, 13 May 2014 05:21:55 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F3B362CA9; Tue, 13 May 2014 05:21:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4D5LsLa075164; Tue, 13 May 2014 05:21:54 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4D5LsG8075163; Tue, 13 May 2014 05:21:54 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201405130521.s4D5LsG8075163@svn.freebsd.org> From: Alan Cox Date: Tue, 13 May 2014 05:21:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r265944 - stable/10/sys/vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 May 2014 05:21:55 -0000 Author: alc Date: Tue May 13 05:21:54 2014 New Revision: 265944 URL: http://svnweb.freebsd.org/changeset/base/265944 Log: MFC r260567 Correctly update the count of stuck pages, "addl_page_shortage", in vm_pageout_scan(). There were missing increments in two less common cases. Don't conflate the count of stuck pages and the pageout deficit provided by vm_page_alloc{,_contig}(). Handle held pages consistently in the inactive queue scan. In the more common case, we did not move the page to the tail of the queue. Whereas, in the less common case, we did. There's no particular reason to move the page in the less common case, so remove it. Perform the calculation of the page shortage for the active queue scan a little earlier, before the active queue lock is acquired. The correctness of this calculation doesn't depend on the active queue lock being held. Eliminate a redundant variable, "pcount". Use the more descriptive variable, "maxscan", in its place. Apply a few nearby style fixes, e.g., eliminate stray whitespace and excess parentheses. Modified: stable/10/sys/vm/vm_pageout.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/vm/vm_pageout.c ============================================================================== --- stable/10/sys/vm/vm_pageout.c Tue May 13 05:19:29 2014 (r265943) +++ stable/10/sys/vm/vm_pageout.c Tue May 13 05:21:54 2014 (r265944) @@ -909,10 +909,8 @@ vm_pageout_scan(struct vm_domain *vmd, i { vm_page_t m, next; struct vm_pagequeue *pq; - int page_shortage, maxscan, pcount; - int addl_page_shortage; vm_object_t object; - int act_delta; + int act_delta, addl_page_shortage, deficit, maxscan, page_shortage; int vnodes_skipped = 0; int maxlaunder; int lockmode; @@ -942,13 +940,15 @@ vm_pageout_scan(struct vm_domain *vmd, i * number of pages from the inactive count that should be * discounted in setting the target for the active queue scan. */ - addl_page_shortage = atomic_readandclear_int(&vm_pageout_deficit); + addl_page_shortage = 0; + + deficit = atomic_readandclear_int(&vm_pageout_deficit); /* * Calculate the number of pages we want to either free or move * to the cache. */ - page_shortage = vm_paging_target() + addl_page_shortage; + page_shortage = vm_paging_target() + deficit; /* * maxlaunder limits the number of dirty pages we flush per scan. @@ -1245,6 +1245,7 @@ vm_pageout_scan(struct vm_domain *vmd, i */ if (vm_page_busied(m)) { vm_page_unlock(m); + addl_page_shortage++; goto unlock_and_continue; } @@ -1252,9 +1253,9 @@ vm_pageout_scan(struct vm_domain *vmd, i * If the page has become held it might * be undergoing I/O, so skip it */ - if (m->hold_count) { + if (m->hold_count != 0) { vm_page_unlock(m); - vm_page_requeue_locked(m); + addl_page_shortage++; if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; goto unlock_and_continue; @@ -1309,19 +1310,20 @@ relock_queues: * Compute the number of pages we want to try to move from the * active queue to the inactive queue. */ + page_shortage = cnt.v_inactive_target - cnt.v_inactive_count + + vm_paging_target() + deficit + addl_page_shortage; + pq = &vmd->vmd_pagequeues[PQ_ACTIVE]; vm_pagequeue_lock(pq); - pcount = pq->pq_cnt; - page_shortage = vm_paging_target() + - cnt.v_inactive_target - cnt.v_inactive_count; - page_shortage += addl_page_shortage; + maxscan = pq->pq_cnt; + /* * If we're just idle polling attempt to visit every * active page within 'update_period' seconds. */ - if (pass == 0 && vm_pageout_update_period != 0) { - pcount /= vm_pageout_update_period; - page_shortage = pcount; + if (pass == 0 && vm_pageout_update_period != 0) { + maxscan /= vm_pageout_update_period; + page_shortage = maxscan; } /* @@ -1330,7 +1332,7 @@ relock_queues: * deactivation candidates. */ m = TAILQ_FIRST(&pq->pq_pl); - while ((m != NULL) && (pcount-- > 0) && (page_shortage > 0)) { + while (m != NULL && maxscan-- > 0 && page_shortage > 0) { KASSERT(m->queue == PQ_ACTIVE, ("vm_pageout_scan: page %p isn't active", m));