svn commit: r228312 - user/attilio/vmcontention/sys/vm
Attilio Rao
attilio at FreeBSD.org
Tue Dec 6 19:04:46 UTC 2011
Author: attilio
Date: Tue Dec 6 19:04:45 2011
New Revision: 228312
URL: http://svn.freebsd.org/changeset/base/228312
Log:
- Make rn_count 32-bits as it will naturally pad for 32-bit arches
- Avoid to use atomic to manipulate it at level0 because it seems
unneeded and introduces a bug on big-endian architectures where only
the top half (2 bits) of the double-words are written (as sparc64,
for example, doesn't support atomics at 16-bits) heading to a wrong
handling of rn_count.
Reported by: flo, andreast
Found by: marius
No answer by: jeff
Modified:
user/attilio/vmcontention/sys/vm/vm_radix.c
user/attilio/vmcontention/sys/vm/vm_radix.h
Modified: user/attilio/vmcontention/sys/vm/vm_radix.c
==============================================================================
--- user/attilio/vmcontention/sys/vm/vm_radix.c Tue Dec 6 18:01:09 2011 (r228311)
+++ user/attilio/vmcontention/sys/vm/vm_radix.c Tue Dec 6 19:04:45 2011 (r228312)
@@ -344,7 +344,7 @@ vm_radix_insert(struct vm_radix *rtree,
rnode->rn_child[slot], (u_long)index));
val = (void *)((uintptr_t)val | VM_RADIX_BLACK);
rnode->rn_child[slot] = val;
- atomic_add_int((volatile int *)&rnode->rn_count, 1);
+ rnode->rn_count++;
CTR6(KTR_VM,
"insert: tree %p, index %ju, level %d, slot %d, rnode %p, count %u",
rtree, (uintmax_t)index, level, slot, rnode, rnode->rn_count);
@@ -681,14 +681,7 @@ vm_radix_remove(struct vm_radix *rtree,
(rnode != NULL) ? rnode->rn_child[slot] : NULL,
(rnode != NULL) ? rnode->rn_count : 0);
rnode->rn_child[slot] = NULL;
- /*
- * Use atomics for the last level since red and black
- * will both adjust it.
- */
- if (level == 0)
- atomic_add_int((volatile int *)&rnode->rn_count, -1);
- else
- rnode->rn_count--;
+ rnode->rn_count--;
/*
* Only allow black removes to prune the tree.
*/
Modified: user/attilio/vmcontention/sys/vm/vm_radix.h
==============================================================================
--- user/attilio/vmcontention/sys/vm/vm_radix.h Tue Dec 6 18:01:09 2011 (r228311)
+++ user/attilio/vmcontention/sys/vm/vm_radix.h Tue Dec 6 19:04:45 2011 (r228312)
@@ -61,8 +61,8 @@ struct vm_radix {
CTASSERT(VM_RADIX_HEIGHT >= VM_RADIX_LIMIT);
struct vm_radix_node {
- void *rn_child[VM_RADIX_COUNT]; /* Child nodes. */
- volatile uint16_t rn_count; /* Valid children. */
+ void *rn_child[VM_RADIX_COUNT]; /* Child nodes. */
+ uint32_t rn_count; /* Valid children. */
};
void vm_radix_init(void);
More information about the svn-src-user
mailing list