New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP15 barrier instructions should be emitted before the exclusives loops #41201
Comments
Rust compiler issue: rust-lang/rust#60605 |
I'm not sure I understand why this is being deprecated, but it's not my decision, I guess. To be clear, the issue here is specifically with weak cmpxchg with release semantics, where the compiler is targeting armv6? (Next time, please include a testcase; it took me a few minutes to work that out based on just this report.) If the barrier is going to trap to the kernel, we shouldn't be putting between an ldrex and an strex, yes. If we're using a barrier we know won't trap, like dmb, we want to avoid the barrier where possible, for the sake of performance. For example, if a "release" cmpxchg fails, we don't need a barrier at all. This may not be due to contention; it might just be that the variable is in a state where the cmpxchg will always fail. This is more likely to be relevant for a "strong" cmpxchg. Independent of where we place the barrier, if we expect that cp15 barriers will trap on future Linux releases, should LLVM be changed so it never uses cp15 barriers on Linux? We can call __sync_synchronize instead. |
Actually, thinking about this a bit more, this isn't really independent. We probably should just expand all non-"monotonic" atomicrmw and cmpxchg operations to _sync* on Linux if we have ldrex, but not dmb. If we have to call a helper for the barrier anyway, there isn't much point to expanding the atomic operation inline. |
Hi, I maintain the raspbian project I was recently directed to this bug as being the root cause of an issue that has been a major PITA in the raspbian project for some time. I decided to take a bit of a look.
I agree, when people build code for "armv6" they generally expect it to work on "armv6 or better" and given the situation with these instructions going forward I decided to take a look at this myself, but I was rather out of my depth in terms of both rust and LLVM. After some searching the code I put the following patch in place, which I thought would disable the use of the cp15 barriers. --- llvm-toolchain-11-11.0.0.orig/llvm/lib/Target/ARM/ARMSubtarget.h
Unfortunately after building and installing the new llvm and clearing the cargo caches, the parking lot testsuite still hangs, I don't know if this is because my change was ineffective or because there was some other problem. Am I looking along the right lines? Does anyone know how to reproduce this issue without involving rust or swift? |
Extended Description
Symptoms
strex never succeeds and is looping indefinitely.
Environment
CP15 barrier instructions
Issue description
parking_lot author:
See attached loop.png image.
ARM engineer (Will Deacon) response on this:
Solution
Will's third point:
No fix
People aren't / won't be able to use Rust / Swift / ... on Linux with
CP15_BARRIER_EMULATION=y & abi.cp15_barrier=1 (emulation, default value)
& arm-unknown-linux-gnueabihf toolchain.
The text was updated successfully, but these errors were encountered: