[Lldb-commits] [lldb] 0407f68 - [lldb][AArch64] Use atomics to sync threads in SVE threading test
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 31 02:06:22 PDT 2023
Author: David Spickett
Date: 2023-08-31T10:06:16+01:00
New Revision: 0407f681a7efa61f81f885e186c25ed99aecb8d4
URL: https://github.com/llvm/llvm-project/commit/0407f681a7efa61f81f885e186c25ed99aecb8d4
DIFF: https://github.com/llvm/llvm-project/commit/0407f681a7efa61f81f885e186c25ed99aecb8d4.diff
LOG: [lldb][AArch64] Use atomics to sync threads in SVE threading test
Previously we would "process continue" then wait for the number of
threads to be 3 before proceeding with the test.
Testing this on QEMU I saw it would sometimes get stuck at this check,
with one of the threads on a breakpoint before the other had started.
We do want it to be on a breakpoint, but we need the other thread to have
at least started so lldb can interact with both.
I've also seen it timeout on the Graviton buildbot, likely the same
cause.
To fix this add 2 variables to stall either thread until the other
has started up. Then it doesn't matter which one hits its breakpoint
first, the test will just continue the one that didn't, until both
are on the expected breakpoint.
Differential Revision: https://reviews.llvm.org/D157967
Added:
Modified:
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
Removed:
################################################################################
diff --git a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
index 3ca20a1803b0fc..ecac3712674976 100644
--- a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
+++ b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
@@ -148,10 +148,6 @@ def run_sve_test(self, mode):
self.runCmd("process continue", RUN_SUCCEEDED)
- # If we start the checks too quickly, thread 3 may not have started.
- while process.GetNumThreads() < 3:
- pass
-
for idx in range(1, process.GetNumThreads()):
thread = process.GetThreadAtIndex(idx)
if thread.GetStopReason() != lldb.eStopReasonBreakpoint:
diff --git a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
index 419d2ddaa725fa..0bb6b3b57046f8 100644
--- a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
+++ b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
@@ -1,4 +1,5 @@
#include <pthread.h>
+#include <stdbool.h>
#include <sys/prctl.h>
#ifndef PR_SME_SET_VL
@@ -62,7 +63,18 @@ static inline void write_sve_registers() {
int SET_VL_OPT = PR_SVE_SET_VL;
+// These ensure that when lldb stops in one of threadX / threadY, the other has
+// at least been created. That means we can continue the other onto the expected
+// breakpoint. Otherwise we could get to the breakpoint in one thread before the
+// other has started.
+volatile bool threadX_ready = false;
+volatile bool threadY_ready = false;
+
void *threadX_func(void *x_arg) {
+ threadX_ready = true;
+ while (!threadY_ready) {
+ }
+
prctl(SET_VL_OPT, 8 * 4);
#ifdef USE_SSVE
SMSTART();
@@ -73,6 +85,10 @@ void *threadX_func(void *x_arg) {
}
void *threadY_func(void *y_arg) {
+ threadY_ready = true;
+ while (!threadX_ready) {
+ }
+
prctl(SET_VL_OPT, 8 * 2);
#ifdef USE_SSVE
SMSTART();
More information about the lldb-commits
mailing list