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: Victor Kamensky X-Patchwork-Id: 5636751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 713C0C058D for ; Thu, 15 Jan 2015 02:53:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD3DF2013A for ; Thu, 15 Jan 2015 02:53:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6BC320107 for ; Thu, 15 Jan 2015 02:53:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YBaWz-0005K4-Nv; Thu, 15 Jan 2015 02:51:33 +0000 Received: from mail-qc0-f173.google.com ([209.85.216.173]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YBaWu-0005Iu-Ta for linux-arm-kernel@lists.infradead.org; Thu, 15 Jan 2015 02:51:30 +0000 Received: by mail-qc0-f173.google.com with SMTP id i17so10436205qcy.4 for ; Wed, 14 Jan 2015 18:51:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=RFdb8Kpvqe6i6uHUR6geizwSoK22SHXsnhVMt3Ib+WQ=; b=Vc2v3jWB/UuLszGhZNEmgNOuJ2iLCBZrB/kkviR+VcesRVN34vuN1S6Cbvq1cL9SPj QJ7JReRAkRZGtdVHVC+PmIlvELtgP0Ex64hvTRJTqJnNoEmotvhLFKC2fUr7PQtGmexA a7IGBoo1FK98NyZ5AkbWaPSSxIMmSokbP4IHfA+e6ws4a5/k/FX9W+Eus9GaiG8hwblq W2RnwEOv6i4Mdc/Lj+o7zax+YgBYYuI0JHMau15N+Z7GH1f5G8E7KYGVOy5gV/BmD14x 8rOqPRXS6iTGosfQjrgqAPBilzgK9UARy2u1LYOqfUHL1xIMbD5HkKELBpQkSIFbdrYM XTNw== X-Gm-Message-State: ALoCoQlzR+dJL8edJQ88MrltoiS8H3suRoWNLKS9B4Z/2+D31nrn7GtjyMftwrqaCSGby9UwLVHD 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150114_185129_111183_518C217B X-CRM114-Status: GOOD ( 22.67 ) X-Spam-Score: -0.7 (/) Cc: Avi Kivity , Peter Zijlstra , Will Deacon , "linux-kernel@vger.kernel.org" , Arnaldo Carvalho de Melo , Adrian Hunter , Ingo Molnar , Paul Mackerras , Anton Blanchard , David Ahern , Masami Hiramatsu , Namhyung Kim , Jiri Olsa , Dave P Martin , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Will Deacon --- 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; }