Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Mar 2006 21:24:47 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 93947 for review
Message-ID:  <200603242124.k2OLOlf2022320@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93947

Change 93947 by jhb@jhb_twclab on 2006/03/24 21:23:46

	After some help from Peter, make td_state non volatile again and
	apply the correct magic to make the one check in the adaptive spin
	treat td_state as volatile.

Affected files ...

.. //depot/projects/smpng/sys/kern/kern_mutex.c#121 edit
.. //depot/projects/smpng/sys/sys/proc.h#169 edit

Differences ...

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

@@ -551,8 +551,16 @@
 		if (m != &Giant && TD_IS_RUNNING(owner)) {
 #endif
 			turnstile_release(&m->mtx_object);
+
+			/*
+			 * Expanded TD_IS_RUNNING so that we could force
+			 * the compiler to not cache owner->td_state.
+			 * Otherwise, we wouldn't notice when the owning
+			 * thread stopped running.
+			 */
 			while (mtx_rawowner(m) == owner &&
-			    TD_IS_RUNNING(owner)) {
+			    ((volatile struct thread *)owner)->td_state ==
+			    TDS_RUNNING) {
 				cpu_spinwait();
 			}
 			continue;

==== //depot/projects/smpng/sys/sys/proc.h#169 (text+ko) ====

@@ -311,7 +311,7 @@
  * or already have been set in the allocator, constructor, etc.
  */
 	struct pcb	*td_pcb;	/* (k) Kernel VA of pcb and kstack. */
-	volatile enum {
+	enum {
 		TDS_INACTIVE = 0x0,
 		TDS_INHIBITED,
 		TDS_CAN_RUN,



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