[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <EECE94D2-B654-4F92-A558-22174F84D780@linux.vnet.ibm.com>
Date: Tue, 14 Jan 2025 13:26:29 +0530
From: Athira Rajeev <atrajeev@...ux.vnet.ibm.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>, jolsa@...nel.org,
adrian.hunter@...el.com, irogers@...gle.com, hbathini@...ux.ibm.com,
linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, maddy@...ux.ibm.com,
kjain@...ux.ibm.com, disgoel@...ux.vnet.ibm.com
Subject: Re: [PATCH] tools/perf: Fix segfault during perf record --off-cpu
when debuginfo is not enabled
> On 13 Jan 2025, at 8:59 PM, Arnaldo Carvalho de Melo <acme@...nel.org> wrote:
>
> On Mon, Jan 06, 2025 at 01:25:32PM -0800, Namhyung Kim wrote:
>> On Fri, Dec 27, 2024 at 04:18:32PM +0530, Athira Rajeev wrote:
>>>
>>>
>>>> On 23 Dec 2024, at 7:28 PM, Athira Rajeev <atrajeev@...ux.vnet.ibm.com> wrote:
>>>>
>>>> When kernel is built without debuginfo, running perf record with
>>>> --off-cpu results in segfault as below:
>>>>
>>>> ./perf record --off-cpu -e dummy sleep 1
>>>> 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
>>>> Segmentation fault (core dumped)
>>>>
>>>> The backtrace pointed to:
>>>>
>>>> #0 0x00000000100fb17c in btf.type_cnt ()
>>>> #1 0x00000000100fc1a8 in btf_find_by_name_kind ()
>>>> #2 0x00000000100fc38c in btf.find_by_name_kind ()
>>>> #3 0x00000000102ee3ac in off_cpu_prepare ()
>>>> #4 0x000000001002f78c in cmd_record ()
>>>> #5 0x00000000100aee78 in run_builtin ()
>>>> #6 0x00000000100af3e4 in handle_internal_command ()
>>>> #7 0x000000001001004c in main ()
>>>>
>>>> Code sequence is:
>>>> static void check_sched_switch_args(void)
>>>> {
>>>> struct btf *btf = btf__load_vmlinux_btf();
>>>> const struct btf_type *t1, *t2, *t3;
>>>> u32 type_id;
>>>>
>>>> type_id = btf__find_by_name_kind(btf, "btf_trace_sched_switch",
>>>> BTF_KIND_TYPEDEF);
>>>>
>>>> btf__load_vmlinux_btf fails when CONFIG_DEBUG_INFO_BTF is not enabled.
>>>> Here bpf__find_by_name_kind calls btf__type_cnt with NULL btf
>>>> value and results in segfault. To fix this, add a check to see if
>>>> btf is not NULL before invoking bpf__find_by_name_kind
>>>>
>>>> Signed-off-by: Athira Rajeev <atrajeev@...ux.vnet.ibm.com>
>>
>> Reviewed-by: Namhyung Kim <namhyung@...nel.org>
>
> Thanks, applied to perf-tools-next,
>
> - Arnaldo
Thanks Namhyung and Arnaldo
Athira.
Powered by blists - more mailing lists