]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf thread: Don't require machine to compute the e_machine
authorIan Rogers <irogers@google.com>
Tue, 3 Feb 2026 18:26:40 +0000 (10:26 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 3 Feb 2026 21:01:27 +0000 (18:01 -0300)
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@google.com>
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com>
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: Anubhav Shelat <ashelat@redhat.com>
Cc: Anup Patel <anup@brainfault.org>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Blake Jones <blakejones@google.com>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
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: Shimin Guo <shimin.guo@skydio.com>
Cc: Swapnil Sapkal <swapnil.sapkal@amd.com>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yunseong Kim <ysk@kzalloc.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/scripting-engines/trace-event-python.c
tools/perf/util/session.c
tools/perf/util/thread.c

index 62c9c73daef5e8a84634e3eb279867c28d1ec3a1..2b0df7bd9a468f291b8a518eaa95f3ec41d461dc 100644 (file)
@@ -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");
 
index 53f51c3f96034d1a2a768927f684e8450f20d5eb..4b465abfa36c8e4486696a027ceb9bf62a898313 100644 (file)
@@ -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;
 }
 
index 618f29afb160c35d465dfdc1700b1add6ead46e0..22be77225bb0cc74cf05fa82bcb7abc118065047 100644 (file)
@@ -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) {