-
Notifications
You must be signed in to change notification settings - Fork 9
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
linux-user: c11-atomic-exec-4 dejagnu test fails #48
Comments
Looks like qemu-user runs second thread with second CPU instance on This is how addition is compiled (both functions have similar output):
|
Looking into this. Did not notice this issue before. |
The Problem:While running on full system or baremetal, qemu runs arc_cpu_do_interrupt from target/arc/helper.c on each interrupt, which clears the LF flag. As such, the LF flag isn't being cleared when a thread is preempted, which breaks atomicity between them.
As the LF flag is not cleared in preemption, the llock (6) will enable scond (7) to succeed, and Thread 1 will overwrite Thread 2s' changes. Verify the problem:The multi threaded nature of the problem makes it hard to debug and get sensible information from.
and the following into helper_llock in the same file
Not forgetting the required I ran the test with these changes 10.000 times, all with success so I do believe it is a fix for it. This code simply makes llock "register" the current thread ID, and scond try and match it. Only if llock and scond run in sequence, without an llock from a different thread being preempted in between them, can scond succeed. This code also needs to be in the helper and not, say, translate.c, because in the common case (i.e. without -singlestep), the relevant preemptions happen in the middle of executing the TB and not during the build As far as I could find, I didn't see any way to do this via QEMU, and as I will be unavailable for the coming week, I leave my research here in case someone wants to take a look into a better solution. @claziss and @shahab-vahedi if you guys know of a better way to handle this case, possibly via QEMU support, please feel free to comment. P.S. |
This also seems to be the issue for the 'gcc.dg/di-sync-multithread.c' test. |
Fix for issue #48 Since an interrupt requires LF to be cleared and there is no hook for usermode interrupts, we save/validate current thread id to detect preemption and clear LF. This only needs to be done where it is relevant for LF (llock/scond variant helpers) Signed-off-by: BrunoASMauricio <[email protected]>
Fix for issue #48 Since an interrupt requires LF to be cleared and there is no hook for usermode interrupts, we save/validate current thread id to detect preemption and clear LF. This only needs to be done where it is relevant for LF (llock/scond variant helpers) Signed-off-by: BrunoASMauricio <[email protected]>
Since an interrupt requires LF to be cleared and there is no hook for usermode interrupts, we save/validate current thread id to detect preemption and clear LF. This only needs to be done where it is relevant for LF (llock/scond variant helpers). Signed-off-by: BrunoASMauricio <[email protected]>
Since an interrupt requires LF to be cleared and there is no hook for usermode interrupts, we save/validate current thread id to detect preemption and clear LF. This only needs to be done where it is relevant for LF (llock/scond variant helpers). Signed-off-by: BrunoASMauricio <[email protected]>
Since an interrupt requires LF to be cleared and there is no hook for usermode interrupts, we save/validate current thread id to detect preemption and clear LF. This only needs to be done where it is relevant for LF (llock/scond variant helpers). Signed-off-by: BrunoASMauricio <[email protected]>
Since an interrupt requires LF to be cleared and there is no hook for usermode interrupts, we save/validate current thread id to detect preemption and clear LF. This only needs to be done where it is relevant for LF (llock/scond variant helpers). Signed-off-by: BrunoASMauricio <[email protected]>
This test works fine in system qemu.
Smaller version of this test:
How to build:
The text was updated successfully, but these errors were encountered: