mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 00:39:03 -04:00
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: 1dbfaf94cf ("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 <atrajeev@linux.ibm.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Hari Bathini <hbathini@linux.vnet.ibm.com>
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 <mpetlan@redhat.com>
Cc: Shivani Nittor <shivani@linux.ibm.com>
Cc: Tanushree Shah <tanushree.shah@ibm.com>
Cc: Tejas Manhas <tejas.manhas1@ibm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
111 lines
2.4 KiB
C
111 lines
2.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* VPA support
|
|
*/
|
|
#include <errno.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/types.h>
|
|
#include <linux/string.h>
|
|
#include <linux/zalloc.h>
|
|
|
|
#include "../../util/evlist.h"
|
|
#include "../../util/debug.h"
|
|
#include "../../util/auxtrace.h"
|
|
#include "../../util/powerpc-vpadtl.h"
|
|
#include "../../util/record.h"
|
|
#include <internal/lib.h> // page_size
|
|
|
|
#define KiB(x) ((x) * 1024)
|
|
|
|
static int
|
|
powerpc_vpadtl_recording_options(struct auxtrace_record *ar __maybe_unused,
|
|
struct evlist *evlist __maybe_unused,
|
|
struct record_opts *opts)
|
|
{
|
|
opts->full_auxtrace = true;
|
|
|
|
/*
|
|
* Set auxtrace_mmap_pages to minimum
|
|
* two pages
|
|
*/
|
|
if (!opts->auxtrace_mmap_pages) {
|
|
opts->auxtrace_mmap_pages = KiB(128) / page_size;
|
|
if (opts->mmap_pages == UINT_MAX)
|
|
opts->mmap_pages = KiB(256) / page_size;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static size_t powerpc_vpadtl_info_priv_size(struct auxtrace_record *itr __maybe_unused,
|
|
struct evlist *evlist __maybe_unused)
|
|
{
|
|
return VPADTL_AUXTRACE_PRIV_SIZE;
|
|
}
|
|
|
|
static int
|
|
powerpc_vpadtl_info_fill(struct auxtrace_record *itr __maybe_unused,
|
|
struct perf_session *session __maybe_unused,
|
|
struct perf_record_auxtrace_info *auxtrace_info,
|
|
size_t priv_size __maybe_unused)
|
|
{
|
|
auxtrace_info->type = PERF_AUXTRACE_VPA_DTL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void powerpc_vpadtl_free(struct auxtrace_record *itr)
|
|
{
|
|
free(itr);
|
|
}
|
|
|
|
static u64 powerpc_vpadtl_reference(struct auxtrace_record *itr __maybe_unused)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
struct auxtrace_record *auxtrace_record__init(struct evlist *evlist,
|
|
int *err)
|
|
{
|
|
struct auxtrace_record *aux;
|
|
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;
|
|
pos->needs_auxtrace_mmap = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!found)
|
|
return NULL;
|
|
|
|
/*
|
|
* To obtain the auxtrace buffer file descriptor, the auxtrace event
|
|
* must come first.
|
|
*/
|
|
evlist__to_front(pos->evlist, pos);
|
|
|
|
aux = zalloc(sizeof(*aux));
|
|
if (aux == NULL) {
|
|
pr_debug("aux record is NULL\n");
|
|
*err = -ENOMEM;
|
|
return NULL;
|
|
}
|
|
|
|
aux->recording_options = powerpc_vpadtl_recording_options;
|
|
aux->info_priv_size = powerpc_vpadtl_info_priv_size;
|
|
aux->info_fill = powerpc_vpadtl_info_fill;
|
|
aux->free = powerpc_vpadtl_free;
|
|
aux->reference = powerpc_vpadtl_reference;
|
|
return aux;
|
|
}
|