linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lutomirski <luto@mit.edu>
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>,
	linux-perf-users@vger.kernel.org
Subject: perf vsyscall bugs
Date: Thu, 24 Mar 2011 00:36:56 -0400	[thread overview]
Message-ID: <AANLkTikxSw5+wJZUWNz++nL7mgivCh_Zf=2Kq6=f9Ce_@mail.gmail.com> (raw)

Perf can't currently trace into the vsyscall page.  It looks like it
was meant to work.
Tested on 2.6.38 and today's -git.

The bug is easy to reproduce.  Compile this:

#include <time.h>

int main()
{
	int i;
	struct timespec t;
	for(i = 0; i < 10000000; i++)
		clock_gettime(CLOCK_MONOTONIC, &t);
	return 0;
}

and run it through perf record; perf report.  The top entry shows
"[unknown]" and you can't zoom in.

It looks like there are two issues.  The first is a that a test for
user mode executing in kernel space
is backwards.  (That's the first hunk below).  The second (I think) is
that something's wrong with the
code that generates lots of little struct dso objects for different
sections -- when it runs on vmlinux
it results in bogus long_name values which cause objdump to fail.  I
don't really understand the
point of that code, so my fix is just a gross kludge.

The patch below applies to 2.6.38 and makes it work.  If only the VDSO
were so easy...

Signed-off-by: Andy Lutomirski <luto@mit.edu>

---

The first hunk is probably safe.  The other part is an eyesore and
probably breaks things that
I haven't tried (like guest mode, maybe).

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 50d0a93..5d6a5a7 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -728,7 +728,7 @@ try_again:
 		 * in the whole kernel symbol list.
 		 */
 		if ((long long)al->addr < 0 &&
-		    cpumode == PERF_RECORD_MISC_KERNEL &&
+		    cpumode == PERF_RECORD_MISC_USER &&
 		    machine && mg != &machine->kmaps) {
 			mg = &machine->kmaps;
 			goto try_again;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index b1bf490..f521c03 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1197,6 +1197,8 @@ static int dso__load_sym(struct dso *self,
struct map *map, const char *name,
 				if (curr_dso == NULL)
 					goto out_elf_end;
 				curr_dso->kernel = self->kernel;
+				curr_dso->long_name = self->long_name;
+				curr_dso->long_name_len = self->long_name_len;
 				curr_map = map__new2(start, curr_dso,
 						     map->type);
 				if (curr_map == NULL) {
@@ -1842,6 +1844,9 @@ int dso__load_vmlinux(struct dso *self, struct map *map,
 	if (fd < 0)
 		return -1;

+	/* Gross hack.  dso__load_sym needs long_name to be set so
+	   it can propagate it to per-section DSOs. */
+	dso__set_long_name(self, (char*)vmlinux);
 	dso__set_loaded(self, map->type);
 	err = dso__load_sym(self, map, symfs_vmlinux, fd, filter, 0, 0);
 	close(fd);

                 reply	other threads:[~2011-03-24  4:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='AANLkTikxSw5+wJZUWNz++nL7mgivCh_Zf=2Kq6=f9Ce_@mail.gmail.com' \
    --to=luto@mit.edu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=linux-perf-users@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).