From owner-svn-src-head@FreeBSD.ORG Thu Jun 26 16:04:04 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8CA375DF; Thu, 26 Jun 2014 16:04:04 +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 603AA2B5B; Thu, 26 Jun 2014 16:04:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5QG44kM069093; Thu, 26 Jun 2014 16:04:04 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5QG44OR069092; Thu, 26 Jun 2014 16:04:04 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201406261604.s5QG44OR069092@svn.freebsd.org> From: Alan Cox Date: Thu, 26 Jun 2014 16:04:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267917 - 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.18 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: Thu, 26 Jun 2014 16:04:04 -0000 Author: alc Date: Thu Jun 26 16:04:03 2014 New Revision: 267917 URL: http://svnweb.freebsd.org/changeset/base/267917 Log: Delay the call to crhold() in vm_map_insert() until we know that we won't have to undo it by calling crfree(). This reduces the total number of calls by vm_map_insert() to crhold() and crfree() by 45% in my tests. Eliminate an unnecessary variable from vm_map_insert(). Reviewed by: kib Tested by: pho Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Thu Jun 26 15:25:42 2014 (r267916) +++ head/sys/vm/vm_map.c Thu Jun 26 16:04:03 2014 (r267917) @@ -1127,7 +1127,6 @@ vm_map_insert(vm_map_t map, vm_object_t vm_eflags_t protoeflags; struct ucred *cred; vm_inherit_t inheritance; - boolean_t charge_prev_obj; VM_MAP_ASSERT_LOCKED(map); KASSERT((object != kmem_object && object != kernel_object) || @@ -1180,7 +1179,6 @@ vm_map_insert(vm_map_t map, vm_object_t inheritance = VM_INHERIT_DEFAULT; cred = NULL; - charge_prev_obj = FALSE; if (cow & (MAP_ACC_NO_CHARGE | MAP_NOFAULT)) goto charged; if ((cow & MAP_ACC_CHARGED) || ((prot & VM_PROT_WRITE) && @@ -1191,9 +1189,6 @@ vm_map_insert(vm_map_t map, vm_object_t object->cred == NULL, ("OVERCOMMIT: vm_map_insert o %p", object)); cred = curthread->td_ucred; - crhold(cred); - if (object == NULL && !(protoeflags & MAP_ENTRY_NEEDS_COPY)) - charge_prev_obj = TRUE; } charged: @@ -1224,7 +1219,8 @@ charged: vm_object_coalesce(prev_entry->object.vm_object, prev_entry->offset, (vm_size_t)(prev_entry->end - prev_entry->start), - (vm_size_t)(end - prev_entry->end), charge_prev_obj)) { + (vm_size_t)(end - prev_entry->end), cred != NULL && + (protoeflags & MAP_ENTRY_NEEDS_COPY) == 0)) { /* * We were able to extend the object. Determine if we * can extend the previous map entry to include the @@ -1237,8 +1233,6 @@ charged: prev_entry->end = end; vm_map_entry_resize_free(map, prev_entry); vm_map_simplify_entry(map, prev_entry); - if (cred != NULL) - crfree(cred); return (KERN_SUCCESS); } @@ -1255,10 +1249,11 @@ charged: if (cred != NULL && object != NULL && object->cred != NULL && !(prev_entry->eflags & MAP_ENTRY_NEEDS_COPY)) { /* Object already accounts for this uid. */ - crfree(cred); cred = NULL; } } + if (cred != NULL) + crhold(cred); /* * Create a new entry