[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260131200224.1296136-7-irogers@google.com>
Date: Sat, 31 Jan 2026 12:02:24 -0800
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
James Clark <james.clark@...aro.org>, John Garry <john.g.garry@...cle.com>,
Will Deacon <will@...nel.org>, Mike Leach <mike.leach@...aro.org>, Leo Yan <leo.yan@...ux.dev>,
Paul Walmsley <pjw@...nel.org>, Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Alexandre Ghiti <alex@...ti.fr>, Shimin Guo <shimin.guo@...dio.com>, Yunseong Kim <ysk@...lloc.com>,
Athira Rajeev <atrajeev@...ux.ibm.com>, Quan Zhou <zhouquan@...as.ac.cn>,
Andrew Jones <ajones@...tanamicro.com>, Anup Patel <anup@...infault.org>,
Dapeng Mi <dapeng1.mi@...ux.intel.com>, Thomas Falcon <thomas.falcon@...el.com>,
Blake Jones <blakejones@...gle.com>, Swapnil Sapkal <swapnil.sapkal@....com>,
Kan Liang <kan.liang@...ux.intel.com>, Howard Chu <howardchu95@...il.com>,
Anubhav Shelat <ashelat@...hat.com>, Aditya Bodkhe <aditya.b1@...ux.ibm.com>,
Chun-Tse Shao <ctshao@...gle.com>, Andi Kleen <ak@...ux.intel.com>,
Dmitry Vyukov <dvyukov@...gle.com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-riscv@...ts.infradead.org
Subject: [PATCH v2 6/6] perf thread: Don't require machine to compute the e_machine
The machine can be calculated from a thread via its maps. Don't
require the machine argument to simplify callers and also to delay
computing the machine until a little later.
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
tools/perf/util/scripting-engines/trace-event-python.c | 8 +++-----
tools/perf/util/session.c | 3 +--
tools/perf/util/thread.c | 5 +++++
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 62c9c73daef5..2b0df7bd9a46 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -837,7 +837,6 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
PyObject *callchain)
{
PyObject *dict, *dict_sample, *brstack, *brstacksym;
- struct machine *machine;
uint16_t e_machine = EM_HOST;
uint32_t e_flags = EF_HOST;
@@ -926,10 +925,9 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
PyLong_FromUnsignedLongLong(sample->cyc_cnt));
}
- if (al->thread) {
- machine = maps__machine(thread__maps(al->thread));
- e_machine = thread__e_machine(al->thread, machine, &e_flags);
- }
+ if (al->thread)
+ e_machine = thread__e_machine(al->thread, /*machine=*/NULL, &e_flags);
+
if (set_regs_in_dict(dict, sample, evsel, e_machine, e_flags))
Py_FatalError("Failed to setting regs in dict");
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 53f51c3f9603..4b465abfa36c 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -2972,9 +2972,8 @@ struct perf_session__e_machine_cb_args {
static int perf_session__e_machine_cb(struct thread *thread, void *_args)
{
struct perf_session__e_machine_cb_args *args = _args;
- struct machine *machine = maps__machine(thread__maps(thread));
- args->e_machine = thread__e_machine(thread, machine, &args->e_flags);
+ args->e_machine = thread__e_machine(thread, /*machine=*/NULL, &args->e_flags);
return args->e_machine != EM_NONE ? 1 : 0;
}
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 618f29afb160..22be77225bb0 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -499,6 +499,11 @@ uint16_t thread__e_machine(struct thread *thread, struct machine *machine, uint3
return e_machine;
}
+ if (machine == NULL) {
+ struct maps *maps = thread__maps(thread);
+
+ machine = maps__machine(maps);
+ }
tid = thread__tid(thread);
pid = thread__pid(thread);
if (pid != tid) {
--
2.53.0.rc1.225.gd81095ad13-goog
Powered by blists - more mailing lists