From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: [PATCH v2 3/5] perf tools: Remove NULL check for maps__machine()
Date: Sun, 18 Oct 2026 22:52:05 -0700 [thread overview]
Message-ID: <20261019055207.39325-4-namhyung@kernel.org> (raw)
In-Reply-To: <20261019055207.39325-1-namhyung@kernel.org>
Now maps should have a machine, let's get rid of checks for the return
value. There are already many places to assume it returns non-NULL,
so having this kind of check could give confusion that it can return
NULL (which is not true anymore).
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/dlfilter.c | 3 +--
tools/perf/util/event.c | 3 ---
tools/perf/util/map.c | 9 +++------
tools/perf/util/python.c | 2 +-
4 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c
index e11e144af62bb979..7e179d1d84d78358 100644
--- a/tools/perf/util/dlfilter.c
+++ b/tools/perf/util/dlfilter.c
@@ -233,8 +233,7 @@ static const __u8 *dlfilter__insn(void *ctx, __u32 *len)
if (thread__maps(al->thread)) {
struct machine *machine = maps__machine(thread__maps(al->thread));
- if (machine)
- perf_sample__fetch_insn(d->sample, al->thread, machine);
+ perf_sample__fetch_insn(d->sample, al->thread, machine);
}
}
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index ea75816d126a14be..2f80e364659fea71 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -706,9 +706,6 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
al->cpumode = cpumode;
al->filtered = 0;
- if (machine == NULL)
- return NULL;
-
if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
al->level = 'k';
maps = machine__kernel_maps(machine);
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 41cdddc987eee710..d5319ffa88a7477c 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -538,13 +538,10 @@ u64 map__rip_2objdump(const struct map *map, u64 rip)
*/
if (kmap && is_entry_trampoline(kmap->name) && kmap->kmaps) {
struct machine *machine = maps__machine(kmap->kmaps);
+ struct map *kernel_map = machine__kernel_map(machine);
- if (machine) {
- struct map *kernel_map = machine__kernel_map(machine);
-
- if (kernel_map)
- map = kernel_map;
- }
+ if (kernel_map)
+ map = kernel_map;
}
if (!dso__adjust_symbols(dso))
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 60dbe2dad5eb8073..42c587cd54a527a4 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -4536,7 +4536,7 @@ static PyObject *pyrf_call_return__new(struct call_return *cr)
if (cr->thread) {
struct maps *maps = thread__maps(cr->thread);
- pevent->machine_pid = maps && maps__machine(maps) ? maps__machine(maps)->pid : 0;
+ pevent->machine_pid = maps ? maps__machine(maps)->pid : 0;
pevent->pid = thread__pid(cr->thread);
pevent->tid = thread__tid(cr->thread);
} else {
--
2.56.0
next prev parent reply other threads:[~2026-10-19 5:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 5:52 [PATCH v2 0/5] perf tools: Random fixes for the symbol code Namhyung Kim
2026-10-19 5:52 ` [PATCH v2 1/5] perf test: Fix a memory leak in PE file parsing test Namhyung Kim
2026-10-19 5:52 ` [PATCH v2 2/5] perf test: Make sure maps to have a machine Namhyung Kim
2026-10-19 5:52 ` Namhyung Kim [this message]
2026-10-19 5:52 ` [PATCH v2 4/5] perf symbol: Check result when reading section headers Namhyung Kim
2026-10-19 5:52 ` [PATCH v2 5/5] perf symbol: Ensure dso__set_is_64_bit() for libbfd Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261019055207.39325-4-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®