PERFORCE change 93947 for review
John Baldwin
jhb at FreeBSD.org
Fri Mar 24 21:24:48 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=93947
Change 93947 by jhb at 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,
More information about the p4-projects
mailing list