LDREX/STREX and pre-emption on SMP hardware

Russell King - ARM Linux linux at arm.linux.org.uk
Mon Sep 14 10:09:09 EDT 2009


On Mon, Sep 14, 2009 at 01:21:21PM +0100, Catalin Marinas wrote:
> And here's an untested patch to clear the exclusive monitor on the
> exception return path. If you are OK with the idea, I'll do some testing
> before pushing it for upstream:

However, a plain STR is not guaranteed to change the state of the
exclusive monitor - it is implementation defined whether STR does
or not.

This is true for both the local and global exclusive monitors.  This
means that if you use STR on a location which is being used by
exclusive access instructions on another CPU:

	CPU0	CPU1
	LDREX
		STR
	STREX

results in the STR getting lost since the STREX can complete.

Basically, don't use STR on exclusive access locations - it's
certainly unsafe in a SMP environment.



More information about the linux-arm-kernel mailing list