svn commit: r230750 - user/attilio/vmcontention/sys/vm

Attilio Rao attilio at FreeBSD.org
Sun Jan 29 16:44:22 UTC 2012


Author: attilio
Date: Sun Jan 29 16:44:21 2012
New Revision: 230750
URL: http://svn.freebsd.org/changeset/base/230750

Log:
  Fix a bug in vm_radix_leaf() where the shifting start address can
  wrap-up at some point.
  This bug is triggered very easilly by indirect blocks in UFS which grow
  negative resulting in very high counts.
  
  In collabouration with:	flo

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	Sun Jan 29 16:29:06 2012	(r230749)
+++ user/attilio/vmcontention/sys/vm/vm_radix.c	Sun Jan 29 16:44:21 2012	(r230750)
@@ -458,6 +458,12 @@ restart:
 	 	 */
 		inc = 1LL << (level * VM_RADIX_WIDTH);
 		start &= ~VM_RADIX_MAX(level);
+
+		/* Avoid start address wrapping up. */
+		if ((VM_RADIX_MAXVAL - start) < inc) {
+			rnode = NULL;
+			goto out;
+		}
 		start += inc;
 		slot++;
 		CTR5(KTR_VM,
@@ -473,6 +479,10 @@ restart:
 				rnode = rnode->rn_child[slot];
 				break;
 			}
+			if ((VM_RADIX_MAXVAL - start) < inc) {
+				rnode = NULL;
+				goto out;
+			}
 		}
 		if (slot == VM_RADIX_COUNT)
 			goto restart;

Modified: user/attilio/vmcontention/sys/vm/vm_radix.h
==============================================================================
--- user/attilio/vmcontention/sys/vm/vm_radix.h	Sun Jan 29 16:29:06 2012	(r230749)
+++ user/attilio/vmcontention/sys/vm/vm_radix.h	Sun Jan 29 16:44:21 2012	(r230750)
@@ -35,6 +35,7 @@
 #define	VM_RADIX_WIDTH	5
 #define	VM_RADIX_COUNT	(1 << VM_RADIX_WIDTH)
 #define	VM_RADIX_MASK	(VM_RADIX_COUNT - 1)
+#define	VM_RADIX_MAXVAL	((vm_pindex_t)-1)
 #define	VM_RADIX_LIMIT	howmany((sizeof(vm_pindex_t) * NBBY), VM_RADIX_WIDTH)
 #define	VM_RADIX_FLAGS	0x3	/* Flag bits stored in node pointers. */
 #define	VM_RADIX_BLACK	0x1	/* Black node. (leaf only) */
@@ -46,7 +47,7 @@
 
 /* Calculates maximum value for a tree of height h. */
 #define	VM_RADIX_MAX(h)							\
-	    ((h) == VM_RADIX_LIMIT ? ((vm_pindex_t)-1) :		\
+	    ((h) == VM_RADIX_LIMIT ? VM_RADIX_MAXVAL :			\
 	    (((vm_pindex_t)1 << ((h) * VM_RADIX_WIDTH)) - 1))
 
 /*


More information about the svn-src-user mailing list