From owner-svn-src-all@FreeBSD.ORG Mon Oct 26 00:01:52 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 981FD1065676; Mon, 26 Oct 2009 00:01:52 +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 6EF458FC12; Mon, 26 Oct 2009 00:01:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9Q01qa5071921; Mon, 26 Oct 2009 00:01:52 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9Q01qcw071919; Mon, 26 Oct 2009 00:01:52 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200910260001.n9Q01qcw071919@svn.freebsd.org> From: Alan Cox Date: Mon, 26 Oct 2009 00:01:52 +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: r198476 - head/sys/vm 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: Mon, 26 Oct 2009 00:01:52 -0000 Author: alc Date: Mon Oct 26 00:01:52 2009 New Revision: 198476 URL: http://svn.freebsd.org/changeset/base/198476 Log: Simplify the inner loop of vm_fault_copy_entry(). Reviewed by: kib Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Oct 25 21:46:38 2009 (r198475) +++ head/sys/vm/vm_fault.c Mon Oct 26 00:01:52 2009 (r198476) @@ -1133,20 +1133,20 @@ vm_fault_copy_entry(vm_map_t dst_map, vm { vm_object_t backing_object, dst_object, object; vm_object_t src_object; - vm_ooffset_t dst_offset; - vm_ooffset_t src_offset; - vm_pindex_t pindex; + vm_pindex_t dst_pindex, pindex, src_pindex; vm_prot_t prot; vm_offset_t vaddr; vm_page_t dst_m; vm_page_t src_m; + boolean_t src_readonly; #ifdef lint src_map++; #endif /* lint */ src_object = src_entry->object.vm_object; - src_offset = src_entry->offset; + src_pindex = OFF_TO_IDX(src_entry->offset); + src_readonly = (src_entry->protection & VM_PROT_WRITE) == 0; /* * Create the top-level object for the destination entry. (Doesn't @@ -1177,16 +1177,16 @@ vm_fault_copy_entry(vm_map_t dst_map, vm * one from the source object (it should be there) to the destination * object. */ - for (vaddr = dst_entry->start, dst_offset = 0; + for (vaddr = dst_entry->start, dst_pindex = 0; vaddr < dst_entry->end; - vaddr += PAGE_SIZE, dst_offset += PAGE_SIZE) { + vaddr += PAGE_SIZE, dst_pindex++) { /* - * Allocate a page in the destination object + * Allocate a page in the destination object. */ do { - dst_m = vm_page_alloc(dst_object, - OFF_TO_IDX(dst_offset), VM_ALLOC_NORMAL); + dst_m = vm_page_alloc(dst_object, dst_pindex, + VM_ALLOC_NORMAL); if (dst_m == NULL) { VM_OBJECT_UNLOCK(dst_object); VM_WAIT; @@ -1201,10 +1201,9 @@ vm_fault_copy_entry(vm_map_t dst_map, vm */ VM_OBJECT_LOCK(src_object); object = src_object; - pindex = 0; - while ((src_m = vm_page_lookup(object, pindex + - OFF_TO_IDX(dst_offset + src_offset))) == NULL && - (src_entry->protection & VM_PROT_WRITE) == 0 && + pindex = src_pindex + dst_pindex; + while ((src_m = vm_page_lookup(object, pindex)) == NULL && + src_readonly && (backing_object = object->backing_object) != NULL) { /* * Allow fallback to backing objects if we are reading.