2009-06-05 13:22:49

by Peter Zijlstra

[permalink] [raw]
Subject: [tip:perfcounters/core] perf report: Deal with maps

Commit-ID: fc54db5105d01ad691a7d747064c7890e17f936c
Gitweb: http://git.kernel.org/tip/fc54db5105d01ad691a7d747064c7890e17f936c
Author: Peter Zijlstra <[email protected]>
AuthorDate: Fri, 5 Jun 2009 14:04:59 +0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 5 Jun 2009 14:46:41 +0200

perf report: Deal with maps

In order to deal with [vdso] maps generalize the ip->symbol path
a bit and allow to override some bits with custom functions.

Signed-off-by: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <[email protected]>


---
Documentation/perf_counter/builtin-report.c | 37 +++++++++++++++++++++++++-
Documentation/perf_counter/util/symbol.c | 1 +
Documentation/perf_counter/util/symbol.h | 1 +
3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
index eb5424f..9783d1e 100644
--- a/Documentation/perf_counter/builtin-report.c
+++ b/Documentation/perf_counter/builtin-report.c
@@ -79,6 +79,7 @@ typedef union event_union {

static LIST_HEAD(dsos);
static struct dso *kernel_dso;
+static struct dso *vdso;

static void dsos__add(struct dso *dso)
{
@@ -136,6 +137,11 @@ static void dsos__fprintf(FILE *fp)
dso__fprintf(pos, fp);
}

+static struct symbol *vdso__find_symbol(struct dso *dso, uint64_t ip)
+{
+ return dso__find_symbol(kernel_dso, ip);
+}
+
static int load_kernel(void)
{
int err;
@@ -151,6 +157,14 @@ static int load_kernel(void)
} else
dsos__add(kernel_dso);

+ vdso = dso__new("[vdso]", 0);
+ if (!vdso)
+ return -1;
+
+ vdso->find_symbol = vdso__find_symbol;
+
+ dsos__add(vdso);
+
return err;
}

@@ -173,9 +187,20 @@ struct map {
uint64_t start;
uint64_t end;
uint64_t pgoff;
+ uint64_t (*map_ip)(struct map *, uint64_t);
struct dso *dso;
};

+static uint64_t map__map_ip(struct map *map, uint64_t ip)
+{
+ return ip - map->start + map->pgoff;
+}
+
+static uint64_t vdso__map_ip(struct map *map, uint64_t ip)
+{
+ return ip;
+}
+
static struct map *map__new(struct mmap_event *event)
{
struct map *self = malloc(sizeof(*self));
@@ -201,6 +226,11 @@ static struct map *map__new(struct mmap_event *event)
self->dso = dsos__findnew(filename);
if (self->dso == NULL)
goto out_delete;
+
+ if (self->dso == vdso)
+ self->map_ip = vdso__map_ip;
+ else
+ self->map_ip = map__map_ip;
}
return self;
out_delete:
@@ -917,8 +947,8 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)

