From: Andi Kleen <andi@firstfloor.org>
To: acme@infradead.org
Cc: jolsa@redhat.com, namhyung@kernel.org, mingo@kernel.org,
dsahern@gmail.com, fweisbec@gmail.com, adrian.hunter@intel.com,
linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 7/9] perf, tools: Add overlap detection for report branch-call-stack mode
Date: Sat, 11 Jan 2014 11:42:57 -0800 [thread overview]
Message-ID: <1389469379-13340-8-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1389469379-13340-1-git-send-email-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
Add a simple heuristic to detect overlap of LBR entries and the call
stack when in lbr-as-callgraph mode. The return address in the
normal callstack is one off compared to the from entry in the
branch stack. Handle this with a simple "assume call instruction
is not longer than 8 bytes" heuristic. With that we can remove
any redundant call in the callstack that is already in the branch
stack.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
tools/perf/util/machine.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 853639c..1f167fe 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1349,6 +1349,7 @@ static int machine__resolve_callchain_sample(struct machine *machine,
int chain_nr = min(max_stack, (int)chain->nr);
int i;
int err;
+ int first_call = 0;
callchain_cursor_reset(&callchain_cursor);
@@ -1362,8 +1363,6 @@ static int machine__resolve_callchain_sample(struct machine *machine,
* Limitations for now:
* - No extra filters
* - No annotations (should annotate somehow)
- * - When the sample is near the beginning of the function
- * we may overlap with the real callstack.
*/
if (branch->nr > PERF_MAX_BRANCH_DEPTH) {
@@ -1372,13 +1371,23 @@ static int machine__resolve_callchain_sample(struct machine *machine,
}
if (callchain_param.branch_callstack) {
- int nr = min(max_stack, branch->nr);
+ int nr = min(max_stack, (int)branch->nr);
struct branch_entry be[nr];
for (i = 0; i < nr; i++) {
- if (callchain_param.order == ORDER_CALLEE)
+ if (callchain_param.order == ORDER_CALLEE) {
be[i] = branch->entries[i];
- else
+ /*
+ * Check for overlap into the callchain.
+ * The return address is one off compared to
+ * the branch entry. To adjust for this
+ * assume the calling instruction is not longer
+ * than 8 bytes.
+ */
+ if (be[i].from < chain->ips[first_call] &&
+ be[i].from >= chain->ips[first_call] - 8)
+ first_call++;
+ } else
be[i] = branch->entries[branch->nr - i - 1];
}
@@ -1405,7 +1414,7 @@ static int machine__resolve_callchain_sample(struct machine *machine,
return 0;
}
- for (i = 0; i < chain_nr; i++) {
+ for (i = first_call; i < chain_nr; i++) {
u64 ip;
if (callchain_param.order == ORDER_CALLEE)
--
1.8.3.1
next prev parent reply other threads:[~2014-01-11 19:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-11 19:42 perf: Implement lbr-as-callgraph v2 Andi Kleen
2014-01-11 19:42 ` [PATCH 1/9] perf, tools: fix BFD detection on opensuse Andi Kleen
2014-01-12 15:16 ` Jiri Olsa
2014-01-13 9:03 ` Namhyung Kim
2014-01-12 15:40 ` David Ahern
2014-03-02 8:57 ` [tip:perf/urgent] perf " tip-bot for Andi Kleen
2014-01-11 19:42 ` [PATCH 2/9] perf, tools: Support handling complete branch stacks as histograms Andi Kleen
2014-01-11 19:42 ` [PATCH 3/9] perf, tools: Add --branch-history option to report v2 Andi Kleen
2014-01-11 19:42 ` [PATCH 4/9] perf, tools: Filter out small loops from LBR-as-call-stack Andi Kleen
2014-01-11 19:42 ` [PATCH 5/9] perf, tools: Enable printing the srcline in the history Andi Kleen
2014-01-11 19:42 ` [PATCH 6/9] perf, tools: Fix max stack handling with lbr-as-callgraph Andi Kleen
2014-01-11 19:42 ` Andi Kleen [this message]
2014-01-11 19:42 ` [PATCH 8/9] perf, tools: Only print base source file for srcline Andi Kleen
2014-01-11 19:42 ` [PATCH 9/9] perf, tools: Support source line numbers in annotate Andi Kleen
2014-01-12 15:16 ` perf: Implement lbr-as-callgraph v2 Jiri Olsa
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=1389469379-13340-8-git-send-email-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=acme@infradead.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®