[PATCH v8 8/8] perf tests: keep bp_signal memory accesses visible
Himanshu Chauhan
himanshu.chauhan at oss.qualcomm.com
Fri Nov 6 18:39:17 PST 2026
In the breakpoint signal handler test, a breakpoint is set on
__test_function. Keep that helper as a real call target so the breakpoint
has a stable address.
The test also relies on the watched variable being accessed as distinct
memory operations. Use READ_ONCE() and WRITE_ONCE() for those accesses
instead of making the object volatile, so the source marks the exact
operations that must be preserved.
Signed-off-by: Himanshu Chauhan <himanshu.chauhan at oss.qualcomm.com>
---
tools/perf/tests/bp_signal.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index f580ba7486b1..2e4f7747d32f 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -36,15 +36,14 @@ static int fd3;
static int overflows;
static int overflows_2;
-static volatile long the_var;
-
+static long the_var;
/*
* Use ASM to ensure watchpoint and breakpoint can be triggered
* at one instruction.
*/
#if defined (__x86_64__)
-extern void __test_function(volatile long *ptr);
+extern void __test_function(long *ptr);
asm (
".pushsection .text;"
".globl __test_function\n"
@@ -54,16 +53,19 @@ asm (
"ret\n"
".popsection\n");
#else
-static void __test_function(volatile long *ptr)
+static noinline void __test_function(long *ptr)
{
- *ptr = 0x1234;
+ WRITE_ONCE(*ptr, 0x1234);
}
#endif
static noinline int test_function(void)
{
+ long value;
+
__test_function(&the_var);
- the_var++;
+ value = READ_ONCE(the_var);
+ WRITE_ONCE(the_var, value + 1);
return time(NULL);
}
--
2.43.0
More information about the linux-riscv
mailing list