From owner-svn-src-all@FreeBSD.ORG Sat Oct 6 19:05:50 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DE383106564A; Sat, 6 Oct 2012 19:05:50 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C9DAE8FC12; Sat, 6 Oct 2012 19:05:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q96J5oiH021827; Sat, 6 Oct 2012 19:05:50 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q96J5of9021825; Sat, 6 Oct 2012 19:05:50 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201210061905.q96J5of9021825@svn.freebsd.org> From: Alan Cox Date: Sat, 6 Oct 2012 19:05:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r241276 - head/sys/mips/mips X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2012 19:05:51 -0000 Author: alc Date: Sat Oct 6 19:05:50 2012 New Revision: 241276 URL: http://svn.freebsd.org/changeset/base/241276 Log: Correct two pessimizations in pmap_extract_and_hold(). Test the PTE for having PTE_RO set instead of PTE_D. This avoids some unnecessary failures by pmap_extract_and_hold() that will have to be handled by a call to vm_fault_hold(). Testing the PTE for both being non-zero and having PTE_V set is redundant. The latter suffices. Modified: head/sys/mips/mips/pmap.c Modified: head/sys/mips/mips/pmap.c ============================================================================== --- head/sys/mips/mips/pmap.c Sat Oct 6 19:01:31 2012 (r241275) +++ head/sys/mips/mips/pmap.c Sat Oct 6 19:05:50 2012 (r241276) @@ -791,24 +791,25 @@ pmap_extract(pmap_t pmap, vm_offset_t va vm_page_t pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot) { - pt_entry_t *ptep; - pt_entry_t pte; + pt_entry_t pte, *ptep; + vm_paddr_t pa, pte_pa; vm_page_t m; - vm_paddr_t pa; m = NULL; pa = 0; PMAP_LOCK(pmap); retry: ptep = pmap_pte(pmap, va); - if ((ptep != NULL) && ((pte = *ptep) != 0) && - pte_test(&pte, PTE_V) && - (pte_test(&pte, PTE_D) || (prot & VM_PROT_WRITE) == 0)) { - if (vm_page_pa_tryrelock(pmap, TLBLO_PTE_TO_PA(pte), &pa)) - goto retry; - - m = PHYS_TO_VM_PAGE(TLBLO_PTE_TO_PA(pte)); - vm_page_hold(m); + if (ptep != NULL) { + pte = *ptep; + if (pte_test(&pte, PTE_V) && (!pte_test(&pte, PTE_RO) || + (prot & VM_PROT_WRITE) == 0)) { + pte_pa = TLBLO_PTE_TO_PA(pte); + if (vm_page_pa_tryrelock(pmap, pte_pa, &pa)) + goto retry; + m = PHYS_TO_VM_PAGE(pte_pa); + vm_page_hold(m); + } } PA_UNLOCK_COND(pa); PMAP_UNLOCK(pmap);