[PATCH 6.18 0617/1611] powerpc tools perf: Initialize error code in auxtrace_record_init function
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2026-07-21 18:04:04
Also in:
linux-patches, stable
Subsystem:
performance events subsystem, the rest · Maintainers:
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Linus Torvalds
6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Athira Rajeev <redacted>
[ Upstream commit 789d22d77879eabb042627f6627cdb62787bc142 ]
perf trace record fails some cases in powerpc
# perf test "perf trace record and replay"
128: perf trace record and replay : FAILED!
# perf trace record sleep 1
# echo $?
32
This is happening because of non-zero err value from
auxtrace_record__init() function.
static int record__auxtrace_init(struct record *rec)
{
int err;
if ((rec->opts.auxtrace_snapshot_opts || rec->opts.auxtrace_sample_opts)
&& record__threads_enabled(rec)) {
pr_err("AUX area tracing options are not available in parallel streaming mode.\n");
return -EINVAL;
}
if (!rec->itr) {
rec->itr = auxtrace_record__init(rec->evlist, &err);
if (err)
return err;
}
Here "int err" is not initialised. The code expects "err" to be set from
auxtrace_record__init() function.
Update auxtrace_record__init() in arch/powerpc/util/auxtrace.c to clear
err value in the beginning.
- Clear err value in beginning of function. Any fail later will
set appropriate return code to err.
- Even if we haven't found any event for auxtrace, perf record
should continue for other events. NULL return
will indicate that there is no auxtrace record initialized.
- Not having "err" set here will affect monitoring of other events
also because perf record will fail seeing random value in err.
Set err to -EINVAL before invoking auxtrace_record__init() in
builtin-record.c
With the fix,
# perf trace record sleep 1
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.033 MB perf.data (228 samples) ]
Fixes: 1dbfaf94cf66ec4b ("perf powerpc: Add basic CONFIG_AUXTRACE support for VPA pmu on powerpc")
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Athira Rajeev <redacted>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Athira Rajeev <redacted>
Cc: Hari Bathini <redacted>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Petlan <redacted>
Cc: Shivani Nittor <redacted>
Cc: Tanushree Shah <redacted>
Cc: Tejas Manhas <redacted>
Cc: Thomas Richter <redacted>
Signed-off-by: Arnaldo Carvalho de Melo <redacted>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/perf/arch/powerpc/util/auxtrace.c | 6 ++++++
tools/perf/builtin-record.c | 1 +
2 files changed, 7 insertions(+)
diff --git a/tools/perf/arch/powerpc/util/auxtrace.c b/tools/perf/arch/powerpc/util/auxtrace.c
index 62c6f67f1bbe66..57f2910c0b0198 100644
--- a/tools/perf/arch/powerpc/util/auxtrace.c
+++ b/tools/perf/arch/powerpc/util/auxtrace.c@@ -70,6 +70,12 @@ struct auxtrace_record *auxtrace_record__init(struct evlist *evlist, struct evsel *pos; int found = 0; + /* + * Set err value to zero here. Any fail later + * will set appropriate return code to err. + */ + *err = 0; + evlist__for_each_entry(evlist, pos) { if (strstarts(pos->name, "vpa_dtl")) { found = 1;
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b1fb87016d5aa9..2563ef66a4d946 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c@@ -867,6 +867,7 @@ static int record__auxtrace_init(struct record *rec) } if (!rec->itr) { + err = -EINVAL; rec->itr = auxtrace_record__init(rec->evlist, &err); if (err) return err;
--
2.53.0