[PATCH][RFC] unlikely spinlocks
Joel Schopp
jschopp at austin.ibm.com
Wed Mar 16 05:15:17 EST 2005
>>On our raw spinlocks, we currently have an attempt at the lock, and if
>>we do not get it we enter a spin loop. This spinloop will likely
>>continue for awhile, and we pridict likely.
>>
>>Shouldn't we predict that we will get out of the loop so our next
>>instructions are already prefetched. Even when we miss because the lock
>>is still held, it won't matter since we are waiting anyways.
>
>
> Possibly the best thing is not to put a static prediction on it at
> all, and let the machine's dynamic branch prediction decide which path
> to predict?
It is better to predict you will get out of the loop than to let the
machine predict it. If we are wrong and go back into the loop we have
all the time in the world and have lost nothing with the wrong
prediction. We could predict wrong 5000 times in a row, get it right on
try 5001, and still come out ahead.
More information about the Linuxppc64-dev
mailing list