Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

use armv7 memory barriers by default #158

Merged
merged 1 commit into from Jan 11, 2014

Conversation

Projects
None yet
2 participants
Member

dicej commented Jan 10, 2014

armv7 and later provide weaker cache coherency models than armv6 and
earlier, so we cannot just implement memory barriers as no-ops. This
patch uses the DMB instruction (or the equivalent OS-provided barrier
function) to implement barriers. This should fix concurrency issues
on newer chips such as the Apple A6 and A7.

If you still need to support ARMv6 devices, you should pass
"armv6=true" to make when building Avian. Ideally, the VM would
detect what kind of CPU it was executing on at runtime and direct the
JIT compiler accordingly, but I don't know how to do that on ARM.
Patches are welcome, though!

Member

dicej commented Jan 10, 2014

This addresses #153

Member

dicej commented Jan 11, 2014

Are we happy with DMB SY as a conservative option, or is DSB necessary? My understanding is that Linux's smp_*mb macros (which use DMB) are intended for synchronization among CPUs, while the *mb macros (which use DSB) are for synchronization with other devices (e.g. DMA, etc.), which would imply that DMB is sufficient for our purposes.

Contributor

joshuawarner32 commented Jan 11, 2014

Ah, that makes a lot of sense. Yes, I think DMB is a fine conservative option. It would be nice to at least leave TODOs to move to using the weaker variants of DMB where possible.

use armv7 memory barriers by default
armv7 and later provide weaker cache coherency models than armv6 and
earlier, so we cannot just implement memory barriers as no-ops.  This
patch uses the DMB instruction (or the equivalent OS-provided barrier
function) to implement barriers.  This should fix concurrency issues
on newer chips such as the Apple A6 and A7.

If you still need to support ARMv6 devices, you should pass
"armv6=true" to make when building Avian.  Ideally, the VM would
detect what kind of CPU it was executing on at runtime and direct the
JIT compiler accordingly, but I don't know how to do that on ARM.
Patches are welcome, though!
Member

dicej commented Jan 11, 2014

I just force-pushed an update with TODO comments.

joshuawarner32 added a commit that referenced this pull request Jan 11, 2014

Merge pull request #158 from dicej/armv7
use armv7 memory barriers by default

@joshuawarner32 joshuawarner32 merged commit 2ac66cb into ReadyTalk:master Jan 11, 2014

1 check passed

default The Travis CI build passed
Details

@dicej dicej deleted the dicej:armv7 branch Feb 28, 2014

dicej pushed a commit to dicej/avian that referenced this pull request Apr 21, 2014

Merge pull request #158 from dicej/armv7
use armv7 memory barriers by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment