mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
perf tool: Remove evsel from tool APIs that pass the sample
As struct perf_sample now directly contains its own resolved evsel pointer, passing the evsel separately is redundant and clutters the interface. Remove the redundant evsel parameter from tool-specific handlers and structures, ensuring the tool always directly accesses the evsel bound to the sample. This simplifies the API signatures and eliminates the risk of passing an inconsistent evsel. Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrew Jones <ajones@ventanamicro.com> Cc: Anup Patel <anup@brainfault.org> Cc: Athira Rajeev <atrajeev@linux.ibm.com> Cc: Blake Jones <blakejones@google.com> Cc: Chen Ni <nichen@iscas.ac.cn> Cc: Chun-Tse Shao <ctshao@google.com> Cc: Dapeng Mi <dapeng1.mi@linux.intel.com> Cc: Derek Foreman <derek.foreman@collabora.com> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Dr. David Alan Gilbert <linux@treblig.org> Cc: Howard Chu <howardchu95@gmail.com> Cc: Hrishikesh Suresh <hrishikesh123s@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com> Cc: Leo Yan <leo.yan@arm.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <pjw@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Quan Zhou <zhouquan@iscas.ac.cn> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Swapnil Sapkal <swapnil.sapkal@amd.com> Cc: Thomas Falcon <thomas.falcon@intel.com> Cc: Tianyou Li <tianyou.li@intel.com> Cc: Yujie Liu <yujie.liu@intel.com> Cc: tanze <tanze@kylinos.cn> [ Fixed up conflict with "perf inject: Fix itrace branch stack synthesis" series ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
daac18e7c4
commit
fc444d05b4
@@ -283,7 +283,6 @@ static int evsel__add_sample(struct evsel *evsel, struct perf_sample *sample,
|
||||
static int process_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct perf_annotate *ann = container_of(tool, struct perf_annotate, tool);
|
||||
@@ -302,7 +301,7 @@ static int process_sample_event(const struct perf_tool *tool,
|
||||
goto out_put;
|
||||
|
||||
if (!al.filtered &&
|
||||
evsel__add_sample(evsel, sample, &al, ann, machine)) {
|
||||
evsel__add_sample(sample->evsel, sample, &al, ann, machine)) {
|
||||
pr_warning("problem incrementing symbol count, "
|
||||
"skipping event\n");
|
||||
ret = -1;
|
||||
|
||||
@@ -314,9 +314,9 @@ static void perf_c2c__evsel_hists_inc_stats(struct evsel *evsel,
|
||||
static int process_sample_event(const struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct c2c_hists *c2c_hists = &c2c.hists;
|
||||
struct c2c_hist_entry *c2c_he;
|
||||
struct c2c_stats stats = { .nr_entries = 0, };
|
||||
|
||||
@@ -390,11 +390,11 @@ static struct hist_entry_ops block_hist_ops = {
|
||||
static int diff__process_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct perf_diff *pdiff = container_of(tool, struct perf_diff, tool);
|
||||
struct addr_location al;
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct hists *hists = evsel__hists(evsel);
|
||||
struct hist_entry_iter iter = {
|
||||
.evsel = evsel,
|
||||
|
||||
@@ -403,11 +403,10 @@ typedef int (*inject_handler)(const struct perf_tool *tool,
|
||||
static int perf_event__repipe_sample(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct perf_inject *inject = container_of(tool, struct perf_inject,
|
||||
tool);
|
||||
struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
|
||||
if (evsel == NULL)
|
||||
return perf_event__repipe_synth(tool, event);
|
||||
@@ -417,7 +416,7 @@ static int perf_event__repipe_sample(const struct perf_tool *tool,
|
||||
return f(tool, event, sample, evsel, machine);
|
||||
}
|
||||
|
||||
build_id__mark_dso_hit(tool, event, sample, evsel, machine);
|
||||
build_id__mark_dso_hit(tool, event, sample, machine);
|
||||
|
||||
if (inject->itrace_synth_opts.set &&
|
||||
(inject->itrace_synth_opts.last_branch ||
|
||||
@@ -491,10 +490,10 @@ static int perf_event__repipe_sample(const struct perf_tool *tool,
|
||||
static int perf_event__convert_sample_callchain(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct callchain_cursor *cursor = get_tls_callchain_cursor();
|
||||
union perf_event *event_copy = (void *)inject->event_copy;
|
||||
struct callchain_cursor_node *node;
|
||||
@@ -1100,10 +1099,8 @@ static int mark_dso_hit_callback(struct callchain_cursor_node *node, void *data)
|
||||
args->mmap_evsel, map, /*sample_in_dso=*/false);
|
||||
}
|
||||
|
||||
int perf_event__inject_buildid(const struct perf_tool *tool, union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel __maybe_unused,
|
||||
struct machine *machine)
|
||||
static int perf_event__inject_buildid(const struct perf_tool *tool, union perf_event *event,
|
||||
struct perf_sample *sample, struct machine *machine)
|
||||
{
|
||||
struct addr_location al;
|
||||
struct thread *thread;
|
||||
@@ -1133,7 +1130,7 @@ int perf_event__inject_buildid(const struct perf_tool *tool, union perf_event *e
|
||||
/*sample_in_dso=*/true);
|
||||
}
|
||||
|
||||
sample__for_each_callchain_node(thread, evsel, sample, PERF_MAX_STACK_DEPTH,
|
||||
sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_STACK_DEPTH,
|
||||
/*symbols=*/false, mark_dso_hit_callback, &args);
|
||||
thread__put(thread);
|
||||
repipe:
|
||||
@@ -1215,7 +1212,7 @@ found:
|
||||
perf_event__synthesize_sample(event_sw, evsel->core.attr.sample_type,
|
||||
evsel->core.attr.read_format,
|
||||
evsel->core.attr.branch_sample_type, &sample_sw);
|
||||
build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine);
|
||||
build_id__mark_dso_hit(tool, event_sw, &sample_sw, machine);
|
||||
ret = perf_event__repipe(tool, event_sw, &sample_sw, machine);
|
||||
perf_sample__exit(&sample_sw);
|
||||
return ret;
|
||||
|
||||
@@ -960,9 +960,9 @@ typedef int (*tracepoint_handler)(struct evsel *evsel,
|
||||
static int process_sample_event(const struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct evsel *evsel = sample->evsel;
|
||||
int err = 0;
|
||||
struct thread *thread = machine__findnew_thread(machine, sample->pid,
|
||||
sample->tid);
|
||||
|
||||
@@ -941,9 +941,9 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
|
||||
|
||||
static bool handle_kvm_event(struct perf_kvm_stat *kvm,
|
||||
struct thread *thread,
|
||||
struct evsel *evsel,
|
||||
struct perf_sample *sample)
|
||||
{
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct vcpu_event_record *vcpu_record;
|
||||
struct event_key key = { .key = INVALID_KEY,
|
||||
.exit_reasons = kvm->exit_reasons };
|
||||
@@ -1133,7 +1133,6 @@ static bool skip_sample(struct perf_kvm_stat *kvm,
|
||||
static int process_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
int err = 0;
|
||||
@@ -1156,7 +1155,7 @@ static int process_sample_event(const struct perf_tool *tool,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!handle_kvm_event(kvm, thread, evsel, sample))
|
||||
if (!handle_kvm_event(kvm, thread, sample))
|
||||
err = -1;
|
||||
|
||||
thread__put(thread);
|
||||
|
||||
@@ -1955,9 +1955,9 @@ typedef int (*tracepoint_handler)(const 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,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct evsel *evsel = sample->evsel;
|
||||
int err = 0;
|
||||
|
||||
if (evsel->handler != NULL) {
|
||||
|
||||
@@ -1430,9 +1430,9 @@ typedef int (*tracepoint_handler)(struct evsel *evsel,
|
||||
static int process_sample_event(const struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct evsel *evsel = sample->evsel;
|
||||
int err = 0;
|
||||
struct thread *thread = machine__findnew_thread(machine, sample->pid,
|
||||
sample->tid);
|
||||
|
||||
@@ -255,7 +255,6 @@ out_put:
|
||||
static int process_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel __maybe_unused,
|
||||
struct machine *machine)
|
||||
{
|
||||
return dump_raw_samples(tool, event, sample, machine);
|
||||
|
||||
@@ -1490,7 +1490,6 @@ static void set_timestamp_boundary(struct record *rec, u64 sample_time)
|
||||
static int process_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct record *rec = container_of(tool, struct record, tool);
|
||||
@@ -1501,7 +1500,7 @@ static int process_sample_event(const struct perf_tool *tool,
|
||||
return 0;
|
||||
|
||||
rec->samples++;
|
||||
return build_id__mark_dso_hit(tool, event, sample, evsel, machine);
|
||||
return build_id__mark_dso_hit(tool, event, sample, machine);
|
||||
}
|
||||
|
||||
static int process_buildids(struct record *rec)
|
||||
|
||||
@@ -265,10 +265,10 @@ static int process_feature_event(const 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,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct report *rep = container_of(tool, struct report, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct addr_location al;
|
||||
struct hist_entry_iter iter = {
|
||||
.evsel = evsel,
|
||||
@@ -345,7 +345,6 @@ out_put:
|
||||
static int process_read_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample __maybe_unused,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine __maybe_unused)
|
||||
{
|
||||
struct report *rep = container_of(tool, struct report, tool);
|
||||
@@ -353,7 +352,7 @@ static int process_read_event(const struct perf_tool *tool,
|
||||
if (rep->show_threads) {
|
||||
int err = perf_read_values_add_value(&rep->show_threads_values,
|
||||
event->read.pid, event->read.tid,
|
||||
evsel,
|
||||
sample->evsel,
|
||||
event->read.value);
|
||||
|
||||
if (err)
|
||||
@@ -779,11 +778,10 @@ static void report__output_resort(struct report *rep)
|
||||
|
||||
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,
|
||||
struct perf_sample *sample,
|
||||
struct machine *machine __maybe_unused)
|
||||
{
|
||||
struct hists *hists = evsel__hists(evsel);
|
||||
struct hists *hists = evsel__hists(sample->evsel);
|
||||
|
||||
hists__inc_nr_events(hists);
|
||||
return 0;
|
||||
|
||||
@@ -1867,9 +1867,9 @@ typedef int (*tracepoint_handler)(const struct perf_tool *tool,
|
||||
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,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct evsel *evsel = sample->evsel;
|
||||
int err = 0;
|
||||
|
||||
if (evsel->handler != NULL) {
|
||||
@@ -3184,10 +3184,10 @@ typedef int (*sched_handler)(const 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,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
int err = 0;
|
||||
struct perf_cpu this_cpu = {
|
||||
.cpu = sample->cpu,
|
||||
|
||||
@@ -2646,10 +2646,10 @@ static bool filter_cpu(struct perf_sample *sample)
|
||||
static int process_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct perf_script *scr = container_of(tool, struct perf_script, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct addr_location al;
|
||||
struct addr_location addr_al;
|
||||
int ret = 0;
|
||||
@@ -2730,10 +2730,10 @@ out_put:
|
||||
static int process_deferred_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct perf_script *scr = container_of(tool, struct perf_script, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct perf_event_attr *attr = &evsel->core.attr;
|
||||
struct evsel_script *es = evsel->priv;
|
||||
unsigned int type = output_type(attr->type);
|
||||
|
||||
@@ -574,10 +574,10 @@ typedef int (*tracepoint_handler)(struct timechart *tchart,
|
||||
static int process_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct timechart *tchart = container_of(tool, struct timechart, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
|
||||
if (evsel->core.attr.sample_type & PERF_SAMPLE_TIME) {
|
||||
if (!tchart->first_time || tchart->first_time > sample->time)
|
||||
|
||||
@@ -3501,10 +3501,10 @@ static void trace__set_base_time(struct trace *trace,
|
||||
static int trace__process_sample(const struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine __maybe_unused)
|
||||
{
|
||||
struct trace *trace = container_of(tool, struct trace, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct thread *thread;
|
||||
int err = 0;
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ static int mark_dso_hit_callback(struct callchain_cursor_node *node, void *data
|
||||
int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct addr_location al;
|
||||
@@ -74,7 +73,7 @@ int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused,
|
||||
|
||||
addr_location__exit(&al);
|
||||
|
||||
sample__for_each_callchain_node(thread, evsel, sample, PERF_MAX_STACK_DEPTH,
|
||||
sample__for_each_callchain_node(thread, sample->evsel, sample, PERF_MAX_STACK_DEPTH,
|
||||
/*symbols=*/false, mark_dso_hit_callback, /*data=*/NULL);
|
||||
|
||||
|
||||
|
||||
@@ -34,12 +34,7 @@ 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(const struct perf_tool *tool, union perf_event *event,
|
||||
struct perf_sample *sample, struct evsel *evsel,
|
||||
struct machine *machine);
|
||||
|
||||
int perf_event__inject_buildid(const struct perf_tool *tool, union perf_event *event,
|
||||
struct perf_sample *sample, struct evsel *evsel,
|
||||
struct machine *machine);
|
||||
struct perf_sample *sample, struct machine *machine);
|
||||
|
||||
bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);
|
||||
int perf_session__write_buildid_table(struct perf_session *session,
|
||||
|
||||
@@ -803,10 +803,10 @@ static bool is_flush_needed(struct ctf_stream *cs)
|
||||
static int process_sample_event(const struct perf_tool *tool,
|
||||
union perf_event *_event,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine __maybe_unused)
|
||||
{
|
||||
struct convert *c = container_of(tool, struct convert, tool);
|
||||
struct evsel *evsel = sample->evsel;
|
||||
struct evsel_priv *priv = evsel->priv;
|
||||
struct ctf_writer *cw = &c->writer;
|
||||
struct ctf_stream *cs;
|
||||
|
||||
@@ -159,13 +159,12 @@ static void output_sample_callchain_entry(const 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,
|
||||
struct machine *machine)
|
||||
{
|
||||
struct convert_json *c = container_of(tool, struct convert_json, tool);
|
||||
FILE *out = c->out;
|
||||
struct addr_location al;
|
||||
u64 sample_type = __evlist__combined_sample_type(evsel->evlist);
|
||||
u64 sample_type = __evlist__combined_sample_type(sample->evsel->evlist);
|
||||
u8 cpumode = PERF_RECORD_MISC_USER;
|
||||
|
||||
addr_location__init(&al);
|
||||
@@ -245,7 +244,7 @@ static int process_sample_event(const struct perf_tool *tool,
|
||||
|
||||
#ifdef HAVE_LIBTRACEEVENT
|
||||
if (sample->raw_data) {
|
||||
struct tep_event *tp_format = evsel__tp_format(evsel);
|
||||
struct tep_event *tp_format = evsel__tp_format(sample->evsel);
|
||||
struct tep_format_field **fields = tp_format ? tep_event_fields(tp_format) : NULL;
|
||||
|
||||
if (fields) {
|
||||
|
||||
@@ -185,7 +185,6 @@ static bool should_ignore_sample(const struct perf_sample *sample, const struct
|
||||
static int process_sample_event(const struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event __maybe_unused,
|
||||
struct perf_sample *sample,
|
||||
struct evsel *evsel,
|
||||
struct machine *machine __maybe_unused)
|
||||
{
|
||||
struct tpebs_retire_lat *t;
|
||||
@@ -196,7 +195,7 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
|
||||
mutex_unlock(tpebs_mtx_get());
|
||||
return 0;
|
||||
}
|
||||
t = tpebs_retire_lat__find(evsel);
|
||||
t = tpebs_retire_lat__find(sample->evsel);
|
||||
if (!t) {
|
||||
mutex_unlock(tpebs_mtx_get());
|
||||
return -EINVAL;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user