Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5648451ybf; Thu, 5 Mar 2020 04:36:25 -0800 (PST) X-Google-Smtp-Source: ADFU+vuFcxwOt+3OkyUra/EfzgonlWKiSmqi9TEVdTQ+KNEaMT/YCrOMweXzRK6JzUBPak/GRdq/ X-Received: by 2002:a05:6808:188:: with SMTP id w8mr5316470oic.106.1583411785162; Thu, 05 Mar 2020 04:36:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583411785; cv=none; d=google.com; s=arc-20160816; b=GuliQnh8mNIYc4XQ/3Gom5UZ40xp3yfLQHDO0N6jHBIix326oUaHOkW6wNKqvNgKyy 5nK3Q3jkWy6a1GBMZgZhiFKxYyPuoUQ8J6m1wrxrgzB0oWUdDtLS8TiH2B0edv3hPypT EkzT+akjBg1PSWQLMlQmgy195WLx548E2OqLrRKFzUURhRuazY55LCkiZv5fmRzl9AW1 ObeoeXil70P6vdRxOX/0sHdP//38w3o69x/eDKjDo1ZwRTItadpYqm+Ata3ZAgMniuwW UiSHJy1I7c5ahXn26IPT5jvC802ttGcs2+72qe6E0h+QI3a0GLwzTl+60AtnNHuzKo3D n8gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :user-agent:mime-version:in-reply-to:references:cc:to:subject:from :date; bh=YPk43Bve9LZKuB1Ain7Lh2oslktaHCDOGBfh6xyB+8U=; b=x6N+218wQTFPAiB+W4IKcAqTH3zcwY/mC00c0mZVrONtl/h2Y4qm8uf7mvZXGkFry2 3WvQu7SOsIvvYz+YlyBYfK0QNOGsFinG7V4dlg4o8lDbcVBVrriCJ0oj8A6by6gkkwLa icNo1vhTi2gSxBqJa06RxUe6LW2fA0HJOMJIpEX/rB//sWXp+n8fgUlQ5hBm1s3kOeBK z+zkuS36fxKVYn9QPOegsO1P1cBR4GcYD9H+pyfOukbXSKANOxyN+/CDEKN4THmBUrX6 rIJHlabFWwDmT9lbBx7t+GHy/Khr1sejBSv2yxxX6b+ftFEisiFqOOQsHMRzzoRDspay Z4VA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y25si3233885oih.73.2020.03.05.04.36.12; Thu, 05 Mar 2020 04:36:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbgCEMfg convert rfc822-to-8bit (ORCPT + 99 others); Thu, 5 Mar 2020 07:35:36 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:47510 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726007AbgCEMfg (ORCPT ); Thu, 5 Mar 2020 07:35:36 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 025CKRKo066940 for ; Thu, 5 Mar 2020 07:35:35 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yfmg3mtcb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 05 Mar 2020 07:35:35 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Mar 2020 12:35:32 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 5 Mar 2020 12:35:27 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 025CZRKc57409556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Mar 2020 12:35:27 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0075911C058; Thu, 5 Mar 2020 12:35:27 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 936F111C04C; Thu, 5 Mar 2020 12:35:26 +0000 (GMT) Received: from localhost (unknown [9.199.53.44]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Mar 2020 12:35:26 +0000 (GMT) Date: Thu, 05 Mar 2020 18:05:25 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH v2] perf symbols: Consolidate symbol fixup issue To: Leo Yan Cc: Arnaldo Carvalho de Melo , Alexander Shishkin , Allison Randal , Hendrik Brueckner , Greg Kroah-Hartman , Enrico Weigelt , John Garry , Jiri Olsa , Kate Stewart , linux-kernel@vger.kernel.org, Mark Rutland , Mathieu Poirier , Mike Leach , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Thomas Gleixner , Thomas Richter References: <20200303110407.28162-1-leo.yan@linaro.org> <1583405831.eapbxpc3ni.naveen@linux.ibm.com> <20200305120738.GA31049@leoy-ThinkPad-X240s> In-Reply-To: <20200305120738.GA31049@leoy-ThinkPad-X240s> MIME-Version: 1.0 User-Agent: astroid/v0.15-13-gb675b421 (https://github.com/astroidmail/astroid) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 20030512-4275-0000-0000-000003A8A0E4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20030512-4276-0000-0000-000038BDB0B6 Message-Id: <1583411597.adgw1518ss.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-05_03:2020-03-05,2020-03-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 malwarescore=0 adultscore=0 suspectscore=0 priorityscore=1501 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003050080 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Leo Yan wrote: > Hi Naveen, > > On Thu, Mar 05, 2020 at 04:32:30PM +0530, Naveen N. Rao wrote: >> Leo Yan wrote: >> > In the common elf__needs_adjust_symbols(), it checks elf header and >> > if >> > the machine type is one of Arm64/ppc/ppc64, it checks extra condition >> > for 'ET_DYN'. Finally, the Arm64 DSO can be parsed properly with x86's >> > perf tool. >> > >> > Before: >> > >> > # perf script >> > main 3258 1 branches: 0 [unknown] ([unknown]) => ffff800010c4665c [unknown] ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c46670 [unknown] ([kernel.kallsyms]) => ffff800010c4eaec [unknown] ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c4eaec [unknown] ([kernel.kallsyms]) => ffff800010c4eb00 [unknown] ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c4eb08 [unknown] ([kernel.kallsyms]) => ffff800010c4e780 [unknown] ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c4e7a0 [unknown] ([kernel.kallsyms]) => ffff800010c4eeac [unknown] ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c4eebc [unknown] ([kernel.kallsyms]) => ffff800010c4ed80 [unknown] ([kernel.kallsyms]) >> > >> > After: >> > >> > # perf script >> > main 3258 1 branches: 0 [unknown] ([unknown]) => ffff800010c4665c coresight_timeout+0x54 ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c46670 coresight_timeout+0x68 ([kernel.kallsyms]) => ffff800010c4eaec etm4_enable_hw+0x3cc ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c4eaec etm4_enable_hw+0x3cc ([kernel.kallsyms]) => ffff800010c4eb00 etm4_enable_hw+0x3e0 ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c4eb08 etm4_enable_hw+0x3e8 ([kernel.kallsyms]) => ffff800010c4e780 etm4_enable_hw+0x60 ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c4e7a0 etm4_enable_hw+0x80 ([kernel.kallsyms]) => ffff800010c4eeac etm4_enable+0x2d4 ([kernel.kallsyms]) >> > main 3258 1 branches: ffff800010c4eebc etm4_enable+0x2e4 ([kernel.kallsyms]) => ffff800010c4ed80 etm4_enable+0x1a8 ([kernel.kallsyms]) >> > >> >> I am not able to reproduce this since powerpc64 kernels are not being built >> as ET_EXEC anymore. > > Thanks for reviewing! > > Based on the context, I think you mean powerpc64 kernels are not being > built as ET_DYN anymore (and now change to ET_EXEC). D'uh, indeed, sorry! > >> > v2: Fixed Arm64 and powerpc native building. >> > >> > Reported-by: Mike Leach >> > Signed-off-by: Leo Yan >> > --- >> > tools/perf/arch/arm64/util/Build | 1 - >> > tools/perf/arch/arm64/util/sym-handling.c | 19 ------------------- >> > tools/perf/arch/powerpc/util/Build | 1 - >> > tools/perf/arch/powerpc/util/sym-handling.c | 10 ---------- >> > tools/perf/util/symbol-elf.c | 8 +++++++- >> > 5 files changed, 7 insertions(+), 32 deletions(-) >> > delete mode 100644 tools/perf/arch/arm64/util/sym-handling.c >> > >> > diff --git a/tools/perf/util/symbol-elf.c >> > b/tools/perf/util/symbol-elf.c >> > index 1965aefccb02..ee788ac67415 100644 >> > --- a/tools/perf/util/symbol-elf.c >> > +++ b/tools/perf/util/symbol-elf.c >> > @@ -704,8 +704,14 @@ void symsrc__destroy(struct symsrc *ss) >> > close(ss->fd); >> > } >> > >> > -bool __weak elf__needs_adjust_symbols(GElf_Ehdr ehdr) >> > +bool elf__needs_adjust_symbols(GElf_Ehdr ehdr) >> > { >> > + if (ehdr.e_machine == EM_AARCH64 || >> > + ehdr.e_machine == EM_PPC || >> > + ehdr.e_machine == EM_PPC64) >> > + return ehdr.e_type == ET_EXEC || ehdr.e_type == ET_REL || >> > + ehdr.e_type == ET_DYN; >> > + >> > return ehdr.e_type == ET_EXEC || ehdr.e_type == ET_REL; >> >> Patch looks good to me. However: > > Can I add your review tag? Yes: Reviewed-by: Naveen N. Rao > >> This is only used for checking kernel, so I wonder if we can simply include >> check for ET_DYN across all architectures? This would only matter if there >> are architectures building their kernel as ET_DYN that _don't_ want to >> adjust symbols. > > Seems only Arm64 enables the link option '-share' for LDFLAGS_vmlinux; > I confirmed with below command: > > $ find arch -name 'Makefile' -exec grep -n '\-share' {} + | grep vmlinux > arch/arm64/Makefile:21:LDFLAGS_vmlinux += -shared -Bsymbolic -z notext -z norelro \ > > Also reviewed the output for searching '\-share' for all Makefiles under > 'arch' folder, many architectures use it for vdso but only Arm64 enables > '-share' for vmlinux linkage. If so, your suggestion is valid and we > can simply include check for ET_DYN for all archs (and it's better to > add comment for this). > > I'd like to wait a bit for anyone has other ideas, and if no objection > will send out new patch for this. Sure, thanks for checking. - Naveen