svn commit: r217836 - stable/7/sys/vm
John Baldwin
jhb at FreeBSD.org
Tue Jan 25 19:44:56 UTC 2011
Author: jhb
Date: Tue Jan 25 19:44:55 2011
New Revision: 217836
URL: http://svn.freebsd.org/changeset/base/217836
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/7/sys/vm/vm_map.c
stable/7/sys/vm/vm_map.h
Directory Properties:
stable/7/sys/ (props changed)
stable/7/sys/cddl/contrib/opensolaris/ (props changed)
stable/7/sys/contrib/dev/acpica/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
Modified: stable/7/sys/vm/vm_map.c
==============================================================================
--- stable/7/sys/vm/vm_map.c Tue Jan 25 19:44:42 2011 (r217835)
+++ stable/7/sys/vm/vm_map.c Tue Jan 25 19:44:55 2011 (r217836)
@@ -336,15 +336,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/7/sys/vm/vm_map.h
==============================================================================
--- stable/7/sys/vm/vm_map.h Tue Jan 25 19:44:42 2011 (r217835)
+++ stable/7/sys/vm/vm_map.h Tue Jan 25 19:44:55 2011 (r217836)
@@ -246,7 +246,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 */
};
#ifdef _KERNEL
More information about the svn-src-all
mailing list