Perform a dummy stwcx. when we switch contexts. The context

being switched out may hold a reservation. The stwcx. will
clear the reservation. This is architecturally recommended.

The scenario this addresses is as follows:
1. Thread 1 performs a lwarx and as such holds a reservation.
2. Thread 1 gets switched out (before doing the matching
   stwcx.) and thread 2 is switched in.
3. Thread 2 performs a stwcx. to the same reservation granule.
   This will succeed because the processor has the reservation
   even though thread 2 didn't do the lwarx.

Note that on some processors the address given the stwcx. is
not checked. On these processors the mere condition of having
a reservation would cause the stwcx. to succeed, irrespective
of whether the addresses are the same. The dummy stwcx. is
especially important for those processors.
This commit is contained in:
Marcel Moolenaar 2009-04-04 22:23:03 +00:00
parent b6f38367b7
commit e9b3f3045d

View File

@ -155,6 +155,12 @@ cpu_switchin:
mtsr USER_SR,%r5
isync
lwz %r1,PCB_SP(%r3) /* Load the stack pointer */
/*
* Perform a dummy stwcx. to clear any reservations we may have
* inherited from the previous thread. It doesn't matter if the
* stwcx succeeds or not. pcb_context[0] can be clobbered.
*/
stwcx. %r1, 0, %r3
blr
/*