[Lldb-commits] [PATCH] D157967: [lldb][AArch64] Use atomics to sync threads in SVE threading test
David Spickett via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 31 01:59:53 PDT 2023
DavidSpickett updated this revision to Diff 554938.
DavidSpickett added a comment.
Actually these don't need to be atomic. They aren't writing to the same locations
we just have one writer and one reader, and if the reader is delayed a bit it's
not a problem.
The volatile isn't needed at -O0 but might as well on the off chance something tries
to optimise it later.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157967/new/
https://reviews.llvm.org/D157967
Files:
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
Index: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
===================================================================
--- lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
+++ 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 @@
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 *threadY_func(void *y_arg) {
+ threadY_ready = true;
+ while (!threadX_ready) {
+ }
+
prctl(SET_VL_OPT, 8 * 2);
#ifdef USE_SSVE
SMSTART();
Index: 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/TestSVEThreadedDynamic.py
+++ lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
@@ -148,10 +148,6 @@
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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157967.554938.patch
Type: text/x-patch
Size: 2038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230831/f7ee9f3d/attachment-0001.bin>
More information about the lldb-commits
mailing list