From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5510D2500B1; Tue, 14 Jan 2025 07:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736841430; cv=none; b=W8f8cU3ysC2eGT8FzBRDiuLMzFufVGH6MbyvMXrpZBwiF/3HKbWANHWFgUK8gcCNYU/8AjBWkEoNuPcDbFHpAILHRpMZevc/Kcgto2C2ijBoK+r0LESuzO72dBTissHJmlVFzSNmQhvQOOZI4DbOc8wQo0/0iSIji/Wxb2mocds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736841430; c=relaxed/simple; bh=OBNT1MMlMdp12vl61/ye4d5rqUcErrqttwCm5Mg59nM=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=OeC91Rkb6cBlFxgbfpNRicOKCKqoKm4Im1uIxaR4XFFS0AhF94034Y362uNV+L6Kvo3xbMHA+Wjt6rhjMNroz5hm3LyvXcJz9fchqrYf78i5eTWAlJaK7R+gCOuWi9jgyiD3e4na3Y6s+Z8OfDSWXLLr+c4EiuvWF4YzYtkLD/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com; spf=none smtp.mailfrom=linux.vnet.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=dwu96IDG; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.vnet.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="dwu96IDG" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50DHWENE000480; Tue, 14 Jan 2025 07:56:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=IdZZfV +w80aRSeDXrWFGAZdtyXJTjObyzk/Ryg7JS64=; b=dwu96IDGUpvRmR/NxpAkaU T2OVXv26iXpQKFIOs+TaTZjGN8TLXqEytPGdBVDSxFGCYZEpTgAMavxmLvFAfsYY rSm/lFlUImiZjzCPRhxDhXvS8LK0MASkEuKstrF80OLITCelIFC4XSgaoHZrkJPf 4BPEXboYPFzUcSwuVYiHfcgYgbcO+CefSj8TzBvomMZYhS3bEDyJzTRDXooQTU5v mptn+oeZhfLL+lb5872bB/Tj+9FXILyz9JGJpewMnc+Oq6x20ro5yRj9ZsQjep6y dSJUPaM1gxHvKlrjq4VhCW4xXcTf2egIIje7tdfG9RwxPVkb/76NO5ucahRmrNxw == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 444y12nak6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 07:56:53 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 50E7sSZ0028908; Tue, 14 Jan 2025 07:56:52 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 444y12nak5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 07:56:52 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50E3ZjJb004526; Tue, 14 Jan 2025 07:56:52 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4442ysje1c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2025 07:56:52 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50E7umvi32899710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Jan 2025 07:56:48 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9F17220043; Tue, 14 Jan 2025 07:56:48 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6802620040; Tue, 14 Jan 2025 07:56:43 +0000 (GMT) Received: from smtpclient.apple (unknown [9.61.251.19]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Tue, 14 Jan 2025 07:56:42 +0000 (GMT) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3818.100.11.1.3\)) Subject: Re: [PATCH] tools/perf: Fix segfault during perf record --off-cpu when debuginfo is not enabled From: Athira Rajeev In-Reply-To: Date: Tue, 14 Jan 2025 13:26:29 +0530 Cc: Namhyung Kim , jolsa@kernel.org, adrian.hunter@intel.com, irogers@google.com, hbathini@linux.ibm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, maddy@linux.ibm.com, kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com Content-Transfer-Encoding: quoted-printable Message-Id: References: <20241223135813.8175-1-atrajeev@linux.vnet.ibm.com> <409D0233-93FF-40D6-BC2E-B7625E4E1B97@linux.vnet.ibm.com> To: Arnaldo Carvalho de Melo , Namhyung Kim X-Mailer: Apple Mail (2.3818.100.11.1.3) X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: seKjSW0JUsw_Upqsyf51QaQ1EIhOT9PS X-Proofpoint-GUID: Gq0byDLv0pXDBQaSUz0S2WliTHuq-5LI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 clxscore=1015 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501140061 > On 13 Jan 2025, at 8:59=E2=80=AFPM, Arnaldo Carvalho de Melo = wrote: >=20 > 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: >>>=20 >>>=20 >>>> On 23 Dec 2024, at 7:28=E2=80=AFPM, Athira Rajeev = wrote: >>>>=20 >>>> When kernel is built without debuginfo, running perf record with >>>> --off-cpu results in segfault as below: >>>>=20 >>>> ./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) >>>>=20 >>>> The backtrace pointed to: >>>>=20 >>>> #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 () >>>>=20 >>>> Code sequence is: >>>> static void check_sched_switch_args(void) >>>> { >>>> struct btf *btf =3D btf__load_vmlinux_btf(); >>>> const struct btf_type *t1, *t2, *t3; >>>> u32 type_id; >>>>=20 >>>> type_id =3D btf__find_by_name_kind(btf, = "btf_trace_sched_switch", >>>> BTF_KIND_TYPEDEF); >>>>=20 >>>> 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 >>>>=20 >>>> Signed-off-by: Athira Rajeev >>=20 >> Reviewed-by: Namhyung Kim >=20 > Thanks, applied to perf-tools-next, >=20 > - Arnaldo Thanks Namhyung and Arnaldo=20 Athira.