Skip to content

Commit 553d18c

Browse files
committed
perf lock contention: Load kernel map before lookup
On some machines, it caused troubles when it tried to find kernel symbols. I think it's because kernel modules and kallsyms are messed up during load and split. Basically we want to make sure the kernel map is loaded and the code has it in the lock_contention_read(). But recently we added more lookups in the lock_contention_prepare() which is called before _read(). Also the kernel map (kallsyms) may not be the first one in the group like on ARM. Let's use machine__kernel_map() rather than just loading the first map. Reviewed-by: Ian Rogers <irogers@google.com> Fixes: 688d2e8 ("perf lock contention: Add -l/--lock-addr option") Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 3528647 commit 553d18c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/perf/util/bpf_lock_contention.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ int lock_contention_prepare(struct lock_contention *con)
184184
struct evlist *evlist = con->evlist;
185185
struct target *target = con->target;
186186

187+
/* make sure it loads the kernel map before lookup */
188+
map__load(machine__kernel_map(con->machine));
189+
187190
skel = lock_contention_bpf__open();
188191
if (!skel) {
189192
pr_err("Failed to open lock-contention BPF skeleton\n");
@@ -749,9 +752,6 @@ int lock_contention_read(struct lock_contention *con)
749752
bpf_prog_test_run_opts(prog_fd, &opts);
750753
}
751754

752-
/* make sure it loads the kernel map */
753-
maps__load_first(machine->kmaps);
754-
755755
prev_key = NULL;
756756
while (!bpf_map_get_next_key(fd, prev_key, &key)) {
757757
s64 ls_key;

0 commit comments

Comments
 (0)