map = thread__find_map(thread, ip);
if (map != NULL) {
+ ip = map->map_ip(map, ip);
dso = map->dso;
- ip -= map->start + map->pgoff;
} else {
/*
* If this is outside of all known maps,
@@ -938,7 +968,10 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
}

if (show & show_mask) {
- struct symbol *sym = dso__find_symbol(dso, ip);
+ struct symbol *sym = NULL;
+
+ if (dso)
+ sym = dso->find_symbol(dso, ip);

if (hist_entry__add(thread, map, dso, sym, ip, level)) {
fprintf(stderr,
diff --git a/Documentation/perf_counter/util/symbol.c b/Documentation/perf_counter/util/symbol.c
index 15d5cf9..a06bbfb 100644
--- a/Documentation/perf_counter/util/symbol.c
+++ b/Documentation/perf_counter/util/symbol.c
@@ -45,6 +45,7 @@ struct dso *dso__new(const char *name, unsigned int sym_priv_size)
strcpy(self->name, name);
self->syms = RB_ROOT;
self->sym_priv_size = sym_priv_size;
+ self->find_symbol = dso__find_symbol;
}

return self;
diff --git a/Documentation/perf_counter/util/symbol.h b/Documentation/perf_counter/util/symbol.h
index 8dd8522..e23cc31 100644
--- a/Documentation/perf_counter/util/symbol.h
+++ b/Documentation/perf_counter/util/symbol.h
@@ -16,6 +16,7 @@ struct dso {
struct list_head node;
struct rb_root syms;
unsigned int sym_priv_size;
+ struct symbol *(*find_symbol)(struct dso *, uint64_t ip);
char name[0];
};


2009-06-05 13:58:29

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [tip:perfcounters/core] perf report: Deal with maps

Em Fri, Jun 05, 2009 at 01:21:54PM +0000, tip-bot for Peter Zijlstra escreveu:
> Commit-ID: fc54db5105d01ad691a7d747064c7890e17f936c
> Gitweb: http://git.kernel.org/tip/fc54db5105d01ad691a7d747064c7890e17f936c
> Author: Peter Zijlstra <[email protected]>
> AuthorDate: Fri, 5 Jun 2009 14:04:59 +0200
> Committer: Ingo Molnar <[email protected]>
> CommitDate: Fri, 5 Jun 2009 14:46:41 +0200
>
> perf report: Deal with maps
>
> In order to deal with [vdso] maps generalize the ip->symbol path
> a bit and allow to override some bits with custom functions.
>
> Signed-off-by: Peter Zijlstra <[email protected]>
> Cc: Mike Galbraith <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Cc: Arnaldo Carvalho de Melo <[email protected]>
> LKML-Reference: <new-submission>
> Signed-off-by: Ingo Molnar <[email protected]>
>
>
> ---
> Documentation/perf_counter/builtin-report.c | 37 +++++++++++++++++++++++++-
> Documentation/perf_counter/util/symbol.c | 1 +
> Documentation/perf_counter/util/symbol.h | 1 +
> 3 files changed, 37 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
> index eb5424f..9783d1e 100644
> --- a/Documentation/perf_counter/builtin-report.c
> +++ b/Documentation/perf_counter/builtin-report.c
> @@ -79,6 +79,7 @@ typedef union event_union {
>
> static LIST_HEAD(dsos);
> static struct dso *kernel_dso;
> +static struct dso *vdso;
>
> static void dsos__add(struct dso *dso)
> {
> @@ -136,6 +137,11 @@ static void dsos__fprintf(FILE *fp)
> dso__fprintf(pos, fp);
> }
>
> +static struct symbol *vdso__find_symbol(struct dso *dso, uint64_t ip)
> +{
> + return dso__find_symbol(kernel_dso, ip);
> +}

Cut'n'paste error? s/kernel_dso/vdso/g

- Arnaldo

2009-06-05 14:07:19

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [tip:perfcounters/core] perf report: Deal with maps

On Fri, 2009-06-05 at 10:57 -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Jun 05, 2009 at 01:21:54PM +0000, tip-bot for Peter Zijlstra escreveu:
> > Commit-ID: fc54db5105d01ad691a7d747064c7890e17f936c
> > Gitweb: http://git.kernel.org/tip/fc54db5105d01ad691a7d747064c7890e17f936c
> > Author: Peter Zijlstra <[email protected]>
> > AuthorDate: Fri, 5 Jun 2009 14:04:59 +0200
> > Committer: Ingo Molnar <[email protected]>
> > CommitDate: Fri, 5 Jun 2009 14:46:41 +0200
> >
> > perf report: Deal with maps
> >
> > In order to deal with [vdso] maps generalize the ip->symbol path
> > a bit and allow to override some bits with custom functions.
> >
> > Signed-off-by: Peter Zijlstra <[email protected]>
> > Cc: Mike Galbraith <[email protected]>
> > Cc: Paul Mackerras <[email protected]>
> > Cc: Arnaldo Carvalho de Melo <[email protected]>
> > LKML-Reference: <new-submission>
> > Signed-off-by: Ingo Molnar <[email protected]>
> >
> >
> > ---
> > Documentation/perf_counter/builtin-report.c | 37 +++++++++++++++++++++++++-
> > Documentation/perf_counter/util/symbol.c | 1 +
> > Documentation/perf_counter/util/symbol.h | 1 +
> > 3 files changed, 37 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
> > index eb5424f..9783d1e 100644
> > --- a/Documentation/perf_counter/builtin-report.c
> > +++ b/Documentation/perf_counter/builtin-report.c
> > @@ -79,6 +79,7 @@ typedef union event_union {
> >
> > static LIST_HEAD(dsos);
> > static struct dso *kernel_dso;
> > +static struct dso *vdso;
> >
> > static void dsos__add(struct dso *dso)
> > {
> > @@ -136,6 +137,11 @@ static void dsos__fprintf(FILE *fp)
> > dso__fprintf(pos, fp);
> > }
> >
> > +static struct symbol *vdso__find_symbol(struct dso *dso, uint64_t ip)
> > +{
> > + return dso__find_symbol(kernel_dso, ip);
> > +}
>
> Cut'n'paste error? s/kernel_dso/vdso/g

Ah, no, intentional cheating ;-)

the kernel dso includes the vdso symbols

2009-06-05 15:02:38

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [tip:perfcounters/core] perf report: Deal with maps

Em Fri, Jun 05, 2009 at 04:06:24PM +0200, Peter Zijlstra escreveu:
> On Fri, 2009-06-05 at 10:57 -0300, Arnaldo Carvalho de Melo wrote:
> > Em Fri, Jun 05, 2009 at 01:21:54PM +0000, tip-bot for Peter Zijlstra escreveu:
> > > Commit-ID: fc54db5105d01ad691a7d747064c7890e17f936c
> > > Gitweb: http://git.kernel.org/tip/fc54db5105d01ad691a7d747064c7890e17f936c
> > > Author: Peter Zijlstra <[email protected]>
> > > AuthorDate: Fri, 5 Jun 2009 14:04:59 +0200
> > > Committer: Ingo Molnar <[email protected]>
> > > CommitDate: Fri, 5 Jun 2009 14:46:41 +0200
> > >
> > > perf report: Deal with maps
> > >
> > > In order to deal with [vdso] maps generalize the ip->symbol path
> > > a bit and allow to override some bits with custom functions.
> > >
> > > Signed-off-by: Peter Zijlstra <[email protected]>
> > > Cc: Mike Galbraith <[email protected]>
> > > Cc: Paul Mackerras <[email protected]>
> > > Cc: Arnaldo Carvalho de Melo <[email protected]>
> > > LKML-Reference: <new-submission>
> > > Signed-off-by: Ingo Molnar <[email protected]>
> > >
> > >
> > > ---
> > > Documentation/perf_counter/builtin-report.c | 37 +++++++++++++++++++++++++-
> > > Documentation/perf_counter/util/symbol.c | 1 +
> > > Documentation/perf_counter/util/symbol.h | 1 +
> > > 3 files changed, 37 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
> > > index eb5424f..9783d1e 100644
> > > --- a/Documentation/perf_counter/builtin-report.c
> > > +++ b/Documentation/perf_counter/builtin-report.c
> > > @@ -79,6 +79,7 @@ typedef union event_union {
> > >
> > > static LIST_HEAD(dsos);
> > > static struct dso *kernel_dso;
> > > +static struct dso *vdso;
> > >
> > > static void dsos__add(struct dso *dso)
> > > {
> > > @@ -136,6 +137,11 @@ static void dsos__fprintf(FILE *fp)
> > > dso__fprintf(pos, fp);
> > > }
> > >
> > > +static struct symbol *vdso__find_symbol(struct dso *dso, uint64_t ip)
> > > +{
> > > + return dso__find_symbol(kernel_dso, ip);
> > > +}
> >
> > Cut'n'paste error? s/kernel_dso/vdso/g
>
> Ah, no, intentional cheating ;-)
>
> the kernel dso includes the vdso symbols

OK, a comment would be nice then, will add it if you don't do it first :)

- Arnaldo