All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun Sharma <asharma@fb.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Benjamin Redelings <benjamin.redelings@nescent.org>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@elte.hu>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Robert Richter <robert.richter@amd.com>,
	Stephane Eranian <eranian@google.com>,
	Tom Zanussi <tzanussi@gmail.com>,
	Ulrich Drepper <drepper@gmail.com>
Subject: perf backtraces off-by-1
Date: Fri, 24 Aug 2012 15:13:51 -0700	[thread overview]
Message-ID: <5037FC9F.3090603@fb.com> (raw)

Some of our language runtimes like to map IP addresses in perf backtrace 
to specific byte codes. The way things stand now, the addresses on the 
backtrace are return addresses, rather than the caller. I think this 
issue may be present for other unusual call/return sequences where the 
user may be more interested in the calling instruction rather than the 
instruction control flow would return to.

A simple hack such as the one below makes our JIT guys happy. But the
code is not right if there was an asynchronous transfer of control (eg:
signal handler or interrupt).

libunwind contains similar code, but has the additional info in the 
unwind information to recognize async control transfer.

Wondering if this has been discussed before. One option is to support 
this for user mode only, with code to detect signal frames. Any other ideas?

        -Arun

--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -296,6 +296,7 @@ int machine__resolve_callchain(struct machine *self, 
struct perf_evsel *evsel,
	u8 cpumode = PERF_RECORD_MISC_USER;
	unsigned int i;
	int err;
+	int async;

	callchain_cursor_reset(&evsel->hists.callchain_cursor);

@@ -322,6 +323,11 @@ int machine__resolve_callchain(struct machine 
*self, struct perf_evsel *evsel,
			continue;
		}

+		/* XXX: check if this was an async control transfer */
+		async = 0;
+                if (!async) {
+			ip--;
+		}
		al.filtered = false;
		thread__find_addr_location(thread, self, cpumode,
					   MAP__FUNCTION, ip, &al, NULL);



             reply	other threads:[~2012-08-24 22:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-24 22:13 Arun Sharma [this message]
2012-08-26 16:10 ` perf backtraces off-by-1 Peter Zijlstra
2012-08-26 17:52   ` Arun Sharma
2012-08-28 16:34     ` Peter Zijlstra
2012-08-28 17:33       ` Arun Sharma

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=5037FC9F.3090603@fb.com \
    --to=asharma@fb.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=benjamin.redelings@nescent.org \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=drepper@gmail.com \
    --cc=eranian@google.com \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=gorcunov@openvz.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=robert.richter@amd.com \
    --cc=tzanussi@gmail.com \
    /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.