[PATCH v5 12/25] perf db-export: Remove evsel from struct export_sample

Ian Rogers
2026-04-03T20:40:52Z

As the sample contains the evsel avoid the duplication. Remove the
evsel from db_export__sample as it can also read from the sample.

Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/db-export.c | 5 ++---
tools/perf/util/db-export.h | 3 +--
tools/perf/util/scripting-engines/trace-event-python.c | 8 ++++----
3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index a1f578c3a8d5..fdfd825c7ef4 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -345,14 +345,13 @@ static int db_export__threads(struct db_export *dbe, struct thread *thread,
}

int db_export__sample(struct db_export *dbe, union perf_event *event,
- struct perf_sample *sample, struct evsel *evsel,
+ struct perf_sample *sample,
struct addr_location *al, struct addr_location *addr_al)
{
struct thread *thread = al->thread;
struct export_sample es = {
.event = event,
.sample = sample,
- .evsel = evsel,
.al = al,
};
struct thread *main_thread;
@@ -365,7 +364,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
if (!machine)
return -1;

- err = db_export__evsel(dbe, evsel);
+ err = db_export__evsel(dbe, sample->evsel);
if (err)
return err;

diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index 23983cb35706..1abbfd398e3a 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -25,7 +25,6 @@ struct call_return;
struct export_sample {
union perf_event *event;
struct perf_sample *sample;
- struct evsel *evsel;
struct addr_location *al;
u64 db_id;
u64 comm_db_id;
@@ -96,7 +95,7 @@ int db_export__symbol(struct db_export *dbe, struct symbol *sym,
int db_export__branch_type(struct db_export *dbe, u32 branch_type,
const char *name);
int db_export__sample(struct db_export *dbe, union perf_event *event,
- struct perf_sample *sample, struct evsel *evsel,
+ struct perf_sample *sample,
struct addr_location *al, struct addr_location *addr_al);

int db_export__branch_types(struct db_export *dbe);
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 08197cef44c8..8de08cebe240 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -1312,7 +1312,7 @@ static void python_export_sample_table(struct db_export *dbe,
t = tuple_new(28);

tuple_set_d64(t, 0, es->db_id);
- tuple_set_d64(t, 1, es->evsel->db_id);
+ tuple_set_d64(t, 1, es->sample->evsel->db_id);
tuple_set_d64(t, 2, maps__machine(thread__maps(es->al->thread))->db_id);
tuple_set_d64(t, 3, thread__db_id(es->al->thread));
tuple_set_d64(t, 4, es->comm_db_id);
@@ -1353,7 +1353,7 @@ static void python_export_synth(struct db_export *dbe, struct export_sample *es)
t = tuple_new(3);

tuple_set_d64(t, 0, es->db_id);
- tuple_set_d64(t, 1, es->evsel->core.attr.config);
+ tuple_set_d64(t, 1, es->sample->evsel->core.attr.config);
tuple_set_bytes(t, 2, es->sample->raw_data, es->sample->raw_size);

call_object(tables->synth_handler, t, "synth_data");
@@ -1368,7 +1368,7 @@ static int python_export_sample(struct db_export *dbe,

python_export_sample_table(dbe, es);

- if (es->evsel->core.attr.type == PERF_TYPE_SYNTH && tables->synth_handler)
+ if (es->sample->evsel->core.attr.type == PERF_TYPE_SYNTH && tables->synth_handler)
python_export_synth(dbe, es);

return 0;
@@ -1517,7 +1517,7 @@ static void python_process_event(union perf_event *event,
/* Reserve for future process_hw/sw/raw APIs */
default:
if (tables->db_export_mode)
- db_export__sample(&tables->dbe, event, sample, evsel, al, addr_al);
+ db_export__sample(&tables->dbe, event, sample, al, addr_al);
else
python_process_general_event(sample, evsel, al, addr_al);
}
--
2.53.0.1213.gd9a14994de-goog