changeset 6032:a9c703859959

6532446 page_migrate() should not call PP_CLRMIGRATE(pp) without SE_EXCL lock on the page
author jj209869
date Tue, 19 Feb 2008 05:42:10 -0800
parents cabd6c04efc5
children 2d82c30467d2
files usr/src/uts/common/vm/vm_page.c
diffstat 1 files changed, 19 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/vm/vm_page.c	Tue Feb 19 02:51:39 2008 -0800
+++ b/usr/src/uts/common/vm/vm_page.c	Tue Feb 19 05:42:10 2008 -0800
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -5669,15 +5669,6 @@
 		to = lgrp_mem_choose(seg, addr, pgsz);
 
 		/*
-		 * Check to see whether we are trying to migrate page to lgroup
-		 * where it is allocated already
-		 */
-		if (to == from) {
-			PP_CLRMIGRATE(pp);
-			goto next;
-		}
-
-		/*
 		 * Need to get exclusive lock's to migrate
 		 */
 		for (i = 0; i < page_cnt; i++) {
@@ -5692,7 +5683,24 @@
 				    page_cnt);
 				break;
 			}
-		}
+
+			/*
+			 * Check to see whether we are trying to migrate
+			 * page to lgroup where it is allocated already.
+			 * If so, clear the migrate bit and skip to next
+			 * page.
+			 */
+			if (i == 0 && to == from) {
+				PP_CLRMIGRATE(ppa[0]);
+				page_downgrade(ppa[0]);
+				goto next;
+			}
+		}
+
+		/*
+		 * If all constituent pages couldn't be locked,
+		 * unlock pages locked so far and skip to next page.
+		 */
 		if (i != page_cnt) {
 			while (--i != -1) {
 				page_downgrade(ppa[i]);