]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf tpebs: Fix concurrent stop races and PID reuse hazards in tpebs_stop
authorIan Rogers <irogers@google.com>
Tue, 2 Jun 2026 17:41:12 +0000 (10:41 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jun 2026 14:35:04 +0000 (11:35 -0300)
commitbded0398ac19bc808984f50023bb482ce41f7bdd
tree2ea0d180cebcde90f26aef780c7bb2d2352db08e
parent74802634e4a7e556429417963a8cbda27dd8b4b3
perf tpebs: Fix concurrent stop races and PID reuse hazards in tpebs_stop

Parallel verbose test execution can trigger a race condition in tpebs_stop
if called concurrently or when PID reuse occurs, causing finish_command()
to block or reap the wrong process.

Introduce a `tpebs_stopping` flag inside intel-tpebs.c to prevent
redundant stop execution paths, and safely restore the `cmd.pid`
temporarily only during `finish_command()` to ensure it is properly reaped,
while preventing other threads from referencing it.

Assisted-by: Gemini-CLI:Google Gemini 3
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/intel-tpebs.c