From: Athira Rajeev <atrajeev@linux.ibm.com>
To: acme@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com,
james.clark@linaro.org, tmricht@linux.ibm.com,
maddy@linux.ibm.com, irogers@google.com, namhyung@kernel.org
Cc: linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
atrajeev@linux.ibm.com, hbathini@linux.vnet.ibm.com,
tejas05@linux.ibm.com, tshah@linux.ibm.com
Subject: [PATCH] perf bench breakpoint: Isolate watched variable to prevent SIGTRAP in active_thread
Date: Wed, 2 Dec 2026 14:50:48 +0530 [thread overview]
Message-ID: <20261202092048.62028-1-atrajeev@linux.ibm.com> (raw)
While running the new 'perf bench tests' suite introduced in the series
"perf tests: Add coverage for the untested perf subcommands", a SIGTRAP
core dump was observed on powerpc (ppc64le) when running:
# ./perf bench breakpoint enable -p 1 -a 1
# Running 'breakpoint/enable' benchmark:
Trace/breakpoint trap (core dumped)
In bench_breakpoint_enable(), 'done' (flag passed to active_thread)
and 'watched' (the target of the hardware read/write watchpoint) are both
allocated as adjacent local stack variables:
&watched = stack_base + 3 (1 byte)
&done = stack_base + 4 (4 bytes)
On powerpc, hardware watchpoint match ranges are always 8-byte doubleword
aligned (HW_BREAKPOINT_SIZE = 8). As a result, 'watched' and 'done' fall
within the exact same 8-byte aligned doubleword window
[stack_base ... stack_base + 7].
When active_thread actively spins loading 'done', every atomic load
instruction hits the hardware watchpoint set on 'watched', triggering
an unhandled SIGTRAP and terminating the benchmark.
Fix this by dynamically allocating 'watched' on the heap so it does
not share an aligned doubleword with stack variables.
Fixes: 68a6772f11dbb ("perf bench: Add breakpoint benchmarks")
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
---
tools/perf/bench/breakpoint.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tools/perf/bench/breakpoint.c b/tools/perf/bench/breakpoint.c
index 1b7cd4481bd2..1f52775621b0 100644
--- a/tools/perf/bench/breakpoint.c
+++ b/tools/perf/bench/breakpoint.c
@@ -198,7 +198,7 @@ static const char * const enable_usage[] = {
int bench_breakpoint_enable(int argc, const char **argv)
{
unsigned int i, nthreads, result_usec, done = 0;
- char watched;
+ char *watched;
int fd;
pthread_t *threads;
struct timeval start, stop, diff;
@@ -207,9 +207,14 @@ int bench_breakpoint_enable(int argc, const char **argv)
usage_with_options(enable_usage, enable_options);
exit(EXIT_FAILURE);
}
- fd = breakpoint_setup(&watched);
+ watched = malloc(sizeof(*watched));
+ if (!watched)
+ exit((perror("malloc"), EXIT_FAILURE));
+
+ fd = breakpoint_setup(watched);
if (fd < 0) {
+ free(watched);
if (fd == -ENODEV) {
printf("Skipping perf bench breakpoint enable: No hardware support\n");
return 0;
@@ -242,6 +247,7 @@ int bench_breakpoint_enable(int argc, const char **argv)
pthread_join(threads[i], NULL);
free(threads);
close(fd);
+ free(watched);
switch (bench_format) {
case BENCH_FORMAT_DEFAULT:
printf("# Enabled/disabled breakpoint %d time with %d passive and %d active threads\n",
--
2.52.0
next reply other threads:[~2026-12-02 9:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 9:20 Athira Rajeev [this message]
2026-12-02 9:26 ` [PATCH] perf bench breakpoint: Isolate watched variable to prevent SIGTRAP in active_thread sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202092048.62028-1-atrajeev@linux.ibm.com \
--to=atrajeev@linux.ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=hbathini@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=namhyung@kernel.org \
--cc=tejas05@linux.ibm.com \
--cc=tmricht@linux.ibm.com \
--cc=tshah@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.