From patchwork Thu Jan 15 02:51:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 43142 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 21F5E240B9 for ; Thu, 15 Jan 2015 02:52:10 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf6581217lab.3 for ; Wed, 14 Jan 2015 18:52:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=sorRxoffyEoxk+Wf7LkycUlI/CqUjn+P+M7K1wWOoVA=; b=H/ZZBaLBTe5fHKTVV2J4bKelzZ0y6T9Pp1ECq5b4mEJ6bFafrGzYeOtFeCFNDgao8Z 4zhADk3ZOmroOiOFgJdQJXPmma416DHKo5rwUJuoIpZsdbe4LGguxDbVN1Ypx3k8orfe +a2mMHWfBI8Q87vkgwPk9nxJoOAfmA++fArVrFvzACKwzulKIAZ3vWwAuhqJ4PNF3bJp J0cGbrrvB02jHzDeCHXgcFlDsUbffZ1ZWovnsDsi8WeS49a8qlv2DCanPqp5ZhByaOjB azYWDO9+83uLC0zBTdJbTIUd0OO/Rc7EZmuOd6ksh4VZTKLFWlFLmYyhMCglSzkDBMRU 8yPw== X-Gm-Message-State: ALoCoQnVSg6O7dKUDsmKZT0HyC80xbs1TXaVtEEZkzDtFf6fjMy1ZAV5eIBYN4yrriG2Bz9OpeMK X-Received: by 10.152.181.138 with SMTP id dw10mr130205lac.1.1421290328999; Wed, 14 Jan 2015 18:52:08 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.104 with SMTP id x8ls197866laj.4.gmail; Wed, 14 Jan 2015 18:52:08 -0800 (PST) X-Received: by 10.112.51.44 with SMTP id h12mr7370232lbo.5.1421290328750; Wed, 14 Jan 2015 18:52:08 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id je4si185730lbc.47.2015.01.14.18.52.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Jan 2015 18:52:08 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id 10so11147709lbg.5 for ; Wed, 14 Jan 2015 18:52:08 -0800 (PST) X-Received: by 10.112.26.135 with SMTP id l7mr7157527lbg.56.1421290328535; Wed, 14 Jan 2015 18:52:08 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1891021lbb; Wed, 14 Jan 2015 18:52:07 -0800 (PST) X-Received: by 10.68.134.74 with SMTP id pi10mr10756965pbb.4.1421290326274; Wed, 14 Jan 2015 18:52:06 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id aw3si231383pbc.87.2015.01.14.18.52.05; Wed, 14 Jan 2015 18:52:06 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752264AbbAOCvJ (ORCPT + 28 others); Wed, 14 Jan 2015 21:51:09 -0500 Received: from mail-qc0-f179.google.com ([209.85.216.179]:47113 "EHLO mail-qc0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750893AbbAOCvH (ORCPT ); Wed, 14 Jan 2015 21:51:07 -0500 Received: by mail-qc0-f179.google.com with SMTP id c9so10379207qcz.10 for ; Wed, 14 Jan 2015 18:51:06 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.34.137 with SMTP id l9mr12699465qad.57.1421290266546; Wed, 14 Jan 2015 18:51:06 -0800 (PST) Received: by 10.229.245.202 with HTTP; Wed, 14 Jan 2015 18:51:06 -0800 (PST) In-Reply-To: <20150115000305.GC12302@n2100.arm.linux.org.uk> References: <1421168344-5363-1-git-send-email-victor.kamensky@linaro.org> <20150114112210.GF4050@arm.com> <20150115000305.GC12302@n2100.arm.linux.org.uk> Date: Wed, 14 Jan 2015 18:51:06 -0800 Message-ID: Subject: Re: [PATCH 1/2] perf symbols: Ignore mapping symbols on aarch64 From: Victor Kamensky To: Russell King - ARM Linux Cc: Will Deacon , Avi Kivity , Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , "linux-kernel@vger.kernel.org" , Ingo Molnar , Paul Mackerras , Anton Blanchard , David Ahern , Masami Hiramatsu , Namhyung Kim , Jiri Olsa , Dave P Martin , "linux-arm-kernel@lists.infradead.org" Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 14 January 2015 at 16:03, Russell King - ARM Linux wrote: > On Wed, Jan 14, 2015 at 10:38:38AM -0800, Victor Kamensky wrote: >> >From fed6caab410ddcaf487ff23a3908eca129e50b89 Mon Sep 17 00:00:00 2001 >> From: Victor Kamensky >> Date: Wed, 14 Jan 2015 07:42:41 -0800 >> Subject: [PATCH 3/3] perf symbols: improve abi compliance in arm mapping >> symbols handling >> >> Both Arm and Aarch64 ELF ABI allow mapping symbols be in from >> either "$d" or "$d.". But current code that handles mapping >> symbols only deals with the first, dollar character and a single >> letter, case. >> >> The patch adds handling of the second case with period >> followed by any characters. >> >> Suggested-by: Will Deacon >> Signed-off-by: Victor Kamensky > > I wonder if it would make more sense to re-use the "is_arm_mapping_symbol" > thing which we have in kernel/module.c and scripts/kallsyms.c - it > seems silly to re-invent code which we already have to detect these > symbols. Thanks for pointing this out. I did not know about "is_arm_mapping_symbol" function. Do you suggest we copy one of those functions into tools/perf? Since tools/perf is separate user-land utility I don't see easy way how can we reuse those directly. Also those functions check for mapping symbols seems to be more efficient that one I come with, for example one from scripts/kallsyms.c static inline int is_arm_mapping_symbol(const char *str) { return str[0] == '$' && strchr("axtd", str[1]) && (str[2] == '\0' || str[2] == '.'); } But it seems that they are somewhat accurate: because they bundle EM_ARM and EM_AARCH64 into one case. According to ABIs for EM_ARM we have $a, $t, $d, $a., $t., $d.; and for EM_AARCH64 we have $x, $d, $x., $d.. How about the following two variants of the patch. It follows the same mapping handling logic as in other 3 copies of is_arm_mapping_symbol function in kernel, but it still separate copy in tools/perf code. Personally I prefer variant 1, but I am fine with variant 2 too, because practically it will be OK. Variant 1 (as addition to this patch, as above): >From e08d348bd72d406d8939993d266729d805577c4b Mon Sep 17 00:00:00 2001 From: Victor Kamensky Date: Wed, 14 Jan 2015 07:42:41 -0800 Subject: [PATCH 3/3] perf symbols: improve abi compliance in arm mapping symbols handling Both Arm and Aarch64 ELF ABI allow mapping symbols be in from either "$d" or "$d.". But current code that handles mapping symbols only deals with the first, dollar character and a single letter, case. The patch adds handling of the second case with period followed by any characters. Suggested-by: Russell King Suggested-by: Will Deacon Signed-off-by: Victor Kamensky --- tools/perf/util/symbol-elf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 1e188dd..a038c98 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -857,17 +857,16 @@ int dso__load_sym(struct dso *dso, struct map *map, * don't identify functions, so will confuse the profile * output: */ if (ehdr.e_machine == EM_ARM) { - if (!strcmp(elf_name, "$a") || - !strcmp(elf_name, "$d") || - !strcmp(elf_name, "$t")) + if (elf_name[0] == '$' && strchr("adt", elf_name[1]) + && (elf_name[2] == '\0' || elf_name[2] == '.')) continue; } /* Reject Aarch64 ELF "mapping symbols": these aren't unique and * don't identify functions, so will confuse the profile * output: */ if (ehdr.e_machine == EM_AARCH64) { - if (!strcmp(elf_name, "$x") || - !strcmp(elf_name, "$d")) + if (elf_name[0] == '$' && strchr("dx", elf_name[1]) + && (elf_name[2] == '\0' || elf_name[2] == '.')) continue; } -- 1.9.3 Variant 2 instead of patch posted with current subject: From c8d08ebddc61203daf21b17c891c26c1d08e14f1 Mon Sep 17 00:00:00 2001 From: Victor Kamensky Date: Mon, 12 Jan 2015 14:13:36 -0800 Subject: [PATCH 1/2] perf symbols: Ignore mapping symbols on aarch64 Aarch64 ELF files use mapping symbols with special names $x, $d to identify regions of Aarch64 code (see Aarch64 ELF ABI - "ARM IHI 0056B", section "4.5.4 Mapping symbols"). The patch filters out these symbols at load time, similar to "696b97a perf symbols: Ignore mapping symbols on ARM" changes done for ARM before V8. Also added handling of mapping symbols that has format "$d." and similar for both cases. Note we are not making difference between EM_ARM and EM_AARCH64 mapping symbols instead code handles superset of both. Signed-off-by: Victor Kamensky Cc: Peter Zijlstra Cc: Paul Mackerras Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Avi Kivity Cc: Masami Hiramatsu Cc: Anton Blanchard Cc: David Ahern Cc: Will Deacon Cc: Russell King Cc: Dave Martin --- tools/perf/util/symbol-elf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 06fcd1b..b2eb0f9 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -856,10 +856,9 @@ int dso__load_sym(struct dso *dso, struct map *map, /* Reject ARM ELF "mapping symbols": these aren't unique and * don't identify functions, so will confuse the profile * output: */ - if (ehdr.e_machine == EM_ARM) { - if (!strcmp(elf_name, "$a") || - !strcmp(elf_name, "$d") || - !strcmp(elf_name, "$t")) + if (ehdr.e_machine == EM_ARM || ehdr.e_machine == EM_AARCH64) { + if (elf_name[0] == '$' && strchr("adtx", elf_name[1]) + && (elf_name[2] == '\0' || elf_name[2] == '.')) continue; }