From owner-svn-src-head@freebsd.org Tue Sep 1 06:21:13 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2F2C79C6A0C; Tue, 1 Sep 2015 06:21:13 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org (repo.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 1158D1E1E; Tue, 1 Sep 2015 06:21:13 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t816LCW3034926; Tue, 1 Sep 2015 06:21:12 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t816LCZ4034925; Tue, 1 Sep 2015 06:21:12 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201509010621.t816LCZ4034925@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Tue, 1 Sep 2015 06:21:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287344 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 06:21:13 -0000 Author: alc Date: Tue Sep 1 06:21:12 2015 New Revision: 287344 URL: https://svnweb.freebsd.org/changeset/base/287344 Log: Handle held pages earlier in the inactive queue scan. Reviewed by: kib Sponsored by: EMC / Isilon Storage Division Modified: head/sys/vm/vm_pageout.c Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Tue Sep 1 06:05:43 2015 (r287343) +++ head/sys/vm/vm_pageout.c Tue Sep 1 06:21:12 2015 (r287344) @@ -1125,31 +1125,45 @@ vm_pageout_scan(struct vm_domain *vmd, i * different position within the queue. In either * case, addl_page_shortage should not be incremented. */ - if (!vm_pageout_page_lock(m, &next)) { - vm_page_unlock(m); - continue; + if (!vm_pageout_page_lock(m, &next)) + goto unlock_page; + else if (m->hold_count != 0) { + /* + * Held pages are essentially stuck in the + * queue. So, they ought to be discounted + * from the inactive count. See the + * calculation of the page_shortage for the + * loop over the active queue below. + */ + addl_page_shortage++; + goto unlock_page; } object = m->object; - if (!VM_OBJECT_TRYWLOCK(object) && - !vm_pageout_fallback_object_lock(m, &next)) { - vm_page_unlock(m); - VM_OBJECT_WUNLOCK(object); - continue; + if (!VM_OBJECT_TRYWLOCK(object)) { + if (!vm_pageout_fallback_object_lock(m, &next)) + goto unlock_object; + else if (m->hold_count != 0) { + addl_page_shortage++; + goto unlock_object; + } } - - /* - * Don't mess with busy pages, keep them at at the - * front of the queue, most likely they are being - * paged out. Increment addl_page_shortage for busy - * pages, because they may leave the inactive queue - * shortly after page scan is finished. - */ if (vm_page_busied(m)) { - vm_page_unlock(m); - VM_OBJECT_WUNLOCK(object); + /* + * Don't mess with busy pages. Leave them at + * the front of the queue. Most likely, they + * are being paged out and will leave the + * queue shortly after the scan finishes. So, + * they ought to be discounted from the + * inactive count. + */ addl_page_shortage++; +unlock_object: + VM_OBJECT_WUNLOCK(object); +unlock_page: + vm_page_unlock(m); continue; } + KASSERT(m->hold_count == 0, ("Held page %p", m)); /* * We unlock the inactive page queue, invalidating the @@ -1164,7 +1178,7 @@ vm_pageout_scan(struct vm_domain *vmd, i * Invalid pages can be easily freed. They cannot be * mapped, vm_page_free() asserts this. */ - if (m->valid == 0 && m->hold_count == 0) { + if (m->valid == 0) { vm_page_free(m); PCPU_INC(cnt.v_dfree); --page_shortage; @@ -1208,18 +1222,6 @@ vm_pageout_scan(struct vm_domain *vmd, i goto drop_page; } - if (m->hold_count != 0) { - /* - * Held pages are essentially stuck in the - * queue. So, they ought to be discounted - * from the inactive count. See the - * calculation of the page_shortage for the - * loop over the active queue below. - */ - addl_page_shortage++; - goto drop_page; - } - /* * If the page appears to be clean at the machine-independent * layer, then remove all of its mappings from the pmap in