* [PATCH V2] tools/perf/builtin-lock: Fix return code for functions in __cmd_contention
@ 2025-01-10 9:37 Athira Rajeev
2025-01-13 22:17 ` Namhyung Kim
2025-01-18 17:59 ` Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: Athira Rajeev @ 2025-01-10 9:37 UTC (permalink / raw)
To: acme, jolsa, adrian.hunter, irogers, namhyung
Cc: linux-perf-users, linuxppc-dev, maddy, atrajeev, kjain, disgoel,
hbathini
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>
---
Changelog:
v1 -> v2
Fixed return code in functions: setup_output_field()
and select_key() as pointed out by Namhyung.
tools/perf/builtin-lock.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 208c482daa56..94a2bc15a2fa 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -2049,7 +2049,8 @@ static int __cmd_contention(int argc, const char **argv)
goto out_delete;
}
- if (lock_contention_prepare(&con) < 0) {
+ err = lock_contention_prepare(&con);
+ if (err < 0) {
pr_err("lock contention BPF setup failed\n");
goto out_delete;
}
@@ -2070,10 +2071,14 @@ static int __cmd_contention(int argc, const char **argv)
}
}
- if (setup_output_field(true, output_fields))
+ err = setup_output_field(true, output_fields);
+ if (err) {
+ pr_err("Failed to setup output field\n");
goto out_delete;
+ }
- if (select_key(true))
+ err = select_key(true);
+ if (err)
goto out_delete;
if (symbol_conf.field_sep) {
--
2.43.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH V2] tools/perf/builtin-lock: Fix return code for functions in __cmd_contention
2025-01-10 9:37 [PATCH V2] tools/perf/builtin-lock: Fix return code for functions in __cmd_contention Athira Rajeev
@ 2025-01-13 22:17 ` Namhyung Kim
2025-01-15 13:03 ` Athira Rajeev
2025-01-18 17:59 ` Namhyung Kim
1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2025-01-13 22:17 UTC (permalink / raw)
To: Athira Rajeev
Cc: acme, jolsa, adrian.hunter, irogers, linux-perf-users,
linuxppc-dev, maddy, kjain, disgoel, hbathini
On Fri, Jan 10, 2025 at 03:07:30PM +0530, Athira Rajeev wrote:
> 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>
Thanks,
Namhyung
> ---
> Changelog:
> v1 -> v2
> Fixed return code in functions: setup_output_field()
> and select_key() as pointed out by Namhyung.
>
> tools/perf/builtin-lock.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
> index 208c482daa56..94a2bc15a2fa 100644
> --- a/tools/perf/builtin-lock.c
> +++ b/tools/perf/builtin-lock.c
> @@ -2049,7 +2049,8 @@ static int __cmd_contention(int argc, const char **argv)
> goto out_delete;
> }
>
> - if (lock_contention_prepare(&con) < 0) {
> + err = lock_contention_prepare(&con);
> + if (err < 0) {
> pr_err("lock contention BPF setup failed\n");
> goto out_delete;
> }
> @@ -2070,10 +2071,14 @@ static int __cmd_contention(int argc, const char **argv)
> }
> }
>
> - if (setup_output_field(true, output_fields))
> + err = setup_output_field(true, output_fields);
> + if (err) {
> + pr_err("Failed to setup output field\n");
> goto out_delete;
> + }
>
> - if (select_key(true))
> + err = select_key(true);
> + if (err)
> goto out_delete;
>
> if (symbol_conf.field_sep) {
> --
> 2.43.5
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH V2] tools/perf/builtin-lock: Fix return code for functions in __cmd_contention
2025-01-13 22:17 ` Namhyung Kim
@ 2025-01-15 13:03 ` Athira Rajeev
0 siblings, 0 replies; 4+ messages in thread
From: Athira Rajeev @ 2025-01-15 13:03 UTC (permalink / raw)
To: Namhyung Kim
Cc: acme, jolsa, adrian.hunter, irogers, linux-perf-users,
linuxppc-dev, maddy, kjain, disgoel, hbathini
> On 14 Jan 2025, at 3:47 AM, Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Fri, Jan 10, 2025 at 03:07:30PM +0530, Athira Rajeev wrote:
>> 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>
>
> Thanks,
> Namhyung
Hi Namhyung,
Thanks for the reviewed-by
Athira
>
>> ---
>> Changelog:
>> v1 -> v2
>> Fixed return code in functions: setup_output_field()
>> and select_key() as pointed out by Namhyung.
>>
>> tools/perf/builtin-lock.c | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
>> index 208c482daa56..94a2bc15a2fa 100644
>> --- a/tools/perf/builtin-lock.c
>> +++ b/tools/perf/builtin-lock.c
>> @@ -2049,7 +2049,8 @@ static int __cmd_contention(int argc, const char **argv)
>> goto out_delete;
>> }
>>
>> - if (lock_contention_prepare(&con) < 0) {
>> + err = lock_contention_prepare(&con);
>> + if (err < 0) {
>> pr_err("lock contention BPF setup failed\n");
>> goto out_delete;
>> }
>> @@ -2070,10 +2071,14 @@ static int __cmd_contention(int argc, const char **argv)
>> }
>> }
>>
>> - if (setup_output_field(true, output_fields))
>> + err = setup_output_field(true, output_fields);
>> + if (err) {
>> + pr_err("Failed to setup output field\n");
>> goto out_delete;
>> + }
>>
>> - if (select_key(true))
>> + err = select_key(true);
>> + if (err)
>> goto out_delete;
>>
>> if (symbol_conf.field_sep) {
>> --
>> 2.43.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] tools/perf/builtin-lock: Fix return code for functions in __cmd_contention
2025-01-10 9:37 [PATCH V2] tools/perf/builtin-lock: Fix return code for functions in __cmd_contention Athira Rajeev
2025-01-13 22:17 ` Namhyung Kim
@ 2025-01-18 17:59 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2025-01-18 17:59 UTC (permalink / raw)
To: acme, jolsa, adrian.hunter, irogers, Athira Rajeev
Cc: linux-perf-users, linuxppc-dev, maddy, kjain, disgoel, hbathini
On Fri, 10 Jan 2025 15:07:30 +0530, Athira Rajeev wrote:
> 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
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-18 17:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10 9:37 [PATCH V2] tools/perf/builtin-lock: Fix return code for functions in __cmd_contention Athira Rajeev
2025-01-13 22:17 ` Namhyung Kim
2025-01-15 13:03 ` Athira Rajeev
2025-01-18 17:59 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).