Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 May 2002 14:10:00 -0700 (PDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 11683 for review
Message-ID:  <200205212110.g4LLA0F56843@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=11683

Change 11683 by jhb@jhb_laptop on 2002/05/21 14:09:42

	- Add more cpu_pause()s where needed.
	- Fixup whitespace in spin mutex panic case.
	- We don't need to increment 'i' twice in the case where we
	  are starting to DELAY().

Affected files ...

... //depot/projects/smpng/sys/kern/kern_mutex.c#31 edit

Differences ...

==== //depot/projects/smpng/sys/kern/kern_mutex.c#31 (text+ko) ====

@@ -488,6 +488,9 @@
 		 */
 		if ((v = m->mtx_lock) == MTX_UNOWNED) {
 			mtx_unlock_spin(&sched_lock);
+#ifdef __i386__
+			cpu_pause();
+#endif
 			continue;
 		}
 
@@ -515,6 +518,9 @@
 		    !atomic_cmpset_ptr(&m->mtx_lock, (void *)v,
 			(void *)(v | MTX_CONTESTED))) {
 			mtx_unlock_spin(&sched_lock);
+#ifdef __i386__
+			cpu_pause();
+#endif
 			continue;
 		}
 
@@ -622,20 +628,24 @@
 		/* Give interrupts a chance while we spin. */
 		critical_exit();
 		while (m->mtx_lock != MTX_UNOWNED) {
+			if (i++ < 10000000) {
 #ifdef __i386__
-			cpu_pause();
+				cpu_pause();
 #endif
-			if (i++ < 10000000)
 				continue;
-			if (i++ < 60000000)
+			}
+			if (i < 60000000)
 				DELAY(1);
 #ifdef DDB
 			else if (!db_active)
 #else
 			else
 #endif
-			panic("spin lock %s held by %p for > 5 seconds",
-			    m->mtx_object.lo_name, (void *)m->mtx_lock);
+				panic("spin lock %s held by %p for > 5 seconds",
+				    m->mtx_object.lo_name, (void *)m->mtx_lock);
+#ifdef __i386__
+			cpu_pause();
+#endif
 		}
 		critical_enter();
 	}

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205212110.g4LLA0F56843>