From: Anton Blanchard <anton@samba.org>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
emunson@mgebm.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] perf: Fix symbol resolution on old ppc64 ABI
Date: Mon, 25 Jul 2011 14:23:56 +1000 [thread overview]
Message-ID: <20110725142356.0c722c6b@kryten> (raw)
The synthetic symbol creation code has an issue with the old ppc64
ABI. We end up with duplicate symbols of different sizes that overlap.
To fix this, walk all of the symbols and remove any duplicates that
are the length of a function descriptor.
Before:
5.46% ppc64_cpu [kernel.kallsyms] [k] 0xc0000000003a2ddc
|
--- 0xc0000000003a2dc0
|
|--99.99%-- 0xc0000000003a2dd4
| |
| |--99.40%-- .cpu_node_mask
After:
5.51% ppc64_cpu [kernel.kallsyms] [k] .__bitmap_weight
|
--- .__bitmap_weight
|
|--99.41%-- .__bitmap_weight
| |
| |--89.55%-- .cpu_node_mask
Signed-off-by: Anton Blanchard <anton@samba.org>
---
I'd prefer not to add a ppc64 specific hack here, but I'm not sure
how we can fix this in a simpler way.
Index: linux-2.6-tip/tools/perf/util/symbol.c
===================================================================
--- linux-2.6-tip.orig/tools/perf/util/symbol.c 2011-07-24 15:06:14.423324103 +1000
+++ linux-2.6-tip/tools/perf/util/symbol.c 2011-07-24 15:21:42.149736397 +1000
@@ -107,6 +107,58 @@ static void symbols__fixup_end(struct rb
curr->end = roundup(curr->start, 4096);
}
+/*
+ * There are two 64bit PowerPC ABIs. The old version creates symbols at the
+ * first instruction of each function by adding a '.' to the start of a symbol
+ * name. A function descriptor called foo has a a symbol called .foo at the
+ * address of the first instruction.
+ *
+ * The new version doesn't create these '.' symbols and instead requires us
+ * to synthesize symbols by parsing the function descriptor section (which
+ * provides a mapping of function name to instruction address, amongst other
+ * things).
+ *
+ * If we created synthetic symbols for an old style object then we end up
+ * with duplicate symbols. The '.' symbol that covers the entire function,
+ * and a fake synthetic symbol that is the length of a function descriptor.
+ *
+ * To fix this, we walk all of the symbols and remove any duplicates that
+ * are the length of a function descriptor.
+ */
+
+/* A ppc64 function descriptor contains 3 64bit values */
+#define PPC64_FUNCTION_DESCRIPTOR_LEN (3 * sizeof(u64))
+
+static void symbols__fixup_ppc64(struct rb_root *symbols)
+{
+ struct rb_node *nd;
+ struct symbol *curr, *next;
+
+ nd = rb_first(symbols);
+
+ while (nd) {
+ curr = rb_entry(nd, struct symbol, rb_node);
+again:
+ nd = rb_next(&curr->rb_node);
+ next = rb_entry(nd, struct symbol, rb_node);
+
+ if (!nd)
+ break;
+
+ if (curr->start == next->start) {
+ if ((curr->end - curr->start + 1) ==
+ PPC64_FUNCTION_DESCRIPTOR_LEN) {
+ nd = rb_next(&curr->rb_node);
+ rb_erase(&curr->rb_node, symbols);
+ } else if ((next->end - next->start + 1) ==
+ PPC64_FUNCTION_DESCRIPTOR_LEN) {
+ rb_erase(&next->rb_node, symbols);
+ goto again;
+ }
+ }
+ }
+}
+
static void __map_groups__fixup_end(struct map_groups *mg, enum map_type type)
{
struct map *prev, *curr;
@@ -1278,6 +1330,9 @@ new_symbol:
* For misannotated, zeroed, ASM function sizes.
*/
if (nr > 0) {
+ if (ehdr.e_machine == EM_PPC64)
+ symbols__fixup_ppc64(&dso->symbols[map->type]);
+
symbols__fixup_end(&dso->symbols[map->type]);
if (kmap) {
/*
next reply other threads:[~2011-07-25 4:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-25 4:23 Anton Blanchard [this message]
2011-07-25 6:25 ` [PATCH] perf: Fix symbol resolution on old ppc64 ABI Ingo Molnar
2011-07-25 10:48 ` Anton Blanchard
2011-07-25 10:50 ` Ingo Molnar
2011-07-25 12:32 ` Anton Blanchard
2011-07-25 12:36 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110725142356.0c722c6b@kryten \
--to=anton@samba.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=emunson@mgebm.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.