diff options
| author | Athira Rajeev <atrajeev@linux.ibm.com> | 2025-09-16 10:55:33 +0530 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2025-10-01 11:22:05 -0300 |
| commit | 71feffa9c08675f65192a6b0d6ce168c620ba49a (patch) | |
| tree | 3660c2a921f6dedcdb107570fd269c69ac226019 /tools/perf/util/powerpc-vpadtl.c | |
| parent | perf powerpc: Process auxtrace events and display in 'perf report -D' (diff) | |
| download | linux-71feffa9c08675f65192a6b0d6ce168c620ba49a.tar.gz linux-71feffa9c08675f65192a6b0d6ce168c620ba49a.zip | |
perf powerpc: Add event name as vpa-dtl of PERF_TYPE_SYNTH type to present DTL samples
Dispatch Trace Log details are captured as-is in PERF_RECORD_AUXTRACE
records.
To present dtl entries as samples, create an event with name as
"vpa-dtl" and type PERF_TYPE_SYNTH.
Add perf_synth_id, "PERF_SYNTH_POWERPC_VPA_DTL" as config value for the
event.
Create a sample id to be a fixed offset from evsel id.
To present the relevant fields from the "struct dtl_entry", prepare the
entries as events of type PERF_TYPE_SYNTH.
By defining as PERF_TYPE_SYNTH type, samples can be printed as part of
perf_sample__fprintf_synth in builtin-script.c
From powerpc_vpadtl_process_auxtrace_info(), invoke
auxtrace_queues__process_index() function which will queue the auxtrace
buffers by invoke auxtrace_queues__add_event().
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
Tested-by: Tejas Manhas <tejas05@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Cc: Aboorva Devarajan <aboorvad@linux.ibm.com>
Cc: Aditya Bodkhe <Aditya.Bodkhe1@ibm.com>
Cc: Hari Bathini <hbathini@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/powerpc-vpadtl.c')
| -rw-r--r-- | tools/perf/util/powerpc-vpadtl.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tools/perf/util/powerpc-vpadtl.c b/tools/perf/util/powerpc-vpadtl.c index 9aff05470b13..c92a400f669f 100644 --- a/tools/perf/util/powerpc-vpadtl.c +++ b/tools/perf/util/powerpc-vpadtl.c @@ -3,6 +3,7 @@ * VPA DTL PMU support */ +#include <linux/string.h> #include <inttypes.h> #include "color.h" #include "evlist.h" @@ -24,6 +25,7 @@ struct powerpc_vpadtl { struct perf_session *session; struct machine *machine; u32 pmu_type; + u64 sample_id; }; struct boottb_freq { @@ -215,6 +217,65 @@ static void powerpc_vpadtl_print_info(__u64 *arr) fprintf(stdout, powerpc_vpadtl_info_fmts[POWERPC_VPADTL_TYPE], arr[POWERPC_VPADTL_TYPE]); } +static void set_event_name(struct evlist *evlist, u64 id, + const char *name) +{ + struct evsel *evsel; + + evlist__for_each_entry(evlist, evsel) { + if (evsel->core.id && evsel->core.id[0] == id) { + if (evsel->name) + zfree(&evsel->name); + evsel->name = strdup(name); + break; + } + } +} + +static int +powerpc_vpadtl_synth_events(struct powerpc_vpadtl *vpa, struct perf_session *session) +{ + struct evlist *evlist = session->evlist; + struct evsel *evsel; + struct perf_event_attr attr; + bool found = false; + u64 id; + int err; + + evlist__for_each_entry(evlist, evsel) { + if (strstarts(evsel->name, "vpa_dtl")) { + found = true; + break; + } + } + + if (!found) { + pr_debug("No selected events with VPA trace data\n"); + return 0; + } + + memset(&attr, 0, sizeof(struct perf_event_attr)); + attr.size = sizeof(struct perf_event_attr); + attr.sample_type = evsel->core.attr.sample_type; + attr.sample_id_all = evsel->core.attr.sample_id_all; + attr.type = PERF_TYPE_SYNTH; + attr.config = PERF_SYNTH_POWERPC_VPA_DTL; + + /* create new id val to be a fixed offset from evsel id */ + id = evsel->core.id[0] + 1000000000; + if (!id) + id = 1; + + err = perf_session__deliver_synth_attr_event(session, &attr, id); + if (err) + return err; + + vpa->sample_id = id; + set_event_name(evlist, id, "vpa-dtl"); + + return 0; +} + /* * Process the PERF_RECORD_AUXTRACE_INFO records and setup * the infrastructure to process auxtrace events. PERF_RECORD_AUXTRACE_INFO @@ -256,8 +317,23 @@ int powerpc_vpadtl_process_auxtrace_info(union perf_event *event, powerpc_vpadtl_print_info(&auxtrace_info->priv[0]); + if (dump_trace) + return 0; + + err = powerpc_vpadtl_synth_events(vpa, session); + if (err) + goto err_free_queues; + + err = auxtrace_queues__process_index(&vpa->queues, session); + if (err) + goto err_free_queues; + return 0; +err_free_queues: + auxtrace_queues__free(&vpa->queues); + session->auxtrace = NULL; + err_free: free(vpa); return err; |
