Skip to content

Commit 83196dd

Browse files
athira-rajeevnamhyung
authored andcommitted
perf lock: Fix return code for functions in __cmd_contention
perf lock contention returns zero exit value even if the lock contention BPF setup failed. # ./perf lock con -b true libbpf: kernel BTF is missing at '/sys/kernel/btf/vmlinux', was CONFIG_DEBUG_INFO_BTF enabled? libbpf: failed to find '.BTF' ELF section in /lib/modules/6.13.0-rc3+/build/vmlinux libbpf: failed to find valid kernel BTF libbpf: kernel BTF is missing at '/sys/kernel/btf/vmlinux', was CONFIG_DEBUG_INFO_BTF enabled? libbpf: failed to find '.BTF' ELF section in /lib/modules/6.13.0-rc3+/build/vmlinux libbpf: failed to find valid kernel BTF libbpf: Error loading vmlinux BTF: -ESRCH libbpf: failed to load object 'lock_contention_bpf' libbpf: failed to load BPF skeleton 'lock_contention_bpf': -ESRCH Failed to load lock-contention BPF skeleton lock contention BPF setup failed # echo $? 0 Fix this by saving the return code for lock_contention_prepare so that command exits with proper return code. Similarly set the return code properly for two other functions in builtin-lock, namely setup_output_field() and select_key(). Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20250110093730.93610-1-atrajeev@linux.vnet.ibm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 036e2fa commit 83196dd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tools/perf/builtin-lock.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,8 @@ static int __cmd_contention(int argc, const char **argv)
20492049
goto out_delete;
20502050
}
20512051

2052-
if (lock_contention_prepare(&con) < 0) {
2052+
err = lock_contention_prepare(&con);
2053+
if (err < 0) {
20532054
pr_err("lock contention BPF setup failed\n");
20542055
goto out_delete;
20552056
}
@@ -2070,10 +2071,14 @@ static int __cmd_contention(int argc, const char **argv)
20702071
}
20712072
}
20722073

2073-
if (setup_output_field(true, output_fields))
2074+
err = setup_output_field(true, output_fields);
2075+
if (err) {
2076+
pr_err("Failed to setup output field\n");
20742077
goto out_delete;
2078+
}
20752079

2076-
if (select_key(true))
2080+
err = select_key(true);
2081+
if (err)
20772082
goto out_delete;
20782083

20792084
if (symbol_conf.field_sep) {

0 commit comments

Comments
 (0)