From owner-svn-src-stable@FreeBSD.ORG Tue Jan 25 19:44:42 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F559106564A; Tue, 25 Jan 2011 19:44:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 63CEB8FC08; Tue, 25 Jan 2011 19:44:42 +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 p0PJighR047978; Tue, 25 Jan 2011 19:44:42 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0PJig2i047975; Tue, 25 Jan 2011 19:44:42 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201101251944.p0PJig2i047975@svn.freebsd.org> From: John Baldwin Date: Tue, 25 Jan 2011 19:44:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217835 - stable/8/sys/vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2011 19:44:42 -0000 Author: jhb Date: Tue Jan 25 19:44:42 2011 New Revision: 217835 URL: http://svn.freebsd.org/changeset/base/217835 Log: MFC 214144: - Make 'vm_refcnt' volatile so that compilers won't be tempted to treat its value as a loop invariant. Currently this is a no-op because 'atomic_cmpset_int()' clobbers all memory on current architectures. - Use atomic_fetchadd_int() instead of an atomic_cmpset_int() loop to drop a reference in vmspace_free(). Modified: stable/8/sys/vm/vm_map.c stable/8/sys/vm/vm_map.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/vm/vm_map.c ============================================================================== --- stable/8/sys/vm/vm_map.c Tue Jan 25 19:27:05 2011 (r217834) +++ stable/8/sys/vm/vm_map.c Tue Jan 25 19:44:42 2011 (r217835) @@ -344,15 +344,11 @@ vmspace_dofree(struct vmspace *vm) void vmspace_free(struct vmspace *vm) { - int refcnt; if (vm->vm_refcnt == 0) panic("vmspace_free: attempt to free already freed vmspace"); - do - refcnt = vm->vm_refcnt; - while (!atomic_cmpset_int(&vm->vm_refcnt, refcnt, refcnt - 1)); - if (refcnt == 1) + if (atomic_fetchadd_int(&vm->vm_refcnt, -1) == 1) vmspace_dofree(vm); } Modified: stable/8/sys/vm/vm_map.h ============================================================================== --- stable/8/sys/vm/vm_map.h Tue Jan 25 19:27:05 2011 (r217834) +++ stable/8/sys/vm/vm_map.h Tue Jan 25 19:44:42 2011 (r217835) @@ -238,7 +238,7 @@ struct vmspace { caddr_t vm_taddr; /* (c) user virtual address of text */ caddr_t vm_daddr; /* (c) user virtual address of data */ caddr_t vm_maxsaddr; /* user VA at max stack growth */ - int vm_refcnt; /* number of references */ + volatile int vm_refcnt; /* number of references */ /* * Keep the PMAP last, so that CPU-specific variations of that * structure on a single architecture don't result in offset