Constify tool pointers
Subsystems (4)
Ian Rogers
reviewerv7 cover Constify tool pointers
struct perf_tool provides a set of function pointers that are called through when processing perf data. To make filling the pointers less cumbersome, if they are NULL perf_tools__fill_defaults will add default do nothing implementations.
This change refactors struct perf_tool to have an init function that provides the default implementation. The special use of NULL and perf_tools__fill_defaults are removed. As a consequence the tool pointers can then all be made const, which better reflects the behavior a particular perf command would expect of the tool and to some extent can reduce the cognitive load on someone working on a command.
v7: Rebase and correct Adrian's reviewed-by tags.
v6: Rebase adding Adrian's reviewed-by/tested-by and Leo's tested-by.
v5: Rebase dropping asan fix merged by Namhyung.
v4: Simplify perf_session__deliver_synth_attr_event following Adrian's
suggestions.
v3: Just remove auxtrace dummy tools [Adrian] and make s390-cpumsf
struct removal its own patch [Adrian].
v2: Remove dummy tool initialization [Adrian] and make zero sized. Add
cs-etm fix for address sanitizer build, found necessary when testing dummy tool change.
Ian Rogers (27):
perf auxtrace: Remove dummy tools
perf s390-cpumsf: Remove unused struct
perf tool: Constify tool pointers
perf tool: Move fill defaults into tool.c perf tool: Add perf_tool__init
perf kmem: Use perf_tool__init
perf buildid-list: Use perf_tool__init
perf kvm: Use perf_tool__init
perf lock: Use perf_tool__init
perf evlist: Use perf_tool__init
perf record: Use perf_tool__init
perf c2c: Use perf_tool__init
perf script: Use perf_tool__init
perf inject: Use perf_tool__init
perf report: Use perf_tool__init
perf stat: Use perf_tool__init
perf annotate: Use perf_tool__init
perf sched: Use perf_tool__init
perf mem: Use perf_tool__init
perf timechart: Use perf_tool__init
perf diff: Use perf_tool__init
perf data convert json: Use perf_tool__init perf data convert ctf: Use perf_tool__init perf test event_update: Ensure tools is initialized perf kwork: Use perf_tool__init
perf tool: Remove perf_tool__fill_defaults perf session: Constify tool
tools/perf/arch/x86/util/event.c | 4 +- tools/perf/bench/synthesize.c | 2 +- tools/perf/builtin-annotate.c | 44 ++-- tools/perf/builtin-buildid-list.c | 10 + tools/perf/builtin-c2c.c | 33 ++- tools/perf/builtin-diff.c | 30 ++- tools/perf/builtin-evlist.c | 10 +- tools/perf/builtin-inject.c | 161 ++++++------ tools/perf/builtin-kmem.c | 20 +- tools/perf/builtin-kvm.c | 19 +- tools/perf/builtin-kwork.c | 33 ++- tools/perf/builtin-lock.c | 41 ++-- tools/perf/builtin-mem.c | 37 +-- tools/perf/builtin-record.c | 47 ++-- tools/perf/builtin-report.c | 67 +++-- tools/perf/builtin-sched.c | 50 ++-- tools/perf/builtin-script.c | 106 ++++---- tools/perf/builtin-stat.c | 26 +- tools/perf/builtin-timechart.c | 25 +- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 4 +- tools/perf/tests/cpumap.c | 6 +- tools/perf/tests/dlfilter-test.c | 2 +- tools/perf/tests/dwarf-unwind.c | 2 +- tools/perf/tests/event_update.c | 9 +- tools/perf/tests/stat.c | 6 +- tools/perf/tests/thread-map.c | 2 +- tools/perf/util/Build | 1 + tools/perf/util/arm-spe.c | 55 +---- tools/perf/util/auxtrace.c | 12 +- tools/perf/util/auxtrace.h | 20 +- tools/perf/util/bpf-event.c | 4 +- tools/perf/util/build-id.c | 34 +-- tools/perf/util/build-id.h | 8 +- tools/perf/util/cs-etm.c | 39 +-- tools/perf/util/data-convert-bt.c | 34 ++- tools/perf/util/data-convert-json.c | 47 ++-- tools/perf/util/event.c | 54 ++-- tools/perf/util/event.h | 38 +-- tools/perf/util/header.c | 6 +- tools/perf/util/header.h | 4 +- tools/perf/util/hisi-ptt.c | 6 +- tools/perf/util/intel-bts.c | 37 +-- tools/perf/util/intel-pt.c | 30 +-- tools/perf/util/jitdump.c | 4 +- tools/perf/util/s390-cpumsf.c | 11 +- tools/perf/util/session.c | 366 +++------------------------- tools/perf/util/session.h | 9 +- tools/perf/util/synthetic-events.c | 80 +++--- tools/perf/util/synthetic-events.h | 70 +++--- tools/perf/util/tool.c | 294 ++++++++++++++++++++++ tools/perf/util/tool.h | 18 +- tools/perf/util/tsc.c | 2 +- 53 files changed, 978 insertions(+), 1103 deletions(-) create mode 100644 tools/perf/util/tool.c
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 1/27 perf auxtrace: Remove dummy tools
Add perf_session__deliver_synth_attr_event that synthesizes a perf_record_header_attr event with one id. Remove use of perf_event__synthesize_attr that necessitates the use of the dummy tool in order to pass the session.
--- tools/perf/util/arm-spe.c | 49 ++++++++----------------------------- tools/perf/util/cs-etm.c | 33 ++----------------------- tools/perf/util/intel-bts.c | 31 +---------------------- tools/perf/util/intel-pt.c | 24 +----------------- tools/perf/util/session.c | 24 ++++++++++++++++++ tools/perf/util/session.h | 3 +++ 6 files changed, 41 insertions(+), 123 deletions(-)
tools/perf/util/arm-spe.c +10 -39
@@ -1073,35 +1073,6 @@ static void arm_spe_print_info(__u64 *arr)fprintf (stdout, arm_spe_info_fmts[ARM_SPE_PMU_TYPE ], arr[ARM_SPE_PMU_TYPE ]); } -struct arm_spe_synth { -struct perf_tool dummy_tool; -struct perf_session *session; -}; - -static int arm_spe_event_synth (struct perf_tool *tool, -union perf_event *event, -struct perf_sample *sample__maybe_unused , -struct machine *machine__maybe_unused ) -{ -struct arm_spe_synth *arm_spe_synth = - container_of(tool, struct arm_spe_synth, dummy_tool); - -return perf_session__deliver_synth_event (arm_spe_synth->session, - event,NULL ); -} - -static int arm_spe_synth_event (struct perf_session *session, -struct perf_event_attr *attr,u64 id) -{ -struct arm_spe_synth arm_spe_synth; - -memset (&arm_spe_synth,0 ,sizeof (struct arm_spe_synth )); - arm_spe_synth.session = session; - -return perf_event__synthesize_attr (&arm_spe_synth.dummy_tool, attr,1 , - &id, arm_spe_event_synth); -} -static void arm_spe_set_event_name (struct evlist *evlist,u64 id,const char *name) {
@@ -1172,7 +1143,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_flc = true;/* Level 1 data cache miss */ - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->l1d_miss_id = id;
@@ -1180,7 +1151,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id +=1 ;/* Level 1 data cache access */ - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->l1d_access_id = id;
@@ -1192,7 +1163,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_llc = true;/* Last level cache miss */ - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->llc_miss_id = id;
@@ -1200,7 +1171,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id +=1 ;/* Last level cache access */ - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->llc_access_id = id;
@@ -1212,7 +1183,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_tlb = true;/* TLB miss */ - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->tlb_miss_id = id;
@@ -1220,7 +1191,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id +=1 ;/* TLB access */ - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->tlb_access_id = id;
@@ -1232,7 +1203,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_branch = true;/* Branch miss */ - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->branch_miss_id = id;
@@ -1244,7 +1215,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_remote_access = true;/* Remote access */ - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->remote_access_id = id;
@@ -1255,7 +1226,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session)if (spe->synth_opts.mem) { spe->sample_memory = true; - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->memory_id = id;
@@ -1276,7 +1247,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) attr.config =PERF_COUNT_HW_INSTRUCTIONS ; attr.sample_period = spe->synth_opts.period; spe->instructions_sample_period = attr.sample_period; - err =arm_spe_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; spe->instructions_id = id;
tools/perf/util/cs-etm.c +2 -31
@@ -1599,35 +1599,6 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq,return ret; } -struct cs_etm_synth { -struct perf_tool dummy_tool; -struct perf_session *session; -}; - -static int cs_etm__event_synth (struct perf_tool *tool, -union perf_event *event, -struct perf_sample *sample__maybe_unused , -struct machine *machine__maybe_unused ) -{ -struct cs_etm_synth *cs_etm_synth = - container_of(tool, struct cs_etm_synth, dummy_tool); - -return perf_session__deliver_synth_event (cs_etm_synth->session, - event,NULL ); -} - -static int cs_etm__synth_event (struct perf_session *session, -struct perf_event_attr *attr,u64 id) -{ -struct cs_etm_synth cs_etm_synth; - -memset (&cs_etm_synth,0 ,sizeof (struct cs_etm_synth )); - cs_etm_synth.session = session; - -return perf_event__synthesize_attr (&cs_etm_synth.dummy_tool, attr,1 , - &id, cs_etm__event_synth); -} -static int cs_etm__synth_events (struct cs_etm_auxtrace *etm,struct perf_session *session) {
@@ -1679,7 +1650,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, attr.config =PERF_COUNT_HW_BRANCH_INSTRUCTIONS ; attr.sample_period =1 ; attr.sample_type |=PERF_SAMPLE_ADDR ; - err =cs_etm__synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; etm->branches_sample_type = attr.sample_type;
@@ -1702,7 +1673,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, attr.config =PERF_COUNT_HW_INSTRUCTIONS ; attr.sample_period = etm->synth_opts.period; etm->instructions_sample_period = attr.sample_period; - err =cs_etm__synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err)return err; etm->instructions_sample_type = attr.sample_type;
tools/perf/util/intel-bts.c +1 -30
@@ -737,35 +737,6 @@ static bool intel_bts_evsel_is_auxtrace(struct perf_session *session,return evsel->core.attr.type == bts->pmu_type; } -struct intel_bts_synth { -struct perf_tool dummy_tool; -struct perf_session *session; -}; - -static int intel_bts_event_synth (struct perf_tool *tool, -union perf_event *event, -struct perf_sample *sample__maybe_unused , -struct machine *machine__maybe_unused ) -{ -struct intel_bts_synth *intel_bts_synth = - container_of(tool, struct intel_bts_synth, dummy_tool); - -return perf_session__deliver_synth_event (intel_bts_synth->session, - event,NULL ); -} - -static int intel_bts_synth_event (struct perf_session *session, -struct perf_event_attr *attr,u64 id) -{ -struct intel_bts_synth intel_bts_synth; - -memset (&intel_bts_synth,0 ,sizeof (struct intel_bts_synth )); - intel_bts_synth.session = session; - -return perf_event__synthesize_attr (&intel_bts_synth.dummy_tool, attr,1 , - &id, intel_bts_event_synth); -} -static int intel_bts_synth_events (struct intel_bts *bts,struct perf_session *session) {
@@ -814,7 +785,7 @@ static int intel_bts_synth_events(struct intel_bts *bts, attr.sample_type |=PERF_SAMPLE_ADDR ;pr_debug ("Synthesizing 'branches' event with id %" PRIu64" sample type %#" PRIx64"\n" , id, (u64 )attr.sample_type); - err =intel_bts_synth_event (session, &attr, id); + err =perf_session__deliver_synth_attr_event (session, &attr, id);if (err) {pr_err ("%s: failed to synthesize 'branches' event type\n" , __func__);
tools/perf/util/intel-pt.c +1 -23
@@ -3659,37 +3659,15 @@ static int intel_pt_queue_data(struct perf_session *session, data_offset, timestamp); } -struct intel_pt_synth { -struct perf_tool dummy_tool; -struct perf_session *session; -}; - -static int intel_pt_event_synth (struct perf_tool *tool, -union perf_event *event, -struct perf_sample *sample__maybe_unused , -struct machine *machine__maybe_unused ) -{ -struct intel_pt_synth *intel_pt_synth = - container_of(tool, struct intel_pt_synth, dummy_tool); - -return perf_session__deliver_synth_event (intel_pt_synth->session, event, -NULL ); -} -static int intel_pt_synth_event (struct perf_session *session,const char *name,struct perf_event_attr *attr,u64 id) { -struct intel_pt_synth intel_pt_synth;int err;pr_debug ("Synthesizing '%s' event with id %" PRIu64" sample type %#" PRIx64"\n" , name, id, (u64 )attr->sample_type); -memset (&intel_pt_synth,0 ,sizeof (struct intel_pt_synth )); - intel_pt_synth.session = session; - - err =perf_event__synthesize_attr (&intel_pt_synth.dummy_tool, attr,1 , - &id, intel_pt_event_synth); + err =perf_session__deliver_synth_attr_event (session, attr, id);if (err)pr_err ("%s: failed to synthesize '%s' event type\n" , __func__, name);
tools/perf/util/session.c +24 -0
@@ -1769,6 +1769,30 @@ int perf_session__deliver_synth_event(struct perf_session *session,return machines__deliver_event (&session->machines, evlist, event, sample, tool,0 ,NULL ); } +int perf_session__deliver_synth_attr_event (struct perf_session *session, +const struct perf_event_attr *attr, +u64 id) +{ +union { +struct { +struct perf_record_header_attr attr; +u64 ids[1 ]; + } attr_id; +union perf_event ev; + } ev = { + .attr_id.attr.header.type =PERF_RECORD_HEADER_ATTR , + .attr_id.attr.header.size =sizeof (ev.attr_id), + .attr_id.ids[0 ] = id, + }; + +if (attr->size !=sizeof (ev.attr_id.attr.attr)) { +pr_debug ("Unexpected perf_event_attr size\n" ); +return -EINVAL ; + } + ev.attr_id.attr.attr = *attr; +return perf_session__deliver_synth_event (session, &ev.ev,NULL ); +} +static void event_swap (union perf_event *event,bool sample_id_all) {perf_event__swap_op swap;
tools/perf/util/session.h +3 -0
@@ -154,6 +154,9 @@ extern volatile int session_done;int perf_session__deliver_synth_event (struct perf_session *session,union perf_event *event,struct perf_sample *sample); +int perf_session__deliver_synth_attr_event (struct perf_session *session, +const struct perf_event_attr *attr, +u64 id);int perf_session__dsos_hit_all (struct perf_session *session);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 2/27 perf s390-cpumsf: Remove unused struct
In reply to Ian Rogersstruct s390_cpumsf_synth was likely cargo culted from other auxtrace examples. It has no users, so remove.
--- tools/perf/util/s390-cpumsf.c | 5 ----- 1 file changed, 5 deletions(-)
tools/perf/util/s390-cpumsf.c +0 -5
@@ -952,11 +952,6 @@ s390_cpumsf_process_event(struct perf_session *session,return err; } -struct s390_cpumsf_synth { -struct perf_tool cpumsf_tool; -struct perf_session *session; -}; - static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused,
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 3/27 perf tool: Constify tool pointers
In reply to Ian RogersThe tool pointer (to a struct largely of function pointers) is passed around but is unchanged except at initialization. Change parameter and variable types to be const to lower the possibilities of what could happen with a tool.
--- tools/perf/arch/x86/util/event.c | 4 +- tools/perf/bench/synthesize.c | 2 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-inject.c | 70 ++++++++++++------------- tools/perf/builtin-kmem.c | 3 +- tools/perf/builtin-kvm.c | 4 +- tools/perf/builtin-kwork.c | 22 ++++---- tools/perf/builtin-lock.c | 4 +- tools/perf/builtin-mem.c | 4 +- tools/perf/builtin-record.c | 14 ++--- tools/perf/builtin-report.c | 12 ++--- tools/perf/builtin-sched.c | 34 ++++++------ tools/perf/builtin-script.c | 41 ++++++++------- tools/perf/builtin-stat.c | 8 +-- tools/perf/builtin-timechart.c | 8 +-- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 4 +- tools/perf/tests/cpumap.c | 6 +-- tools/perf/tests/dlfilter-test.c | 2 +- tools/perf/tests/dwarf-unwind.c | 2 +- tools/perf/tests/event_update.c | 8 +-- tools/perf/tests/stat.c | 6 +-- tools/perf/tests/thread-map.c | 2 +- tools/perf/util/arm-spe.c | 6 +-- tools/perf/util/auxtrace.c | 12 ++--- tools/perf/util/auxtrace.h | 20 ++++---- tools/perf/util/bpf-event.c | 4 +- tools/perf/util/build-id.c | 4 +- tools/perf/util/build-id.h | 4 +- tools/perf/util/cs-etm.c | 6 +-- tools/perf/util/data-convert-bt.c | 4 +- tools/perf/util/data-convert-json.c | 4 +- tools/perf/util/event.c | 34 ++++++------ tools/perf/util/event.h | 34 ++++++------ tools/perf/util/header.c | 6 +-- tools/perf/util/header.h | 4 +- tools/perf/util/hisi-ptt.c | 6 +-- tools/perf/util/intel-bts.c | 6 +-- tools/perf/util/intel-pt.c | 6 +-- tools/perf/util/jitdump.c | 4 +- tools/perf/util/s390-cpumsf.c | 6 +-- tools/perf/util/session.c | 30 +++++------ tools/perf/util/session.h | 2 +- tools/perf/util/synthetic-events.c | 80 ++++++++++++++--------------- tools/perf/util/synthetic-events.h | 70 ++++++++++++------------- tools/perf/util/tool.h | 8 +-- tools/perf/util/tsc.c | 2 +- 49 files changed, 314 insertions(+), 316 deletions(-)
tools/perf/arch/x86/util/event.c +2 -2
@@ -15,7 +15,7 @@ #if defined(__x86_64__) struct perf_event__synthesize_extra_kmaps_cb_args { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; union perf_event *event;
@@ -65,7 +65,7 @@ static int perf_event__synthesize_extra_kmaps_cb(struct map *map, void *data)return 0 ; } -int perf_event__synthesize_extra_kmaps (struct perf_tool *tool, +int perf_event__synthesize_extra_kmaps (const struct perf_tool *tool,perf_event__handler_t process,struct machine *machine) {
tools/perf/bench/synthesize.c +1 -1
@@ -49,7 +49,7 @@ static const char *const bench_usage[] = {static atomic_t event_count; -static int process_synthesized_event (struct perf_tool *tool__maybe_unused , +static int process_synthesized_event (const struct perf_tool *tool__maybe_unused ,union perf_event *event__maybe_unused ,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
tools/perf/builtin-annotate.c +1 -1
@@ -279,7 +279,7 @@ static int evsel__add_sample(struct evsel *evsel, struct perf_sample *sample,return ret; } -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
tools/perf/builtin-c2c.c +1 -1
@@ -273,7 +273,7 @@ static void compute_stats(struct c2c_hist_entry *c2c_he,update_stats (&cstats->load, weight); } -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
tools/perf/builtin-diff.c +1 -1
@@ -388,7 +388,7 @@ struct hist_entry_ops block_hist_ops = { .free = block_hist_free, }; -static int diff__process_sample_event(struct perf_tool *tool, +static int diff__process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
tools/perf/builtin-inject.c +35 -35
279 lines not on this page · raw message
tools/perf/builtin-kmem.c +1 -2
@@ -955,7 +955,7 @@ static bool perf_kmem__skip_sample(struct perf_sample *sample)typedef int (*tracepoint_handler )(struct evsel *evsel,struct perf_sample *sample); -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
@@ -2061,4 +2061,3 @@ int cmd_kmem(int argc, const char **argv)return ret; } -
tools/perf/builtin-kvm.c +2 -2
@@ -1166,7 +1166,7 @@ static void print_result(struct perf_kvm_stat *kvm) }#if defined(HAVE_TIMERFD_SUPPORT ) && defined(HAVE_LIBTRACEEVENT ) -static int process_lost_event (struct perf_tool *tool, +static int process_lost_event (const struct perf_tool *tool,union perf_event *event__maybe_unused ,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -1187,7 +1187,7 @@ static bool skip_sample(struct perf_kvm_stat *kvm,return false; } -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
tools/perf/builtin-kwork.c +11 -11
@@ -958,7 +958,7 @@ static int top_sched_switch_event(struct perf_kwork *kwork, }static struct kwork_class kwork_irq; -static int process_irq_handler_entry_event (struct perf_tool *tool, +static int process_irq_handler_entry_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -971,7 +971,7 @@ static int process_irq_handler_entry_event(struct perf_tool *tool,return 0 ; } -static int process_irq_handler_exit_event (struct perf_tool *tool, +static int process_irq_handler_exit_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1037,7 +1037,7 @@ static struct kwork_class kwork_irq = { };static struct kwork_class kwork_softirq; -static int process_softirq_raise_event (struct perf_tool *tool, +static int process_softirq_raise_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1051,7 +1051,7 @@ static int process_softirq_raise_event(struct perf_tool *tool,return 0 ; } -static int process_softirq_entry_event (struct perf_tool *tool, +static int process_softirq_entry_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1065,7 +1065,7 @@ static int process_softirq_entry_event(struct perf_tool *tool,return 0 ; } -static int process_softirq_exit_event (struct perf_tool *tool, +static int process_softirq_exit_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1167,7 +1167,7 @@ static struct kwork_class kwork_softirq = { };static struct kwork_class kwork_workqueue; -static int process_workqueue_activate_work_event (struct perf_tool *tool, +static int process_workqueue_activate_work_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1181,7 +1181,7 @@ static int process_workqueue_activate_work_event(struct perf_tool *tool,return 0 ; } -static int process_workqueue_execute_start_event (struct perf_tool *tool, +static int process_workqueue_execute_start_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1195,7 +1195,7 @@ static int process_workqueue_execute_start_event(struct perf_tool *tool,return 0 ; } -static int process_workqueue_execute_end_event (struct perf_tool *tool, +static int process_workqueue_execute_end_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1266,7 +1266,7 @@ static struct kwork_class kwork_workqueue = { };static struct kwork_class kwork_sched; -static int process_sched_switch_event (struct perf_tool *tool, +static int process_sched_switch_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1945,12 +1945,12 @@ static int perf_kwork__report(struct perf_kwork *kwork)return 0 ; } -typedef int (*tracepoint_handler )(struct perf_tool *tool, +typedef int (*tracepoint_handler )(const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine); -static int perf_kwork__process_tracepoint_sample(struct perf_tool *tool, +static int perf_kwork__process_tracepoint_sample(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel,
tools/perf/builtin-lock.c +2 -2
@@ -1501,7 +1501,7 @@ static const struct evsel_str_handler contention_tracepoints[] = { { "lock:contention_end", evsel__process_contention_end, }, }; -static int process_event_update (struct perf_tool *tool, +static int process_event_update (const struct perf_tool *tool,union perf_event *event,struct evlist **pevlist) {
@@ -1520,7 +1520,7 @@ static int process_event_update(struct perf_tool *tool,typedef int (*tracepoint_handler )(struct evsel *evsel,struct perf_sample *sample); -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
tools/perf/builtin-mem.c +2 -2
@@ -179,7 +179,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem, }static int -dump_raw_samples (struct perf_tool *tool, +dump_raw_samples (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -253,7 +253,7 @@ dump_raw_samples(struct perf_tool *tool,return 0 ; } -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused,
tools/perf/builtin-record.c +7 -7
@@ -609,7 +609,7 @@ static int record__comp_enabled(struct record *rec)return rec->opts.comp_level >0 ; } -static int process_synthesized_event (struct perf_tool *tool, +static int process_synthesized_event (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -620,7 +620,7 @@ static int process_synthesized_event(struct perf_tool *tool,static struct mutex synth_lock; -static int process_locked_synthesized_event (struct perf_tool *tool, +static int process_locked_synthesized_event (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -705,7 +705,7 @@ static void record__sig_exit(void)#ifdef HAVE_AUXTRACE_SUPPORT -static int record__process_auxtrace (struct perf_tool *tool, +static int record__process_auxtrace (const struct perf_tool *tool,struct mmap *map,union perf_event *event,void *data1,size_t len1,void *data2,size_t len2)
@@ -1417,7 +1417,7 @@ static void set_timestamp_boundary(struct record *rec, u64 sample_time) rec->evlist->last_sample_time = sample_time; } -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
@@ -3244,7 +3244,7 @@ static const char * const __record_usage[] = { };const char *const *record_usage = __record_usage; -static int build_id__process_mmap (struct perf_tool *tool,union perf_event *event, +static int build_id__process_mmap (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine) {/*
@@ -3256,7 +3256,7 @@ static int build_id__process_mmap(struct perf_tool *tool, union perf_event *evenreturn perf_event__process_mmap (tool, event, sample, machine); } -static int build_id__process_mmap2 (struct perf_tool *tool,union perf_event *event, +static int build_id__process_mmap2 (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine) {/*
@@ -3269,7 +3269,7 @@ static int build_id__process_mmap2(struct perf_tool *tool, union perf_event *evereturn perf_event__process_mmap2 (tool, event, sample, machine); } -static int process_timestamp_boundary (struct perf_tool *tool, +static int process_timestamp_boundary (const struct perf_tool *tool,union perf_event *event__maybe_unused ,struct perf_sample *sample,struct machine *machine__maybe_unused )
tools/perf/builtin-report.c +6 -6
@@ -263,7 +263,7 @@ static int process_feature_event(struct perf_session *session,return 0 ; } -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
@@ -339,7 +339,7 @@ static int process_sample_event(struct perf_tool *tool,return ret; } -static int process_read_event(struct perf_tool *tool, +static int process_read_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct evsel *evsel,
@@ -765,7 +765,7 @@ static void report__output_resort(struct report *rep)ui_progress__finish (); } -static int count_sample_event(struct perf_tool *tool __maybe_unused, +static int count_sample_event(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel,
@@ -777,7 +777,7 @@ static int count_sample_event(struct perf_tool *tool __maybe_unused,return 0 ; } -static int count_lost_samples_event (struct perf_tool *tool, +static int count_lost_samples_event (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine__maybe_unused )
@@ -793,7 +793,7 @@ static int count_lost_samples_event(struct perf_tool *tool,return 0 ; } -static int process_attr (struct perf_tool *tool__maybe_unused , +static int process_attr (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct evlist **pevlist);
@@ -1233,7 +1233,7 @@ parse_percent_limit(const struct option *opt, const char *str,return 0 ; } -static int process_attr (struct perf_tool *tool__maybe_unused , +static int process_attr (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct evlist **pevlist) {
tools/perf/builtin-sched.c +17 -17
@@ -1489,7 +1489,7 @@ static void perf_sched__sort_lat(struct perf_sched *sched) } } -static int process_sched_wakeup_event (struct perf_tool *tool, +static int process_sched_wakeup_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1502,7 +1502,7 @@ static int process_sched_wakeup_event(struct perf_tool *tool,return 0 ; } -static int process_sched_wakeup_ignore (struct perf_tool *tool__maybe_unused , +static int process_sched_wakeup_ignore (const struct perf_tool *tool__maybe_unused ,struct evsel *evsel__maybe_unused ,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -1770,7 +1770,7 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,return 0 ; } -static int process_sched_switch_event (struct perf_tool *tool, +static int process_sched_switch_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1796,7 +1796,7 @@ static int process_sched_switch_event(struct perf_tool *tool,return err; } -static int process_sched_runtime_event (struct perf_tool *tool, +static int process_sched_runtime_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1809,7 +1809,7 @@ static int process_sched_runtime_event(struct perf_tool *tool,return 0 ; } -static int perf_sched__process_fork_event (struct perf_tool *tool, +static int perf_sched__process_fork_event (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -1826,7 +1826,7 @@ static int perf_sched__process_fork_event(struct perf_tool *tool,return 0 ; } -static int process_sched_migrate_task_event (struct perf_tool *tool, +static int process_sched_migrate_task_event (const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine)
@@ -1839,12 +1839,12 @@ static int process_sched_migrate_task_event(struct perf_tool *tool,return 0 ; } -typedef int (*tracepoint_handler )(struct perf_tool *tool, +typedef int (*tracepoint_handler )(const struct perf_tool *tool,struct evsel *evsel,struct perf_sample *sample,struct machine *machine); -static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_unused, +static int perf_sched__process_tracepoint_sample(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel,
@@ -1860,7 +1860,7 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_return err; } -static int perf_sched__process_comm (struct perf_tool *tool__maybe_unused , +static int perf_sched__process_comm (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -2506,7 +2506,7 @@ static void timehist_print_wakeup_event(struct perf_sched *sched,printf ("\n" ); } -static int timehist_sched_wakeup_ignore(struct perf_tool *tool __maybe_unused, +static int timehist_sched_wakeup_ignore(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct evsel *evsel __maybe_unused, struct perf_sample *sample __maybe_unused,
@@ -2515,7 +2515,7 @@ static int timehist_sched_wakeup_ignore(struct perf_tool *tool __maybe_unused,return 0 ; } -static int timehist_sched_wakeup_event(struct perf_tool *tool, +static int timehist_sched_wakeup_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct evsel *evsel, struct perf_sample *sample,
@@ -2599,7 +2599,7 @@ static void timehist_print_migration_event(struct perf_sched *sched,printf ("\n" ); } -static int timehist_migrate_task_event(struct perf_tool *tool, +static int timehist_migrate_task_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct evsel *evsel, struct perf_sample *sample,
@@ -2627,7 +2627,7 @@ static int timehist_migrate_task_event(struct perf_tool *tool,return 0 ; } -static int timehist_sched_change_event(struct perf_tool *tool, +static int timehist_sched_change_event(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample,
@@ -2758,7 +2758,7 @@ static int timehist_sched_change_event(struct perf_tool *tool,return rc; } -static int timehist_sched_switch_event(struct perf_tool *tool, +static int timehist_sched_switch_event(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample,
@@ -2767,7 +2767,7 @@ static int timehist_sched_switch_event(struct perf_tool *tool,return timehist_sched_change_event (tool, event, evsel, sample, machine); } -static int process_lost (struct perf_tool *tool__maybe_unused , +static int process_lost (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine__maybe_unused )
@@ -3010,13 +3010,13 @@ static void timehist_print_summary(struct perf_sched *sched,printf (" (x %d)\n" , sched->max_cpu.cpu); } -typedef int (*sched_handler )(struct perf_tool *tool, +typedef int (*sched_handler )(const struct perf_tool *tool,union perf_event *event,struct evsel *evsel,struct perf_sample *sample,struct machine *machine); -static int perf_timehist__process_sample(struct perf_tool *tool, +static int perf_timehist__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
tools/perf/builtin-script.c +20 -21
164 lines not on this page · raw message
tools/perf/builtin-stat.c +4 -4
@@ -248,7 +248,7 @@ static void perf_stat__reset_stats(void)perf_stat__reset_shadow_stats (); } -static int process_synthesized_event (struct perf_tool *tool__maybe_unused , +static int process_synthesized_event (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -2180,7 +2180,7 @@ staticint process_stat_config_event (struct perf_session *session,union perf_event *event) { -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool; struct perf_stat *st = container_of(tool, struct perf_stat, tool);perf_event__read_stat_config (&stat_config, &event->stat_config);
@@ -2229,7 +2229,7 @@ staticint process_thread_map_event (struct perf_session *session,union perf_event *event) { -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool; struct perf_stat *st = container_of(tool, struct perf_stat, tool);if (st->threads) {
@@ -2248,7 +2248,7 @@ staticint process_cpu_map_event (struct perf_session *session,union perf_event *event) { -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool; struct perf_stat *st = container_of(tool, struct perf_stat, tool);struct perf_cpu_map *cpus;
tools/perf/builtin-timechart.c +4 -4
@@ -320,7 +320,7 @@ static int *cpus_cstate_state;static u64 *cpus_pstate_start_times;static u64 *cpus_pstate_state; -static int process_comm_event (struct perf_tool *tool, +static int process_comm_event (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -330,7 +330,7 @@ static int process_comm_event(struct perf_tool *tool,return 0 ; } -static int process_fork_event (struct perf_tool *tool, +static int process_fork_event (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -340,7 +340,7 @@ static int process_fork_event(struct perf_tool *tool,return 0 ; } -static int process_exit_event (struct perf_tool *tool, +static int process_exit_event (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -571,7 +571,7 @@ typedef int (*tracepoint_handler)(struct timechart *tchart,struct perf_sample *sample, const char *backtrace); -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
tools/perf/builtin-top.c +1 -1
@@ -740,7 +740,7 @@ static int hist_iter__top_callback(struct hist_entry_iter *iter,return 0 ; } -static void perf_event__process_sample(struct perf_tool *tool, +static void perf_event__process_sample(const struct perf_tool *tool, const union perf_event *event, struct evsel *evsel, struct perf_sample *sample,
tools/perf/builtin-trace.c +2 -2
@@ -1778,7 +1778,7 @@ static int trace__process_event(struct trace *trace, struct machine *machine,return ret; } -static int trace__tool_process (struct perf_tool *tool, +static int trace__tool_process (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -3179,7 +3179,7 @@ static void trace__set_base_time(struct trace *trace, trace->base_time = sample->time; } -static int trace__process_sample(struct perf_tool *tool, +static int trace__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel,
tools/perf/tests/cpumap.c +3 -3
@@ -11,7 +11,7 @@struct machine ; -static int process_event_mask (struct perf_tool *tool__maybe_unused , +static int process_event_mask (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -47,7 +47,7 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused,return 0 ; } -static int process_event_cpus (struct perf_tool *tool__maybe_unused , +static int process_event_cpus (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -73,7 +73,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,return 0 ; } -static int process_event_range_cpus (struct perf_tool *tool__maybe_unused , +static int process_event_range_cpus (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
tools/perf/tests/dlfilter-test.c +1 -1
@@ -62,7 +62,7 @@ static int test_result(const char *msg, int ret)return ret; } -static int process (struct perf_tool *tool,union perf_event *event, +static int process (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused ) {
tools/perf/tests/dwarf-unwind.c +1 -1
@@ -37,7 +37,7 @@#define NO_TAIL_CALL_BARRIER __asm__ __volatile__("" : : : "memory");#endif -static int mmap_handler (struct perf_tool *tool__maybe_unused , +static int mmap_handler (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
tools/perf/tests/event_update.c +4 -4
@@ -12,7 +12,7 @@#include "tests.h" #include "debug.h" -static int process_event_unit (struct perf_tool *tool__maybe_unused , +static int process_event_unit (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -25,7 +25,7 @@ static int process_event_unit(struct perf_tool *tool __maybe_unused,return 0 ; } -static int process_event_scale (struct perf_tool *tool__maybe_unused , +static int process_event_scale (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -43,7 +43,7 @@ struct event_name {const char *name; }; -static int process_event_name (struct perf_tool *tool, +static int process_event_name (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -57,7 +57,7 @@ static int process_event_name(struct perf_tool *tool,return 0 ; } -static int process_event_cpus (struct perf_tool *tool__maybe_unused , +static int process_event_cpus (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
tools/perf/tests/stat.c +3 -3
@@ -21,7 +21,7 @@ static bool has_term(struct perf_record_stat_config *config,return false; } -static int process_stat_config_event (struct perf_tool *tool__maybe_unused , +static int process_stat_config_event (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -62,7 +62,7 @@ static int test__synthesize_stat_config(struct test_suite *test __maybe_unused,return 0 ; } -static int process_stat_event (struct perf_tool *tool__maybe_unused , +static int process_stat_event (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -93,7 +93,7 @@ static int test__synthesize_stat(struct test_suite *test __maybe_unused, int subreturn 0 ; } -static int process_stat_round_event (struct perf_tool *tool__maybe_unused , +static int process_stat_round_event (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
tools/perf/tests/thread-map.c +1 -1
@@ -60,7 +60,7 @@ static int test__thread_map(struct test_suite *test __maybe_unused, int subtestreturn 0 ; } -static int process_event (struct perf_tool *tool__maybe_unused , +static int process_event (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
tools/perf/util/arm-spe.c +3 -3
@@ -899,7 +899,7 @@ static int arm_spe_context_switch(struct arm_spe *spe, union perf_event *event,static int arm_spe_process_event (struct perf_session *session,union perf_event *event,struct perf_sample *sample, -struct perf_tool *tool) +const struct perf_tool *tool) {int err =0 ;u64 timestamp;
@@ -947,7 +947,7 @@ static int arm_spe_process_event(struct perf_session *session,static int arm_spe_process_auxtrace_event (struct perf_session *session,union perf_event *event, -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) { struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, auxtrace);
@@ -985,7 +985,7 @@ static int arm_spe_process_auxtrace_event(struct perf_session *session, }static int arm_spe_flush (struct perf_session *session__maybe_unused , -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) { struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, auxtrace);
tools/perf/util/auxtrace.c +6 -6
@@ -1240,7 +1240,7 @@ void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int }int perf_event__synthesize_auxtrace_info (struct auxtrace_record *itr, -struct perf_tool *tool, +const struct perf_tool *tool,struct perf_session *session,perf_event__handler_t process) {
@@ -1831,7 +1831,7 @@ int __weak compat_auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail)static int __auxtrace_mmap__read (struct mmap *map,struct auxtrace_record *itr, -struct perf_tool *tool,process_auxtrace_t fn, +const struct perf_tool *tool,process_auxtrace_t fn,bool snapshot,size_t snapshot_size) {struct auxtrace_mmap *mm = &map->auxtrace_mmap;
@@ -1942,14 +1942,14 @@ static int __auxtrace_mmap__read(struct mmap *map, }int auxtrace_mmap__read (struct mmap *map,struct auxtrace_record *itr, -struct perf_tool *tool,process_auxtrace_t fn) +const struct perf_tool *tool,process_auxtrace_t fn) {return __auxtrace_mmap__read (map, itr, tool, fn, false,0 ); }int auxtrace_mmap__read_snapshot (struct mmap *map,struct auxtrace_record *itr, -struct perf_tool *tool,process_auxtrace_t fn, +const struct perf_tool *tool,process_auxtrace_t fn,size_t snapshot_size) {return __auxtrace_mmap__read (map, itr, tool, fn, true, snapshot_size);
@@ -2829,7 +2829,7 @@ int auxtrace_parse_filters(struct evlist *evlist) }int auxtrace__process_event (struct perf_session *session,union perf_event *event, -struct perf_sample *sample,struct perf_tool *tool) +struct perf_sample *sample,const struct perf_tool *tool) {if (!session->auxtrace)return 0 ;
@@ -2847,7 +2847,7 @@ void auxtrace__dump_auxtrace_sample(struct perf_session *session, session->auxtrace->dump_auxtrace_sample (session, sample); } -int auxtrace__flush_events (struct perf_session *session,struct perf_tool *tool) +int auxtrace__flush_events (struct perf_session *session,const struct perf_tool *tool) {if (!session->auxtrace)return 0 ;
tools/perf/util/auxtrace.h +10 -10
@@ -208,17 +208,17 @@ struct auxtrace {int (*process_event)(struct perf_session *session,union perf_event *event,struct perf_sample *sample, -struct perf_tool *tool); +const struct perf_tool *tool);int (*process_auxtrace_event)(struct perf_session *session,union perf_event *event, -struct perf_tool *tool); +const struct perf_tool *tool);int (*queue_data)(struct perf_session *session,struct perf_sample *sample,union perf_event *event,u64 data_offset);void (*dump_auxtrace_sample)(struct perf_session *session,struct perf_sample *sample);int (*flush_events)(struct perf_session *session, -struct perf_tool *tool); +const struct perf_tool *tool);void (*free_events)(struct perf_session *session);void (*free)(struct perf_session *session); bool (*evsel_is_auxtrace)(struct perf_session *session,
@@ -508,17 +508,17 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,struct evlist *evlist, struct evsel *evsel, int idx); -typedef int (*process_auxtrace_t )(struct perf_tool *tool, +typedef int (*process_auxtrace_t )(const struct perf_tool *tool,struct mmap *map,union perf_event *event,void *data1,size_t len1,void *data2,size_t len2);int auxtrace_mmap__read (struct mmap *map,struct auxtrace_record *itr, -struct perf_tool *tool,process_auxtrace_t fn); +const struct perf_tool *tool,process_auxtrace_t fn);int auxtrace_mmap__read_snapshot (struct mmap *map,struct auxtrace_record *itr, -struct perf_tool *tool,process_auxtrace_t fn, +const struct perf_tool *tool,process_auxtrace_t fn,size_t snapshot_size);int auxtrace_queues__init_nr (struct auxtrace_queues *queues,int nr_queues);
@@ -639,10 +639,10 @@ int addr_filters__parse_bare_filter(struct addr_filters *filts,int auxtrace_parse_filters (struct evlist *evlist);int auxtrace__process_event (struct perf_session *session,union perf_event *event, -struct perf_sample *sample,struct perf_tool *tool); +struct perf_sample *sample,const struct perf_tool *tool);void auxtrace__dump_auxtrace_sample (struct perf_session *session,struct perf_sample *sample); -int auxtrace__flush_events (struct perf_session *session,struct perf_tool *tool); +int auxtrace__flush_events (struct perf_session *session,const struct perf_tool *tool);void auxtrace__free_events (struct perf_session *session);void auxtrace__free (struct perf_session *session); bool auxtrace__evsel_is_auxtrace(struct perf_session *session,
@@ -809,7 +809,7 @@ static inlineint auxtrace__process_event (struct perf_session *session__maybe_unused ,union perf_event *event__maybe_unused ,struct perf_sample *sample__maybe_unused , -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) {return 0 ; }
@@ -822,7 +822,7 @@ void auxtrace__dump_auxtrace_sample(struct perf_session *session __maybe_unused,static inline int auxtrace__flush_events (struct perf_session *session__maybe_unused , -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) {return 0 ; }
tools/perf/util/bpf-event.c +2 -2
@@ -170,7 +170,7 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session, {struct perf_record_ksymbol *ksymbol_event = &event->ksymbol;struct perf_record_bpf_event *bpf_event = &event->bpf; -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool;struct bpf_prog_info_node *info_node;struct perf_bpil *info_linear;struct bpf_prog_info *info;
@@ -310,7 +310,7 @@ struct kallsyms_parse {union perf_event *event;perf_event__handler_t process;struct machine *machine; -struct perf_tool *tool; +const struct perf_tool *tool; }; static int
tools/perf/util/build-id.c +2 -2
@@ -42,7 +42,7 @@static bool no_buildid_cache; -int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused, +int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused,
@@ -67,7 +67,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,return 0 ; } -static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unused, +static int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused,
tools/perf/util/build-id.h +2 -2
@@ -35,11 +35,11 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size,char *__dso__build_id_filename (const struct dso *dso,char *bf,size_t size,bool is_debug,bool is_kallsyms); -int build_id__mark_dso_hit (struct perf_tool *tool,union perf_event *event, +int build_id__mark_dso_hit (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct evsel *evsel,struct machine *machine); -int perf_event__inject_buildid (struct perf_tool *tool,union perf_event *event, +int perf_event__inject_buildid (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct evsel *evsel,struct machine *machine);
tools/perf/util/cs-etm.c +3 -3
@@ -788,7 +788,7 @@ static void cs_etm__dump_event(struct cs_etm_queue *etmq, }static int cs_etm__flush_events (struct perf_session *session, -struct perf_tool *tool) +const struct perf_tool *tool) { struct cs_etm_auxtrace *etm = container_of(session->auxtrace, struct cs_etm_auxtrace,
@@ -2715,7 +2715,7 @@ static int cs_etm__process_switch_cpu_wide(struct cs_etm_auxtrace *etm,static int cs_etm__process_event (struct perf_session *session,union perf_event *event,struct perf_sample *sample, -struct perf_tool *tool) +const struct perf_tool *tool) { struct cs_etm_auxtrace *etm = container_of(session->auxtrace, struct cs_etm_auxtrace,
@@ -2785,7 +2785,7 @@ static void dump_queued_data(struct cs_etm_auxtrace *etm,static int cs_etm__process_auxtrace_event (struct perf_session *session,union perf_event *event, -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) { struct cs_etm_auxtrace *etm = container_of(session->auxtrace, struct cs_etm_auxtrace,
tools/perf/util/data-convert-bt.c +2 -2
@@ -792,7 +792,7 @@ static bool is_flush_needed(struct ctf_stream *cs)return cs->count >=STREAM_FLUSH_COUNT ; } -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *_event, struct perf_sample *sample, struct evsel *evsel,
@@ -871,7 +871,7 @@ do { \ } while(0)#define __FUNC_PROCESS_NON_SAMPLE (_name, body) \ -static int process_##_name##_event(struct perf_tool *tool, \ +static int process_##_name##_event(const struct perf_tool *tool, \ union perf_event *_event, \ struct perf_sample *sample, \ struct machine *machine) \
tools/perf/util/data-convert-json.c +2 -2
@@ -118,7 +118,7 @@ static void output_json_key_format(FILE *out, bool comma, int depth,va_end (args); } -static void output_sample_callchain_entry (struct perf_tool *tool, +static void output_sample_callchain_entry (const struct perf_tool *tool,u64 ip,struct addr_location *al) { struct convert_json *c = container_of(tool, struct convert_json, tool);
@@ -146,7 +146,7 @@ static void output_sample_callchain_entry(struct perf_tool *tool,output_json_format (out, false,4 ,"}" ); } -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel __maybe_unused,
tools/perf/util/event.c +17 -17
@@ -216,7 +216,7 @@ size_t perf_event__fprintf_cgroup(union perf_event *event, FILE *fp) event->cgroup.id, event->cgroup.path); } -int perf_event__process_comm (struct perf_tool *tool__maybe_unused , +int perf_event__process_comm (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -224,7 +224,7 @@ int perf_event__process_comm(struct perf_tool *tool __maybe_unused,return machine__process_comm_event (machine, event, sample); } -int perf_event__process_namespaces (struct perf_tool *tool__maybe_unused , +int perf_event__process_namespaces (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -232,7 +232,7 @@ int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused,return machine__process_namespaces_event (machine, event, sample); } -int perf_event__process_cgroup (struct perf_tool *tool__maybe_unused , +int perf_event__process_cgroup (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -240,7 +240,7 @@ int perf_event__process_cgroup(struct perf_tool *tool __maybe_unused,return machine__process_cgroup_event (machine, event, sample); } -int perf_event__process_lost (struct perf_tool *tool__maybe_unused , +int perf_event__process_lost (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -248,7 +248,7 @@ int perf_event__process_lost(struct perf_tool *tool __maybe_unused,return machine__process_lost_event (machine, event, sample); } -int perf_event__process_aux (struct perf_tool *tool__maybe_unused , +int perf_event__process_aux (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine)
@@ -256,7 +256,7 @@ int perf_event__process_aux(struct perf_tool *tool __maybe_unused,return machine__process_aux_event (machine, event); } -int perf_event__process_itrace_start (struct perf_tool *tool__maybe_unused , +int perf_event__process_itrace_start (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine)
@@ -264,7 +264,7 @@ int perf_event__process_itrace_start(struct perf_tool *tool __maybe_unused,return machine__process_itrace_start_event (machine, event); } -int perf_event__process_aux_output_hw_id (struct perf_tool *tool__maybe_unused , +int perf_event__process_aux_output_hw_id (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine)
@@ -272,7 +272,7 @@ int perf_event__process_aux_output_hw_id(struct perf_tool *tool __maybe_unused,return machine__process_aux_output_hw_id_event (machine, event); } -int perf_event__process_lost_samples (struct perf_tool *tool__maybe_unused , +int perf_event__process_lost_samples (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -280,7 +280,7 @@ int perf_event__process_lost_samples(struct perf_tool *tool __maybe_unused,return machine__process_lost_samples_event (machine, event, sample); } -int perf_event__process_switch (struct perf_tool *tool__maybe_unused , +int perf_event__process_switch (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine)
@@ -288,7 +288,7 @@ int perf_event__process_switch(struct perf_tool *tool __maybe_unused,return machine__process_switch_event (machine, event); } -int perf_event__process_ksymbol (struct perf_tool *tool__maybe_unused , +int perf_event__process_ksymbol (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample__maybe_unused ,struct machine *machine)
@@ -296,7 +296,7 @@ int perf_event__process_ksymbol(struct perf_tool *tool __maybe_unused,return machine__process_ksymbol (machine, event, sample); } -int perf_event__process_bpf (struct perf_tool *tool__maybe_unused , +int perf_event__process_bpf (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -304,7 +304,7 @@ int perf_event__process_bpf(struct perf_tool *tool __maybe_unused,return machine__process_bpf (machine, event, sample); } -int perf_event__process_text_poke (struct perf_tool *tool__maybe_unused , +int perf_event__process_text_poke (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -387,7 +387,7 @@ size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp)return ret; } -int perf_event__process_mmap (struct perf_tool *tool__maybe_unused , +int perf_event__process_mmap (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -395,7 +395,7 @@ int perf_event__process_mmap(struct perf_tool *tool __maybe_unused,return machine__process_mmap_event (machine, event, sample); } -int perf_event__process_mmap2 (struct perf_tool *tool__maybe_unused , +int perf_event__process_mmap2 (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -410,7 +410,7 @@ size_t perf_event__fprintf_task(union perf_event *event, FILE *fp) event->fork.ppid, event->fork.ptid); } -int perf_event__process_fork (struct perf_tool *tool__maybe_unused , +int perf_event__process_fork (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -418,7 +418,7 @@ int perf_event__process_fork(struct perf_tool *tool __maybe_unused,return machine__process_fork_event (machine, event, sample); } -int perf_event__process_exit (struct perf_tool *tool__maybe_unused , +int perf_event__process_exit (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
@@ -587,7 +587,7 @@ size_t perf_event__fprintf(union perf_event *event, struct machine *machine, FILreturn ret; } -int perf_event__process (struct perf_tool *tool__maybe_unused , +int perf_event__process (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct perf_sample *sample,struct machine *machine)
tools/perf/util/event.h +17 -17
@@ -267,71 +267,71 @@ struct perf_tool;void perf_event__read_stat_config (struct perf_stat_config *config,struct perf_record_stat_config *event); -int perf_event__process_comm (struct perf_tool *tool, +int perf_event__process_comm (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_lost (struct perf_tool *tool, +int perf_event__process_lost (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_lost_samples (struct perf_tool *tool, +int perf_event__process_lost_samples (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_aux (struct perf_tool *tool, +int perf_event__process_aux (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_itrace_start (struct perf_tool *tool, +int perf_event__process_itrace_start (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_aux_output_hw_id (struct perf_tool *tool, +int perf_event__process_aux_output_hw_id (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_switch (struct perf_tool *tool, +int perf_event__process_switch (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_namespaces (struct perf_tool *tool, +int perf_event__process_namespaces (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_cgroup (struct perf_tool *tool, +int perf_event__process_cgroup (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_mmap (struct perf_tool *tool, +int perf_event__process_mmap (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_mmap2 (struct perf_tool *tool, +int perf_event__process_mmap2 (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_fork (struct perf_tool *tool, +int perf_event__process_fork (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_exit (struct perf_tool *tool, +int perf_event__process_exit (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_ksymbol (struct perf_tool *tool, +int perf_event__process_ksymbol (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_bpf (struct perf_tool *tool, +int perf_event__process_bpf (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process_text_poke (struct perf_tool *tool, +int perf_event__process_text_poke (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -int perf_event__process (struct perf_tool *tool, +int perf_event__process (const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine);
tools/perf/util/header.c +3 -3
@@ -4326,7 +4326,7 @@ int perf_session__read_header(struct perf_session *session, int repipe_fd)int perf_event__process_feature (struct perf_session *session,union perf_event *event) { -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool;struct feat_fd ff = { .fd =0 };struct perf_record_header_feature *fe = (struct perf_record_header_feature *)event;int type = fe->header.type;
@@ -4405,7 +4405,7 @@ size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp)return ret; } -int perf_event__process_attr (struct perf_tool *tool__maybe_unused , +int perf_event__process_attr (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct evlist **pevlist) {
@@ -4444,7 +4444,7 @@ int perf_event__process_attr(struct perf_tool *tool __maybe_unused,return 0 ; } -int perf_event__process_event_update (struct perf_tool *tool__maybe_unused , +int perf_event__process_event_update (const struct perf_tool *tool__maybe_unused ,union perf_event *event,struct evlist **pevlist) {
tools/perf/util/header.h +2 -2
@@ -156,9 +156,9 @@ int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full);int perf_event__process_feature (struct perf_session *session,union perf_event *event); -int perf_event__process_attr (struct perf_tool *tool,union perf_event *event, +int perf_event__process_attr (const struct perf_tool *tool,union perf_event *event,struct evlist **pevlist); -int perf_event__process_event_update (struct perf_tool *tool, +int perf_event__process_event_update (const struct perf_tool *tool,union perf_event *event,struct evlist **pevlist);size_t perf_event__fprintf_event_update (union perf_event *event,FILE *fp);
tools/perf/util/hisi-ptt.c +3 -3
@@ -79,14 +79,14 @@ static void hisi_ptt_dump_event(struct hisi_ptt *ptt, unsigned char *buf,static int hisi_ptt_process_event (struct perf_session *session__maybe_unused ,union perf_event *event__maybe_unused ,struct perf_sample *sample__maybe_unused , -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) {return 0 ; }static int hisi_ptt_process_auxtrace_event (struct perf_session *session,union perf_event *event, -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) { struct hisi_ptt *ptt = container_of(session->auxtrace, struct hisi_ptt, auxtrace);
@@ -123,7 +123,7 @@ static int hisi_ptt_process_auxtrace_event(struct perf_session *session, }static int hisi_ptt_flush (struct perf_session *session__maybe_unused , -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) {return 0 ; }
tools/perf/util/intel-bts.c +3 -3
@@ -591,7 +591,7 @@ static int intel_bts_process_queues(struct intel_bts *bts, u64 timestamp)static int intel_bts_process_event (struct perf_session *session,union perf_event *event,struct perf_sample *sample, -struct perf_tool *tool) +const struct perf_tool *tool) { struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, auxtrace);
@@ -634,7 +634,7 @@ static int intel_bts_process_event(struct perf_session *session,static int intel_bts_process_auxtrace_event (struct perf_session *session,union perf_event *event, -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) { struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, auxtrace);
@@ -675,7 +675,7 @@ static int intel_bts_process_auxtrace_event(struct perf_session *session, }static int intel_bts_flush (struct perf_session *session, -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) { struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, auxtrace);
tools/perf/util/intel-pt.c +3 -3
@@ -3449,7 +3449,7 @@ static int intel_pt_text_poke(struct intel_pt *pt, union perf_event *event)static int intel_pt_process_event (struct perf_session *session,union perf_event *event,struct perf_sample *sample, -struct perf_tool *tool) +const struct perf_tool *tool) { struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, auxtrace);
@@ -3533,7 +3533,7 @@ static int intel_pt_process_event(struct perf_session *session,return err; } -static int intel_pt_flush (struct perf_session *session,struct perf_tool *tool) +static int intel_pt_flush (struct perf_session *session,const struct perf_tool *tool) { struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, auxtrace);
@@ -3600,7 +3600,7 @@ static bool intel_pt_evsel_is_auxtrace(struct perf_session *session,static int intel_pt_process_auxtrace_event (struct perf_session *session,union perf_event *event, -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) { struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, auxtrace);
tools/perf/util/jitdump.c +2 -2
@@ -424,7 +424,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) {struct perf_sample sample;union perf_event *event; -struct perf_tool *tool = jd->session->tool; +const struct perf_tool *tool = jd->session->tool;uint64_t code, addr;uintptr_t uaddr;char *filename;
@@ -543,7 +543,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr) {struct perf_sample sample;union perf_event *event; -struct perf_tool *tool = jd->session->tool; +const struct perf_tool *tool = jd->session->tool;char *filename;size_t size;struct stat st;
tools/perf/util/s390-cpumsf.c +3 -3
@@ -912,7 +912,7 @@ static int s390_cpumsf_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct s390_cpumsf *sf = container_of(session->auxtrace, struct s390_cpumsf,
@@ -955,7 +955,7 @@ s390_cpumsf_process_event(struct perf_session *session,static int s390_cpumsf_process_auxtrace_event (struct perf_session *session,union perf_event *event__maybe_unused , -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) { struct s390_cpumsf *sf = container_of(session->auxtrace, struct s390_cpumsf,
@@ -998,7 +998,7 @@ static void s390_cpumsf_free_events(struct perf_session *session __maybe_unused) }static int s390_cpumsf_flush (struct perf_session *session__maybe_unused , -struct perf_tool *tool__maybe_unused ) +const struct perf_tool *tool__maybe_unused ) {return 0 ; }
tools/perf/util/session.c +15 -15
@@ -103,7 +103,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,static int perf_session__deliver_event (struct perf_session *session,union perf_event *event, -struct perf_tool *tool, +const struct perf_tool *tool,u64 file_offset,const char *file_path);
@@ -330,7 +330,7 @@ static int process_event_synth_tracing_data_stub(struct perf_session *sessionreturn 0 ; } -static int process_event_synth_attr_stub (struct perf_tool *tool__maybe_unused , +static int process_event_synth_attr_stub (const struct perf_tool *tool__maybe_unused ,union perf_event *event__maybe_unused ,struct evlist **pevlist__maybe_unused )
@@ -339,7 +339,7 @@ static int process_event_synth_attr_stub(struct perf_tool *tool __maybe_unused,return 0 ; } -static int process_event_synth_event_update_stub (struct perf_tool *tool__maybe_unused , +static int process_event_synth_event_update_stub (const struct perf_tool *tool__maybe_unused ,union perf_event *event__maybe_unused ,struct evlist **pevlist__maybe_unused )
@@ -351,7 +351,7 @@ static int process_event_synth_event_update_stub(struct perf_tool *tool __maybe_return 0 ; } -static int process_event_sample_stub(struct perf_tool *tool __maybe_unused, +static int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel __maybe_unused,
@@ -361,7 +361,7 @@ static int process_event_sample_stub(struct perf_tool *tool __maybe_unused,return 0 ; } -static int process_event_stub (struct perf_tool *tool__maybe_unused , +static int process_event_stub (const struct perf_tool *tool__maybe_unused ,union perf_event *event__maybe_unused ,struct perf_sample *sample__maybe_unused ,struct machine *machine__maybe_unused )
@@ -370,7 +370,7 @@ static int process_event_stub(struct perf_tool *tool __maybe_unused,return 0 ; } -static int process_finished_round_stub (struct perf_tool *tool__maybe_unused , +static int process_finished_round_stub (const struct perf_tool *tool__maybe_unused ,union perf_event *event__maybe_unused ,struct ordered_events *oe__maybe_unused ) {
@@ -1078,7 +1078,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {* Flush every events below timestamp 7 * etc... */ -int perf_event__process_finished_round (struct perf_tool *tool__maybe_unused , +int perf_event__process_finished_round (const struct perf_tool *tool__maybe_unused ,union perf_event *event__maybe_unused ,struct ordered_events *oe) {
@@ -1472,7 +1472,7 @@ static struct machine *machines__find_for_cpumode(struct machines *machines, } static int deliver_sample_value(struct evlist *evlist, - struct perf_tool *tool, + const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct sample_read_value *v,
@@ -1504,7 +1504,7 @@ static int deliver_sample_value(struct evlist *evlist, } static int deliver_sample_group(struct evlist *evlist, - struct perf_tool *tool, + const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine,
@@ -1526,7 +1526,7 @@ static int deliver_sample_group(struct evlist *evlist,return ret; } -static int evlist__deliver_sample (struct evlist *evlist,struct perf_tool *tool, +static int evlist__deliver_sample (struct evlist *evlist,const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct evsel *evsel,struct machine *machine) {
@@ -1551,7 +1551,7 @@ static int machines__deliver_event(struct machines *machines,struct evlist *evlist, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool, u64 file_offset, + const struct perf_tool *tool, u64 file_offset, const char *file_path) { struct evsel *evsel;
@@ -1639,7 +1639,7 @@ static int machines__deliver_event(struct machines *machines,static int perf_session__deliver_event (struct perf_session *session,union perf_event *event, -struct perf_tool *tool, +const struct perf_tool *tool,u64 file_offset,const char *file_path) {
@@ -1672,7 +1672,7 @@ static s64 perf_session__process_user_event(struct perf_session *session, const char *file_path) {struct ordered_events *oe = &session->ordered_events; -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool;struct perf_sample sample = { .time =0 , };int fd =perf_data__fd (session->data);int err;
@@ -1759,7 +1759,7 @@ int perf_session__deliver_synth_event(struct perf_session *session, struct perf_sample *sample) {struct evlist *evlist = session->evlist; -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool;events_stats__inc (&evlist->stats, event->header.type);
@@ -1891,7 +1891,7 @@ static s64 perf_session__process_event(struct perf_session *session, const char *file_path) {struct evlist *evlist = session->evlist; -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool;int ret;if (session->header.needs_swap)
tools/perf/util/session.h +1 -1
@@ -163,7 +163,7 @@ int perf_session__dsos_hit_all(struct perf_session *session);int perf_event__process_id_index (struct perf_session *session,union perf_event *event); -int perf_event__process_finished_round (struct perf_tool *tool, +int perf_event__process_finished_round (const struct perf_tool *tool,union perf_event *event,struct ordered_events *oe);
tools/perf/util/synthetic-events.c +40 -40
316 lines not on this page · raw message
tools/perf/util/synthetic-events.h +35 -35
101 lines not on this page · raw message
tools/perf/util/tool.h +4 -4
@@ -15,14 +15,14 @@ struct perf_tool;struct machine ;struct ordered_events ; -typedef int (*event_sample )(struct perf_tool *tool,union perf_event *event, +typedef int (*event_sample )(const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct evsel *evsel,struct machine *machine); -typedef int (*event_op )(struct perf_tool *tool,union perf_event *event, +typedef int (*event_op )(const struct perf_tool *tool,union perf_event *event,struct perf_sample *sample,struct machine *machine); -typedef int (*event_attr_op )(struct perf_tool *tool, +typedef int (*event_attr_op )(const struct perf_tool *tool,union perf_event *event,struct evlist **pevlist);
@@ -31,7 +31,7 @@ typedef s64 (*event_op3)(struct perf_session *session, union perf_event *event);typedef int (*event_op4 )(struct perf_session *session,union perf_event *event,u64 data,const char *str); -typedef int (*event_oe )(struct perf_tool *tool,union perf_event *event, +typedef int (*event_oe )(const struct perf_tool *tool,union perf_event *event,struct ordered_events *oe);enum show_feature_header {
tools/perf/util/tsc.c +1 -1
@@ -72,7 +72,7 @@ int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, }int perf_event__synth_time_conv (const struct perf_event_mmap_page *pc, -struct perf_tool *tool, +const struct perf_tool *tool,perf_event__handler_t process,struct machine *machine) {
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 4/27 perf tool: Move fill defaults into tool.c
In reply to Ian RogersThe aim here is to eventually make perf_tool__fill_defaults an init function so that the tools struct is more const.
Create a tool.c to go along with tool.h. Move perf_tool__fill_defaults out of session.c into tool.c along with the default stub values. Add perf_tool__compressed_is_stub for a test in perf_session__process_user_event.
perf_session__process_compressed_event is only used from being default initialized so migrate into tool.c.
--- tools/perf/util/Build | 1 + tools/perf/util/session.c | 310 +----------------------------------- tools/perf/util/session.h | 2 - tools/perf/util/tool.c | 325 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 4 + 5 files changed, 331 insertions(+), 311 deletions(-) create mode 100644 tools/perf/util/tool.c
tools/perf/util/Build +1 -0
@@ -66,6 +66,7 @@ perf-util-y += map.o perf-util-y += maps.o perf-util-y += pstack.o perf-util-y += session.o +perf-util-y += tool.o perf-util-y += sample-raw.o perf-util-y += s390-sample-raw.o perf-util-y += amd-sample-raw.o
tools/perf/util/session.c +1 -309
328 lines not on this page · raw message
tools/perf/util/session.h +0 -2
@@ -92,8 +92,6 @@ int perf_session__process_events(struct perf_session *session);int perf_session__queue_event (struct perf_session *s,union perf_event *event,u64 timestamp,u64 file_offset,const char *file_path); -void perf_tool__fill_defaults (struct perf_tool *tool); - int perf_session__resolve_callchain(struct perf_session *session, struct evsel *evsel, struct thread *thread,
tools/perf/util/tool.c new file +325 -0
325 lines not on this page · raw message
tools/perf/util/tool.h +4 -0
@@ -89,4 +89,8 @@ struct perf_tool { enum show_feature_header show_feat_hdr; }; +void perf_tool__fill_defaults (struct perf_tool *tool); + +bool perf_tool__compressed_is_stub (const struct perf_tool *tool); +#endif /* __PERF_TOOL_H */
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 5/27 perf tool: Add perf_tool__init
In reply to Ian RogersAdd init function that behaves like perf_tool__fill_defaults but assumes all values haven't been initialized.
--- tools/perf/util/tool.c | 58 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 1 + 2 files changed, 59 insertions(+)
tools/perf/util/tool.c +58 -0
@@ -230,6 +230,64 @@ static int perf_session__process_compressed_event_stub(struct perf_session *sessreturn 0 ; } +void perf_tool__init (struct perf_tool *tool,bool ordered_events) +{ + tool->ordered_events = ordered_events; + tool->ordering_requires_timestamps = false; + tool->namespace_events = false; + tool->cgroup_events = false; + tool->no_warn = false; + tool->show_feat_hdr =SHOW_FEAT_NO_HEADER ; + + tool->sample = process_event_sample_stub; + tool->mmap = process_event_stub; + tool->mmap2 = process_event_stub; + tool->comm = process_event_stub; + tool->namespaces = process_event_stub; + tool->cgroup = process_event_stub; + tool->fork = process_event_stub; + tool->exit = process_event_stub; + tool->lost = perf_event__process_lost; + tool->lost_samples = perf_event__process_lost_samples; + tool->aux = perf_event__process_aux; + tool->itrace_start = perf_event__process_itrace_start; + tool->context_switch = perf_event__process_switch; + tool->ksymbol = perf_event__process_ksymbol; + tool->bpf = perf_event__process_bpf; + tool->text_poke = perf_event__process_text_poke; + tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; + tool->read = process_event_sample_stub; + tool->throttle = process_event_stub; + tool->unthrottle = process_event_stub; + tool->attr = process_event_synth_attr_stub; + tool->event_update = process_event_synth_event_update_stub; + tool->tracing_data = process_event_synth_tracing_data_stub; + tool->build_id = process_event_op2_stub; + +if (ordered_events) + tool->finished_round = perf_event__process_finished_round; +else + tool->finished_round = process_finished_round_stub; + + tool->id_index = process_event_op2_stub; + tool->auxtrace_info = process_event_op2_stub; + tool->auxtrace = process_event_auxtrace_stub; + tool->auxtrace_error = process_event_op2_stub; + tool->thread_map = process_event_thread_map_stub; + tool->cpu_map = process_event_cpu_map_stub; + tool->stat_config = process_event_stat_config_stub; + tool->stat = process_stat_stub; + tool->stat_round = process_stat_round_stub; + tool->time_conv = process_event_time_conv_stub; + tool->feature = process_event_op2_stub; +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed = perf_session__process_compressed_event; +#else + tool->compressed = perf_session__process_compressed_event_stub; +#endif + tool->finished_init = process_event_op2_stub; +} +void perf_tool__fill_defaults (struct perf_tool *tool) {if (tool->sample ==NULL )
tools/perf/util/tool.h +1 -0
@@ -89,6 +89,7 @@ struct perf_tool {enum show_feature_header show_feat_hdr; }; +void perf_tool__init (struct perf_tool *tool,bool ordered_events);void perf_tool__fill_defaults (struct perf_tool *tool);bool perf_tool__compressed_is_stub (const struct perf_tool *tool);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 6/27 perf kmem: Use perf_tool__init
In reply to Ian RogersReduce the scope of the tool from global/static to just that of the cmd_kmem function where the session is scoped. Use the perf_tool__init to initialize default values.
--- tools/perf/builtin-kmem.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
tools/perf/builtin-kmem.c +8 -9
@@ -986,15 +986,6 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,return err; } -static struct perf_tool perf_kmem = { - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, -}; -static double fragmentation (unsigned long n_req,unsigned long n_alloc) {if (n_alloc ==0 )
@@ -1971,6 +1962,7 @@ int cmd_kmem(int argc, const char **argv) NULL };struct perf_session *session; +struct perf_tool perf_kmem;static const char errmsg[] ="No %s allocation events found. Have you run 'perf kmem record --%s'?\n" ;int ret =perf_config (kmem_config,NULL );
@@ -1998,6 +1990,13 @@ int cmd_kmem(int argc, const char **argv) data.path = input_name; +perf_tool__init (&perf_kmem,/*ordered_events=*/ true); + perf_kmem.sample = process_sample_event; + perf_kmem.comm = perf_event__process_comm; + perf_kmem.mmap = perf_event__process_mmap; + perf_kmem.mmap2 = perf_event__process_mmap2; + perf_kmem.namespaces = perf_event__process_namespaces; + kmem_session = session =perf_session__new (&data, &perf_kmem);if (IS_ERR (session))return PTR_ERR (session);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 7/27 perf buildid-list: Use perf_tool__init
In reply to Ian RogersReduce scope of build_id__mark_dso_hit_ops to the scope of function perf_session__list_build_ids, its only use, and use perf_tool__init for the default values. Move perf_event__exit_del_thread to event.[ch] so it can be used in builtin-buildid-list.c.
--- tools/perf/builtin-buildid-list.c | 10 ++++++++++ tools/perf/util/build-id.c | 32 ------------------------------- tools/perf/util/build-id.h | 4 +--- tools/perf/util/event.c | 20 +++++++++++++++++++ tools/perf/util/event.h | 4 ++++ 5 files changed, 35 insertions(+), 35 deletions(-)
tools/perf/builtin-buildid-list.c +10 -0
@@ -89,6 +89,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits) .mode = PERF_DATA_MODE_READ, .force = force, }; +struct perf_tool build_id__mark_dso_hit_ops;symbol__elf_init ();/*
@@ -97,6 +98,15 @@ static int perf_session__list_build_ids(bool force, bool with_hits)if (filename__fprintf_build_id (input_name, stdout) >0 ) goto out; +perf_tool__init (&build_id__mark_dso_hit_ops,/*ordered_events=*/ true); + build_id__mark_dso_hit_ops.sample = build_id__mark_dso_hit; + build_id__mark_dso_hit_ops.mmap = perf_event__process_mmap; + build_id__mark_dso_hit_ops.mmap2 = perf_event__process_mmap2; + build_id__mark_dso_hit_ops.fork = perf_event__process_fork; + build_id__mark_dso_hit_ops.exit = perf_event__exit_del_thread; + build_id__mark_dso_hit_ops.attr = perf_event__process_attr; + build_id__mark_dso_hit_ops.build_id = perf_event__process_build_id; + session =perf_session__new (&data, &build_id__mark_dso_hit_ops);if (IS_ERR (session))return PTR_ERR (session);
tools/perf/util/build-id.c +0 -32
@@ -67,38 +67,6 @@ int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused,return 0 ; } -static int perf_event__exit_del_thread (const struct perf_tool *tool__maybe_unused , -union perf_event *event, -struct perf_sample *sample -__maybe_unused , -struct machine *machine) -{ -struct thread *thread =machine__findnew_thread (machine, - event->fork.pid, - event->fork.tid); - -dump_printf ("(%d:%d):(%d:%d)\n" , event->fork.pid, event->fork.tid, - event->fork.ppid, event->fork.ptid); - -if (thread) { -machine__remove_thread (machine, thread); -thread__put (thread); - } - -return 0 ; -} - -struct perf_tool build_id__mark_dso_hit_ops = { - .sample = build_id__mark_dso_hit, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .fork = perf_event__process_fork, - .exit = perf_event__exit_del_thread, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, - .ordered_events = true, -}; -int build_id__sprintf (const struct build_id *build_id,char *bf) {char *bid = bf;
tools/perf/util/build-id.h +1 -3
@@ -16,11 +16,9 @@ struct build_id {size_t size; }; -struct nsinfo ; - -extern struct perf_tool build_id__mark_dso_hit_ops;struct dso ;struct feat_fd ; +struct nsinfo ;void build_id__init (struct build_id *bid,const u8 *data,size_t size);int build_id__sprintf (const struct build_id *build_id,char *bf);
tools/perf/util/event.c +20 -0
@@ -426,6 +426,26 @@ int perf_event__process_exit(const struct perf_tool *tool __maybe_unused,return machine__process_exit_event (machine, event, sample); } +int perf_event__exit_del_thread (const struct perf_tool *tool__maybe_unused , +union perf_event *event, +struct perf_sample *sample__maybe_unused , +struct machine *machine) +{ +struct thread *thread =machine__findnew_thread (machine, + event->fork.pid, + event->fork.tid); + +dump_printf ("(%d:%d):(%d:%d)\n" , event->fork.pid, event->fork.tid, + event->fork.ppid, event->fork.ptid); + +if (thread) { +machine__remove_thread (machine, thread); +thread__put (thread); + } + +return 0 ; +} +size_t perf_event__fprintf_aux (union perf_event *event,FILE *fp) { return fprintf(fp, " offset: %#"PRI_lx64" size: %#"PRI_lx64" flags: %#"PRI_lx64" [%s%s%s]\n",
tools/perf/util/event.h +4 -0
@@ -319,6 +319,10 @@ int perf_event__process_exit(const struct perf_tool *tool,union perf_event *event, struct perf_sample *sample, struct machine *machine); +int perf_event__exit_del_thread (const struct perf_tool *tool, +union perf_event *event, +struct perf_sample *sample, +struct machine *machine); int perf_event__process_ksymbol(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample,
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 8/27 perf kvm: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-kvm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
tools/perf/builtin-kvm.c +6 -9
@@ -1603,19 +1603,17 @@ static int read_events(struct perf_kvm_stat *kvm) {int ret; -struct perf_tool eops = { - .sample = process_sample_event, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, - };struct perf_data file = { .path = kvm->file_name, .mode =PERF_DATA_MODE_READ , .force = kvm->force, }; - kvm->tool = eops; +perf_tool__init (&kvm->tool,/*ordered_events=*/ true); + kvm->tool.sample = process_sample_event; + kvm->tool.comm = perf_event__process_comm; + kvm->tool.namespaces = perf_event__process_namespaces; + kvm->session =perf_session__new (&file, &kvm->tool);if (IS_ERR (kvm->session)) {pr_err ("Initializing perf session failed\n" );
@@ -1919,14 +1917,13 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,/* event handling */ +perf_tool__init (&kvm->tool,/*ordered_events=*/ true); kvm->tool.sample = process_sample_event; kvm->tool.comm = perf_event__process_comm; kvm->tool.exit = perf_event__process_exit; kvm->tool.fork = perf_event__process_fork; kvm->tool.lost = process_lost_event; kvm->tool.namespaces = perf_event__process_namespaces; - kvm->tool.ordered_events = true; -perf_tool__fill_defaults (&kvm->tool);/* set defaults */ kvm->display_time =1 ;
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 9/27 perf lock: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-lock.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)
tools/perf/builtin-lock.c +18 -19
@@ -1933,22 +1933,21 @@ static bool force;static int __cmd_report (bool display_info) {int err = -EINVAL ; -struct perf_tool eops = { - .attr = perf_event__process_attr, - .event_update = process_event_update, - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .namespaces = perf_event__process_namespaces, - .tracing_data = perf_event__process_tracing_data, - .ordered_events = true, - }; +struct perf_tool eops;struct perf_data data = { .path = input_name, .mode =PERF_DATA_MODE_READ , .force = force, }; +perf_tool__init (&eops,/*ordered_events=*/ true); + eops.attr = perf_event__process_attr; + eops.event_update = process_event_update; + eops.sample = process_sample_event; + eops.comm = perf_event__process_comm; + eops.mmap = perf_event__process_mmap; + eops.namespaces = perf_event__process_namespaces; + eops.tracing_data = perf_event__process_tracing_data; session =perf_session__new (&data, &eops);if (IS_ERR (session)) {pr_err ("Initializing perf session failed\n" );
@@ -2069,15 +2068,7 @@ static int check_lock_contention_options(const struct option *options,static int __cmd_contention (int argc,const char **argv) {int err = -EINVAL ; -struct perf_tool eops = { - .attr = perf_event__process_attr, - .event_update = process_event_update, - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .tracing_data = perf_event__process_tracing_data, - .ordered_events = true, - }; +struct perf_tool eops;struct perf_data data = { .path = input_name, .mode =PERF_DATA_MODE_READ ,
@@ -2100,6 +2091,14 @@ static int __cmd_contention(int argc, const char **argv) con.result = &lockhash_table[0 ]; +perf_tool__init (&eops,/*ordered_events=*/ true); + eops.attr = perf_event__process_attr; + eops.event_update = process_event_update; + eops.sample = process_sample_event; + eops.comm = perf_event__process_comm; + eops.mmap = perf_event__process_mmap; + eops.tracing_data = perf_event__process_tracing_data; + session =perf_session__new (use_bpf ?NULL : &data, &eops);if (IS_ERR (session)) {pr_err ("Initializing perf session failed\n" );
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 10/27 perf evlist: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-evlist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/builtin-evlist.c +5 -5
@@ -35,13 +35,13 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details .mode = PERF_DATA_MODE_READ, .force = details->force, }; -struct perf_tool tool = { -/* only needed for pipe mode */ - .attr = perf_event__process_attr, - .feature = process_header_feature, - }; +struct perf_tool tool;bool has_tracepoint = false; +perf_tool__init (&tool,/*ordered_events=*/ false); +/* only needed for pipe mode */ + tool.attr = perf_event__process_attr; + tool.feature = process_header_feature; session =perf_session__new (&data, &tool);if (IS_ERR (session))return PTR_ERR (session);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 11/27 perf record: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-record.c | 33 ++++++++++++++++++++------------- tools/perf/util/tool.c | 10 +++++----- tools/perf/util/tool.h | 6 ++++++ 3 files changed, 31 insertions(+), 18 deletions(-)
tools/perf/builtin-record.c +20 -13
@@ -194,6 +194,15 @@ static const char *affinity_tags[PERF_AFFINITY_MAX] = {"SYS" ,"NODE" ,"CPU" }; +static int build_id__process_mmap (const struct perf_tool *tool,union perf_event *event, +struct perf_sample *sample,struct machine *machine); +static int build_id__process_mmap2 (const struct perf_tool *tool,union perf_event *event, +struct perf_sample *sample,struct machine *machine); +static int process_timestamp_boundary (const struct perf_tool *tool, +union perf_event *event, +struct perf_sample *sample, +struct machine *machine); +#ifndef HAVE_GETTID static inline pid_t gettid (void ) {
@@ -1459,7 +1468,7 @@ static int process_buildids(struct record *rec)* first/last samples. */ if (rec->buildid_all && !rec->timestamp_boundary) - rec->tool.sample =NULL ; + rec->tool.sample = process_event_sample_stub;return perf_session__process_events (session); }
@@ -2387,6 +2396,16 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)signal (SIGUSR2 ,SIG_IGN ); } +perf_tool__init (tool,/*ordered_events=*/ true); + tool->sample = process_sample_event; + tool->fork = perf_event__process_fork; + tool->exit = perf_event__process_exit; + tool->comm = perf_event__process_comm; + tool->namespaces = perf_event__process_namespaces; + tool->mmap = build_id__process_mmap; + tool->mmap2 = build_id__process_mmap2; + tool->itrace_start = process_timestamp_boundary; + tool->aux = process_timestamp_boundary; session =perf_session__new (data, tool);if (IS_ERR (session)) {pr_err ("Perf session creation failed.\n" );
@@ -3327,18 +3346,6 @@ static struct record record = { .ctl_fd_ack = -1, .synth = PERF_SYNTH_ALL, }, - .tool = { - .sample = process_sample_event, - .fork = perf_event__process_fork, - .exit = perf_event__process_exit, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .mmap = build_id__process_mmap, - .mmap2 = build_id__process_mmap2, - .itrace_start = process_timestamp_boundary, - .aux = process_timestamp_boundary, - .ordered_events = true, - }, };const char record_callchain_help[] =CALLCHAIN_RECORD_HELP
tools/perf/util/tool.c +5 -5
@@ -99,11 +99,11 @@ static int process_event_synth_event_update_stub(const struct perf_tool *tool __return 0 ; } -static int process_event_sample_stub (const struct perf_tool *tool__maybe_unused , -union perf_event *event__maybe_unused , -struct perf_sample *sample__maybe_unused , -struct evsel *evsel__maybe_unused , -struct machine *machine__maybe_unused ) +int process_event_sample_stub (const struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_sample *sample__maybe_unused , +struct evsel *evsel__maybe_unused , +struct machine *machine__maybe_unused ) {dump_printf (": unhandled!\n" );return 0 ;
tools/perf/util/tool.h +6 -0
@@ -94,4 +94,10 @@ void perf_tool__fill_defaults(struct perf_tool *tool);bool perf_tool__compressed_is_stub (const struct perf_tool *tool); +int process_event_sample_stub (const struct perf_tool *tool, +union perf_event *event, +struct perf_sample *sample, +struct evsel *evsel, +struct machine *machine); +#endif /* __PERF_TOOL_H */
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 12/27 perf c2c: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-c2c.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
tools/perf/builtin-c2c.c +13 -18
@@ -385,24 +385,6 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused, goto out; } -static struct perf_c2c c2c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .attr = perf_event__process_attr, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, -}; -static const char *const c2c_usage[] = {"perf c2c {record|report}" ,NULL
@@ -3070,6 +3052,19 @@ static int perf_c2c__report(int argc, const char **argv) data.path = input_name; data.force = symbol_conf.force; +perf_tool__init (&c2c.tool,/*ordered_events=*/ true); + c2c.tool.sample = process_sample_event; + c2c.tool.mmap = perf_event__process_mmap; + c2c.tool.mmap2 = perf_event__process_mmap2; + c2c.tool.comm = perf_event__process_comm; + c2c.tool.exit = perf_event__process_exit; + c2c.tool.fork = perf_event__process_fork; + c2c.tool.lost = perf_event__process_lost; + c2c.tool.attr = perf_event__process_attr; + c2c.tool.auxtrace_info = perf_event__process_auxtrace_info; + c2c.tool.auxtrace = perf_event__process_auxtrace; + c2c.tool.auxtrace_error = perf_event__process_auxtrace_error; + c2c.tool.ordering_requires_timestamps = true; session =perf_session__new (&data, &c2c.tool);if (IS_ERR (session)) { err =PTR_ERR (session);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 13/27 perf script: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-script.c | 65 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 35 deletions(-)
tools/perf/builtin-script.c +30 -35
@@ -3899,38 +3899,7 @@ int cmd_script(int argc, const char **argv)const char *dlfilter_file =NULL ;const char **__argv;int i, j, err =0 ; -struct perf_script script = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .attr = process_attr, - .event_update = perf_event__process_event_update, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .feature = process_feature_event, - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_script__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .stat = perf_event__process_stat_event, - .stat_round = process_stat_round_event, - .stat_config = process_stat_config_event, - .thread_map = process_thread_map_event, - .cpu_map = process_cpu_map_event, - .throttle = process_throttle_event, - .unthrottle = process_throttle_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; +struct perf_script script = {};struct perf_data data = { .mode =PERF_DATA_MODE_READ , };
@@ -4102,10 +4071,8 @@ int cmd_script(int argc, const char **argv) data.path = input_name; data.force = symbol_conf.force; -if (unsorted_dump) { +if (unsorted_dump) dump_trace = true; - script.tool.ordered_events = false; - }if (symbol__validate_sym_arguments ())return -1 ;
@@ -4296,6 +4263,34 @@ int cmd_script(int argc, const char **argv) use_browser =0 ; } +perf_tool__init (&script.tool, !unsorted_dump); + script.tool.sample = process_sample_event; + script.tool.mmap = perf_event__process_mmap; + script.tool.mmap2 = perf_event__process_mmap2; + script.tool.comm = perf_event__process_comm; + script.tool.namespaces = perf_event__process_namespaces; + script.tool.cgroup = perf_event__process_cgroup; + script.tool.exit = perf_event__process_exit; + script.tool.fork = perf_event__process_fork; + script.tool.attr = process_attr; + script.tool.event_update = perf_event__process_event_update; +#ifdef HAVE_LIBTRACEEVENT + script.tool.tracing_data = perf_event__process_tracing_data; +#endif + script.tool.feature = process_feature_event; + script.tool.build_id = perf_event__process_build_id; + script.tool.id_index = perf_event__process_id_index; + script.tool.auxtrace_info = perf_script__process_auxtrace_info; + script.tool.auxtrace = perf_event__process_auxtrace; + script.tool.auxtrace_error = perf_event__process_auxtrace_error; + script.tool.stat = perf_event__process_stat_event; + script.tool.stat_round = process_stat_round_event; + script.tool.stat_config = process_stat_config_event; + script.tool.thread_map = process_thread_map_event; + script.tool.cpu_map = process_cpu_map_event; + script.tool.throttle = process_throttle_event; + script.tool.unthrottle = process_throttle_event; + script.tool.ordering_requires_timestamps = true; session =perf_session__new (&data, &script.tool);if (IS_ERR (session))return PTR_ERR (session);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 14/27 perf inject: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-inject.c | 91 ++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 48 deletions(-)
tools/perf/builtin-inject.c +43 -48
@@ -2165,47 +2165,6 @@ static int __cmd_inject(struct perf_inject *inject)int cmd_inject (int argc,const char **argv) {struct perf_inject inject = { - .tool = { - .sample = perf_event__repipe_sample, - .read = perf_event__repipe_sample, - .mmap = perf_event__repipe, - .mmap2 = perf_event__repipe, - .comm = perf_event__repipe, - .namespaces = perf_event__repipe, - .cgroup = perf_event__repipe, - .fork = perf_event__repipe, - .exit = perf_event__repipe, - .lost = perf_event__repipe, - .lost_samples = perf_event__repipe, - .aux = perf_event__repipe, - .itrace_start = perf_event__repipe, - .aux_output_hw_id = perf_event__repipe, - .context_switch = perf_event__repipe, - .throttle = perf_event__repipe, - .unthrottle = perf_event__repipe, - .ksymbol = perf_event__repipe, - .bpf = perf_event__repipe, - .text_poke = perf_event__repipe, - .attr = perf_event__repipe_attr, - .event_update = perf_event__repipe_event_update, - .tracing_data = perf_event__repipe_op2_synth, - .finished_round = perf_event__repipe_oe_synth, - .build_id = perf_event__repipe_op2_synth, - .id_index = perf_event__repipe_op2_synth, - .auxtrace_info = perf_event__repipe_op2_synth, - .auxtrace_error = perf_event__repipe_op2_synth, - .time_conv = perf_event__repipe_op2_synth, - .thread_map = perf_event__repipe_op2_synth, - .cpu_map = perf_event__repipe_op2_synth, - .stat_config = perf_event__repipe_op2_synth, - .stat = perf_event__repipe_op2_synth, - .stat_round = perf_event__repipe_op2_synth, - .feature = perf_event__repipe_op2_synth, - .finished_init = perf_event__repipe_op2_synth, - .compressed = perf_event__repipe_op4_synth, - .auxtrace = perf_event__repipe_auxtrace, - .dont_split_sample_group = true, - }, .input_name ="-" , .samples =LIST_HEAD_INIT (inject.samples), .output = {
@@ -2270,6 +2229,7 @@ int cmd_inject(int argc, const char **argv)"perf inject [<options>]" , NULL }; +bool ordered_events;if (!inject.itrace_synth_opts.set) {/* Disable eager loading of kernel symbols that adds overhead to perf inject. */
@@ -2334,7 +2294,48 @@ int cmd_inject(int argc, const char **argv)if (strcmp (inject.input_name,"-" )) repipe = false; } - + ordered_events = inject.jit_mode || inject.sched_stat || + (inject.build_ids && !inject.build_id_all); +perf_tool__init (&inject.tool, ordered_events); + inject.tool.sample = perf_event__repipe_sample; + inject.tool.read = perf_event__repipe_sample; + inject.tool.mmap = perf_event__repipe; + inject.tool.mmap2 = perf_event__repipe; + inject.tool.comm = perf_event__repipe; + inject.tool.namespaces = perf_event__repipe; + inject.tool.cgroup = perf_event__repipe; + inject.tool.fork = perf_event__repipe; + inject.tool.exit = perf_event__repipe; + inject.tool.lost = perf_event__repipe; + inject.tool.lost_samples = perf_event__repipe; + inject.tool.aux = perf_event__repipe; + inject.tool.itrace_start = perf_event__repipe; + inject.tool.aux_output_hw_id = perf_event__repipe; + inject.tool.context_switch = perf_event__repipe; + inject.tool.throttle = perf_event__repipe; + inject.tool.unthrottle = perf_event__repipe; + inject.tool.ksymbol = perf_event__repipe; + inject.tool.bpf = perf_event__repipe; + inject.tool.text_poke = perf_event__repipe; + inject.tool.attr = perf_event__repipe_attr; + inject.tool.event_update = perf_event__repipe_event_update; + inject.tool.tracing_data = perf_event__repipe_op2_synth; + inject.tool.finished_round = perf_event__repipe_oe_synth; + inject.tool.build_id = perf_event__repipe_op2_synth; + inject.tool.id_index = perf_event__repipe_op2_synth; + inject.tool.auxtrace_info = perf_event__repipe_op2_synth; + inject.tool.auxtrace_error = perf_event__repipe_op2_synth; + inject.tool.time_conv = perf_event__repipe_op2_synth; + inject.tool.thread_map = perf_event__repipe_op2_synth; + inject.tool.cpu_map = perf_event__repipe_op2_synth; + inject.tool.stat_config = perf_event__repipe_op2_synth; + inject.tool.stat = perf_event__repipe_op2_synth; + inject.tool.stat_round = perf_event__repipe_op2_synth; + inject.tool.feature = perf_event__repipe_op2_synth; + inject.tool.finished_init = perf_event__repipe_op2_synth; + inject.tool.compressed = perf_event__repipe_op4_synth; + inject.tool.auxtrace = perf_event__repipe_auxtrace; + inject.tool.dont_split_sample_group = true; inject.session =__perf_session__new (&data, repipe,output_fd (&inject), &inject.tool);
@@ -2373,7 +2374,6 @@ int cmd_inject(int argc, const char **argv)* mmaps. We cannot generate the buildid hit list and * inject the jit mmaps at the same time for now. */ - inject.tool.ordered_events = true; inject.tool.ordering_requires_timestamps = true;if (known_build_ids !=NULL ) { inject.known_build_ids =
@@ -2386,15 +2386,10 @@ int cmd_inject(int argc, const char **argv) } } -if (inject.sched_stat) { - inject.tool.ordered_events = true; - } -#ifdef HAVE_JITDUMP if (inject.jit_mode) { inject.tool.mmap2 = perf_event__jit_repipe_mmap2; inject.tool.mmap = perf_event__jit_repipe_mmap; - inject.tool.ordered_events = true; inject.tool.ordering_requires_timestamps = true;/* * JIT MMAP injection injects all MMAP events in one go, so it
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 15/27 perf report: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-report.c | 55 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 28 deletions(-)
tools/perf/builtin-report.c +27 -28
@@ -799,7 +799,7 @@ static int process_attr(const struct perf_tool *tool __maybe_unused,static void stats_setup (struct report *rep) { -memset (&rep->tool,0 ,sizeof (rep->tool)); +perf_tool__init (&rep->tool,/*ordered_events=*/ false); rep->tool.attr = process_attr; rep->tool.sample = count_sample_event; rep->tool.lost_samples = count_lost_samples_event;
@@ -817,8 +817,7 @@ static int stats_print(struct report *rep)static void tasks_setup (struct report *rep) { -memset (&rep->tool,0 ,sizeof (rep->tool)); - rep->tool.ordered_events = true; +perf_tool__init (&rep->tool,/*ordered_events=*/ true);if (rep->mmaps_mode) { rep->tool.mmap = perf_event__process_mmap; rep->tool.mmap2 = perf_event__process_mmap2;
@@ -1272,30 +1271,6 @@ int cmd_report(int argc, const char **argv)NULL };struct report report = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .read = process_read_event, - .attr = process_attr, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .event_update = perf_event__process_event_update, - .feature = process_feature_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, .max_stack =PERF_MAX_STACK_DEPTH , .pretty_printing_style ="normal" , .socket_filter =-1 ,
@@ -1477,6 +1452,7 @@ int cmd_report(int argc, const char **argv) };int ret =hists__init ();char sort_tmp[128 ]; +bool ordered_events = true;if (ret <0 ) goto exit;
@@ -1531,7 +1507,7 @@ int cmd_report(int argc, const char **argv) report.tasks_mode = true;if (dump_trace && report.disable_order) - report.tool.ordered_events = false; + ordered_events = false;if (quiet)perf_quiet_option ();
@@ -1562,6 +1538,29 @@ int cmd_report(int argc, const char **argv) symbol_conf.skip_empty = report.skip_empty; repeat: +perf_tool__init (&report.tool, ordered_events); + report.tool.sample = process_sample_event; + report.tool.mmap = perf_event__process_mmap; + report.tool.mmap2 = perf_event__process_mmap2; + report.tool.comm = perf_event__process_comm; + report.tool.namespaces = perf_event__process_namespaces; + report.tool.cgroup = perf_event__process_cgroup; + report.tool.exit = perf_event__process_exit; + report.tool.fork = perf_event__process_fork; + report.tool.lost = perf_event__process_lost; + report.tool.read = process_read_event; + report.tool.attr = process_attr; +#ifdef HAVE_LIBTRACEEVENT + report.tool.tracing_data = perf_event__process_tracing_data; +#endif + report.tool.build_id = perf_event__process_build_id; + report.tool.id_index = perf_event__process_id_index; + report.tool.auxtrace_info = perf_event__process_auxtrace_info; + report.tool.auxtrace = perf_event__process_auxtrace; + report.tool.event_update = perf_event__process_event_update; + report.tool.feature = process_feature_event; + report.tool.ordering_requires_timestamps = true; + session =perf_session__new (&data, &report.tool);if (IS_ERR (session)) { ret =PTR_ERR (session);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 16/27 perf stat: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-stat.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tools/perf/builtin-stat.c +9 -9
@@ -2271,15 +2271,6 @@ static const char * const stat_report_usage[] = { };static struct perf_stat perf_stat = { - .tool = { - .attr = perf_event__process_attr, - .event_update = perf_event__process_event_update, - .thread_map = process_thread_map_event, - .cpu_map = process_cpu_map_event, - .stat_config = process_stat_config_event, - .stat = perf_event__process_stat_event, - .stat_round = process_stat_round_event, - }, .aggr_mode =AGGR_UNSET , .aggr_level =0 , };
@@ -2322,6 +2313,15 @@ static int __cmd_report(int argc, const char **argv) perf_stat.data.path = input_name; perf_stat.data.mode =PERF_DATA_MODE_READ ; +perf_tool__init (&perf_stat.tool,/*ordered_events=*/ false); + perf_stat.tool.attr = perf_event__process_attr; + perf_stat.tool.event_update = perf_event__process_event_update; + perf_stat.tool.thread_map = process_thread_map_event; + perf_stat.tool.cpu_map = process_cpu_map_event; + perf_stat.tool.stat_config = process_stat_config_event; + perf_stat.tool.stat = perf_event__process_stat_event; + perf_stat.tool.stat_round = process_stat_round_event; + session =perf_session__new (&perf_stat.data, &perf_stat.tool);if (IS_ERR (session))return PTR_ERR (session);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 17/27 perf annotate: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-annotate.c | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-)
tools/perf/builtin-annotate.c +20 -22
@@ -696,28 +696,7 @@ static const char * const annotate_usage[] = {int cmd_annotate (int argc,const char **argv) { -struct perf_annotate annotate = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .namespaces = perf_event__process_namespaces, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .feature = process_feature_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; +struct perf_annotate annotate = {};struct perf_data data = { .mode =PERF_DATA_MODE_READ , };
@@ -876,6 +855,25 @@ int cmd_annotate(int argc, const char **argv) data.path = input_name; +perf_tool__init (&annotate.tool,/*ordered_events=*/ true); + annotate.tool.sample = process_sample_event; + annotate.tool.mmap = perf_event__process_mmap; + annotate.tool.mmap2 = perf_event__process_mmap2; + annotate.tool.comm = perf_event__process_comm; + annotate.tool.exit = perf_event__process_exit; + annotate.tool.fork = perf_event__process_fork; + annotate.tool.namespaces = perf_event__process_namespaces; + annotate.tool.attr = perf_event__process_attr; + annotate.tool.build_id = perf_event__process_build_id; +#ifdef HAVE_LIBTRACEEVENT + annotate.tool.tracing_data = perf_event__process_tracing_data; +#endif + annotate.tool.id_index = perf_event__process_id_index; + annotate.tool.auxtrace_info = perf_event__process_auxtrace_info; + annotate.tool.auxtrace = perf_event__process_auxtrace; + annotate.tool.feature = process_feature_event; + annotate.tool.ordering_requires_timestamps = true; + annotate.session =perf_session__new (&data, &annotate.tool);if (IS_ERR (annotate.session))return PTR_ERR (annotate.session);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 18/27 perf sched: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-sched.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
tools/perf/builtin-sched.c +7 -9
@@ -3100,7 +3100,6 @@ static int perf_sched__timehist(struct perf_sched *sched) sched->tool.tracing_data = perf_event__process_tracing_data; sched->tool.build_id = perf_event__process_build_id; - sched->tool.ordered_events = true; sched->tool.ordering_requires_timestamps = true; symbol_conf.use_callchain = sched->show_callchain;
@@ -3605,14 +3604,6 @@ int cmd_sched(int argc, const char **argv) {static const char default_sort_order[] ="avg, max, switch, runtime" ;struct perf_sched sched = { - .tool = { - .sample = perf_sched__process_tracepoint_sample, - .comm = perf_sched__process_comm, - .namespaces = perf_event__process_namespaces, - .lost = perf_event__process_lost, - .fork = perf_sched__process_fork_event, - .ordered_events = true, - }, .cmp_pid =LIST_HEAD_INIT (sched.cmp_pid), .sort_list =LIST_HEAD_INIT (sched.sort_list), .sort_order = default_sort_order,
@@ -3733,6 +3724,13 @@ int cmd_sched(int argc, const char **argv) };int ret; +perf_tool__init (&sched.tool,/*ordered_events=*/ true); + sched.tool.sample = perf_sched__process_tracepoint_sample; + sched.tool.comm = perf_sched__process_comm; + sched.tool.namespaces = perf_event__process_namespaces; + sched.tool.lost = perf_event__process_lost; + sched.tool.fork = perf_sched__process_fork_event; + argc =parse_options_subcommand (argc, argv, sched_options, sched_subcommands, sched_usage,PARSE_OPT_STOP_AT_NON_OPTION );if (!argc)
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 19/27 perf mem: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-mem.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
tools/perf/builtin-mem.c +17 -16
@@ -276,7 +276,23 @@ static int report_raw_events(struct perf_mem *mem) .force = mem->force, };int ret; -struct perf_session *session =perf_session__new (&data, &mem->tool); +struct perf_session *session; + +perf_tool__init (&mem->tool,/*ordered_events=*/ true); + mem->tool.sample = process_sample_event; + mem->tool.mmap = perf_event__process_mmap; + mem->tool.mmap2 = perf_event__process_mmap2; + mem->tool.comm = perf_event__process_comm; + mem->tool.lost = perf_event__process_lost; + mem->tool.fork = perf_event__process_fork; + mem->tool.attr = perf_event__process_attr; + mem->tool.build_id = perf_event__process_build_id; + mem->tool.namespaces = perf_event__process_namespaces; + mem->tool.auxtrace_info = perf_event__process_auxtrace_info; + mem->tool.auxtrace = perf_event__process_auxtrace; + mem->tool.auxtrace_error = perf_event__process_auxtrace_error; + + session =perf_session__new (&data, &mem->tool);if (IS_ERR (session))return PTR_ERR (session);
@@ -458,21 +474,6 @@ int cmd_mem(int argc, const char **argv) {struct stat st;struct perf_mem mem = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .lost = perf_event__process_lost, - .fork = perf_event__process_fork, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, - .namespaces = perf_event__process_namespaces, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .ordered_events = true, - }, .input_name ="perf.data" ,/* * default to both load an store sampling
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 20/27 perf timechart: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-timechart.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
tools/perf/builtin-timechart.c +8 -9
@@ -1606,10 +1606,16 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name) .mode = PERF_DATA_MODE_READ, .force = tchart->force, }; - -struct perf_session *session =perf_session__new (&data, &tchart->tool); +struct perf_session *session;int ret = -EINVAL ; +perf_tool__init (&tchart->tool,/*ordered_events=*/ true); + tchart->tool.comm = process_comm_event; + tchart->tool.fork = process_fork_event; + tchart->tool.exit = process_exit_event; + tchart->tool.sample = process_sample_event; + + session =perf_session__new (&data, &tchart->tool);if (IS_ERR (session))return PTR_ERR (session);
@@ -1924,13 +1930,6 @@ parse_time(const struct option *opt, const char *arg, int __maybe_unused unset)int cmd_timechart (int argc,const char **argv) {struct timechart tchart = { - .tool = { - .comm = process_comm_event, - .fork = process_fork_event, - .exit = process_exit_event, - .sample = process_sample_event, - .ordered_events = true, - }, .proc_num =15 , .min_time =NSEC_PER_MSEC , .merge_dist =1000 ,
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 21/27 perf diff: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-diff.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
tools/perf/builtin-diff.c +13 -15
@@ -467,21 +467,7 @@ static int diff__process_sample_event(const struct perf_tool *tool,return ret; } -static struct perf_diff pdiff = { - .tool = { - .sample = diff__process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, -}; +static struct perf_diff pdiff;static struct evsel *evsel_match (struct evsel *evsel,struct evlist *evlist)
@@ -1959,6 +1945,18 @@ int cmd_diff(int argc, const char **argv)if (ret <0 )return ret; +perf_tool__init (&pdiff.tool,/*ordered_events=*/ true); + pdiff.tool.sample = diff__process_sample_event; + pdiff.tool.mmap = perf_event__process_mmap; + pdiff.tool.mmap2 = perf_event__process_mmap2; + pdiff.tool.comm = perf_event__process_comm; + pdiff.tool.exit = perf_event__process_exit; + pdiff.tool.fork = perf_event__process_fork; + pdiff.tool.lost = perf_event__process_lost; + pdiff.tool.namespaces = perf_event__process_namespaces; + pdiff.tool.cgroup = perf_event__process_cgroup; + pdiff.tool.ordering_requires_timestamps = true; +perf_config (diff__config,NULL ); argc =parse_options (argc, argv, options, diff_usage,0 );
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 22/27 perf data convert json: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/util/data-convert-json.c | 43 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-)
tools/perf/util/data-convert-json.c +20 -23
@@ -316,39 +316,36 @@ int bt_convert__perf2json(const char *input_name, const char *output_name,struct perf_session *session;int fd;int ret =-1 ; -struct convert_json c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .event_update = perf_event__process_event_update, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, .first = true, .events_count =0 , }; -struct perf_data data = { .mode =PERF_DATA_MODE_READ , .path = input_name, .force = opts->force, }; +perf_tool__init (&c.tool,/*ordered_events=*/ true); + c.tool.sample = process_sample_event; + c.tool.mmap = perf_event__process_mmap; + c.tool.mmap2 = perf_event__process_mmap2; + c.tool.comm = perf_event__process_comm; + c.tool.namespaces = perf_event__process_namespaces; + c.tool.cgroup = perf_event__process_cgroup; + c.tool.exit = perf_event__process_exit; + c.tool.fork = perf_event__process_fork; + c.tool.lost = perf_event__process_lost; +#ifdef HAVE_LIBTRACEEVENT + c.tool.tracing_data = perf_event__process_tracing_data; +#endif + c.tool.build_id = perf_event__process_build_id; + c.tool.id_index = perf_event__process_id_index; + c.tool.auxtrace_info = perf_event__process_auxtrace_info; + c.tool.auxtrace = perf_event__process_auxtrace; + c.tool.event_update = perf_event__process_event_update; + c.tool.ordering_requires_timestamps = true; +if (opts->all) {pr_err ("--all is currently unsupported for JSON output.\n" ); goto err;
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 23/27 perf data convert ctf: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/util/data-convert-bt.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
tools/perf/util/data-convert-bt.c +14 -16
@@ -1607,25 +1607,23 @@ int bt_convert__perf2ctf(const char *input, const char *path, .mode = PERF_DATA_MODE_READ, .force = opts->force, }; -struct convert c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .tracing_data = perf_event__process_tracing_data, - .build_id = perf_event__process_build_id, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; +struct convert c = {};struct ctf_writer *cw = &c.writer;int err; +perf_tool__init (&c.tool,/*ordered_events=*/ true); + c.tool.sample = process_sample_event; + c.tool.mmap = perf_event__process_mmap; + c.tool.mmap2 = perf_event__process_mmap2; + c.tool.comm = perf_event__process_comm; + c.tool.exit = perf_event__process_exit; + c.tool.fork = perf_event__process_fork; + c.tool.lost = perf_event__process_lost; + c.tool.tracing_data = perf_event__process_tracing_data; + c.tool.build_id = perf_event__process_build_id; + c.tool.namespaces = perf_event__process_namespaces; + c.tool.ordering_requires_timestamps = true; +if (opts->all) { c.tool.comm = process_comm_event; c.tool.exit = process_exit_event;
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 24/27 perf test event_update: Ensure tools is initialized
In reply to Ian RogersEnsure tool is initialized to avoid lazy initialization pattern so that more uses of struct perf_tool can be made const.
--- tools/perf/tests/event_update.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/event_update.c +1 -0
@@ -103,6 +103,7 @@ static int test__event_update(struct test_suite *test __maybe_unused, int subtesTEST_ASSERT_VAL ("failed to synthesize attr update scale" , !perf_event__synthesize_event_update_scale (NULL , evsel, process_event_scale)); +perf_tool__init (&tmp.tool,/*ordered_events=*/ false); tmp.name =evsel__name (evsel); TEST_ASSERT_VAL("failed to synthesize attr update name",
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 25/27 perf kwork: Use perf_tool__init
In reply to Ian RogersUse perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults.
--- tools/perf/builtin-kwork.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
tools/perf/builtin-kwork.c +5 -6
@@ -2322,12 +2322,6 @@ int cmd_kwork(int argc, const char **argv) {static struct perf_kwork kwork = { .class_list =LIST_HEAD_INIT (kwork.class_list), - .tool = { - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .sample = perf_kwork__process_tracepoint_sample, - .ordered_events = true, - }, .atom_page_list =LIST_HEAD_INIT (kwork.atom_page_list), .sort_list =LIST_HEAD_INIT (kwork.sort_list), .cmp_id =LIST_HEAD_INIT (kwork.cmp_id),
@@ -2462,6 +2456,11 @@ int cmd_kwork(int argc, const char **argv) "record", "report", "latency", "timehist", "top", NULL }; +perf_tool__init (&kwork.tool,/*ordered_events=*/ true); + kwork.tool.mmap = perf_event__process_mmap; + kwork.tool.mmap2 = perf_event__process_mmap2; + kwork.tool.sample = perf_kwork__process_tracepoint_sample; + argc =parse_options_subcommand (argc, argv, kwork_options, kwork_subcommands, kwork_usage,PARSE_OPT_STOP_AT_NON_OPTION );
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 26/27 perf tool: Remove perf_tool__fill_defaults
In reply to Ian RogersNow all tools are fully initialized prior to use it has no use so remove.
--- tools/perf/util/session.c | 6 --- tools/perf/util/tool.c | 89 --------------------------------------- tools/perf/util/tool.h | 1 - 3 files changed, 96 deletions(-)
tools/perf/util/session.c +0 -6
@@ -1781,8 +1781,6 @@ static int __perf_session__process_pipe_events(struct perf_session *session)void *p;bool update_prog = false; -perf_tool__fill_defaults (tool); -/* * If it's from a file saving pipe data (by redirection), it would have * a file name other than "-". Then we can get the total size and show
@@ -2206,8 +2204,6 @@ static int __perf_session__process_events(struct perf_session *session)struct ui_progress prog;int err; -perf_tool__fill_defaults (tool); -if (rd.data_size ==0 )return -1 ;
@@ -2260,8 +2256,6 @@ static int __perf_session__process_dir_events(struct perf_session *session)u64 total_size =perf_data__size (session->data);struct reader *rd; -perf_tool__fill_defaults (tool); -ui_progress__init_size (&prog, total_size,"Processing events..." ); nr_readers =1 ;
tools/perf/util/tool.c +0 -89
95 lines not on this page · raw message
tools/perf/util/tool.h +0 -1
@@ -90,7 +90,6 @@ struct perf_tool { };void perf_tool__init (struct perf_tool *tool,bool ordered_events); -void perf_tool__fill_defaults (struct perf_tool *tool);bool perf_tool__compressed_is_stub (const struct perf_tool *tool);
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Ian Rogers
reviewerPATCH v7 27/27 perf session: Constify tool
In reply to Ian RogersMake tool const now that all uses are const and perf_tool__fill_defaults won't be used. The aim is to better capture that sessions don't mutate tools.
--- tools/perf/util/session.c | 6 +++--- tools/perf/util/session.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/session.c +3 -3
@@ -1770,7 +1770,7 @@ static int __perf_session__process_decomp_events(struct perf_session *session);static int __perf_session__process_pipe_events (struct perf_session *session) {struct ordered_events *oe = &session->ordered_events; -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool;struct ui_progress prog;union perf_event *event;uint32_t size, cur_size =0 ;
@@ -2200,7 +2200,7 @@ static int __perf_session__process_events(struct perf_session *session) .in_place_update = session->data->in_place_update, };struct ordered_events *oe = &session->ordered_events; -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool;struct ui_progress prog;int err;
@@ -2250,7 +2250,7 @@ static int __perf_session__process_events(struct perf_session *session)static int __perf_session__process_dir_events (struct perf_session *session) {struct perf_data *data = session->data; -struct perf_tool *tool = session->tool; +const struct perf_tool *tool = session->tool;int i, ret, readers, nr_readers;struct ui_progress prog;u64 total_size =perf_data__size (session->data);
tools/perf/util/session.h +1 -1
@@ -43,7 +43,7 @@ struct perf_session {u64 one_mmap_offset;struct ordered_events ordered_events;struct perf_data *data; -struct perf_tool *tool; +const struct perf_tool *tool;u64 bytes_transferred;u64 bytes_compressed;struct zstd_data zstd_data;
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog