From owner-svn-src-head@FreeBSD.ORG Sun Jun 14 20:23:42 2015 Return-Path: Delivered-To: svn-src-head@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4F386D9A; Sun, 14 Jun 2015 20:23:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) 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 23788CA; Sun, 14 Jun 2015 20:23:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5EKNgOI011007; Sun, 14 Jun 2015 20:23:42 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5EKNgNo011006; Sun, 14 Jun 2015 20:23:42 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201506142023.t5EKNgNo011006@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 14 Jun 2015 20:23:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284387 - 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: Sun, 14 Jun 2015 20:23:42 -0000 Author: kib Date: Sun Jun 14 20:23:41 2015 New Revision: 284387 URL: https://svnweb.freebsd.org/changeset/base/284387 Log: Invalid pages do not need neither update of the activation count nor they coould be dirty. Move the handling if the invalid pages in the inactive scan earlier. Remove some code duplication in the scan by introducing the 'drop_page' label, which centralizes the object and the page unlock. Suggested and reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/sys/vm/vm_pageout.c Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Sun Jun 14 20:16:36 2015 (r284386) +++ head/sys/vm/vm_pageout.c Sun Jun 14 20:23:41 2015 (r284387) @@ -1159,6 +1159,17 @@ vm_pageout_scan(struct vm_domain *vmd, i queues_locked = FALSE; /* + * Invalid pages can be easily freed. They cannot be + * mapped, vm_page_free() asserts this. + */ + if (m->valid == 0 && m->hold_count == 0) { + vm_page_free(m); + PCPU_INC(cnt.v_dfree); + --page_shortage; + goto drop_page; + } + + /* * We bump the activation count if the page has been * referenced while in the inactive queue. This makes * it less likely that the page will be added back to the @@ -1192,15 +1203,10 @@ vm_pageout_scan(struct vm_domain *vmd, i queues_locked = TRUE; vm_page_requeue_locked(m); } - VM_OBJECT_WUNLOCK(object); - vm_page_unlock(m); - goto relock_queues; + goto drop_page; } if (m->hold_count != 0) { - vm_page_unlock(m); - VM_OBJECT_WUNLOCK(object); - /* * Held pages are essentially stuck in the * queue. So, they ought to be discounted @@ -1209,7 +1215,7 @@ vm_pageout_scan(struct vm_domain *vmd, i * loop over the active queue below. */ addl_page_shortage++; - goto relock_queues; + goto drop_page; } /* @@ -1224,14 +1230,7 @@ vm_pageout_scan(struct vm_domain *vmd, i if (m->dirty == 0 && object->ref_count != 0) pmap_remove_all(m); - if (m->valid == 0) { - /* - * Invalid pages can be easily freed - */ - vm_page_free(m); - PCPU_INC(cnt.v_dfree); - --page_shortage; - } else if (m->dirty == 0) { + if (m->dirty == 0) { /* * Clean pages can be freed. */ @@ -1305,6 +1304,7 @@ vm_pageout_scan(struct vm_domain *vmd, i vm_page_lock_assert(m, MA_NOTOWNED); goto relock_queues; } +drop_page: vm_page_unlock(m); VM_OBJECT_WUNLOCK(object); relock_queues: