Skip to content

Commit 25b5ee3

Browse files
namhyunggregkh
authored andcommitted
perf lock contention: Load kernel map before lookup
[ Upstream commit 553d18c ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 76a3392 commit 25b5ee3

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
@@ -26,6 +26,9 @@ int lock_contention_prepare(struct lock_contention *con)
2626
struct evlist *evlist = con->evlist;
2727
struct target *target = con->target;
2828

29+
/* make sure it loads the kernel map before lookup */
30+
map__load(machine__kernel_map(con->machine));
31+
2932
skel = lock_contention_bpf__open();
3033
if (!skel) {
3134
pr_err("Failed to open lock-contention BPF skeleton\n");
@@ -443,9 +446,6 @@ int lock_contention_read(struct lock_contention *con)
443446
bpf_prog_test_run_opts(prog_fd, &opts);
444447
}
445448

446-
/* make sure it loads the kernel map */
447-
maps__load_first(machine->kmaps);
448-
449449
prev_key = NULL;
450450
while (!bpf_map_get_next_key(fd, prev_key, &key)) {
451451
s64 ls_key;

0 commit comments

Comments
 (0)