[PATCH 2/4] perf tools: pass timestamp to map_init

Stephane Eranian
2015-02-10T23:43:17Z

This patch passes the sample timestamp down to the
map_init function. This is used to sort mmap records.

Signed-off-by: Stephane Eranian <eranian@google.com>
---
tools/perf/util/machine.c | 8 ++++++--
tools/perf/util/map.c | 9 +++++----
tools/perf/util/map.h | 5 +++--
3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 1bca3a9..3288a71 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1176,7 +1176,9 @@ int machine__process_mmap2_event(struct machine *machine,
event->mmap2.ino_generation,
event->mmap2.prot,
event->mmap2.flags,
- event->mmap2.filename, type, thread);
+ event->mmap2.filename, type,
+ thread,
+ sample->time);

if (map == NULL)
goto out_problem;
@@ -1223,7 +1225,9 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
event->mmap.len, event->mmap.pgoff,
event->mmap.pid, 0, 0, 0, 0, 0, 0,
event->mmap.filename,
- type, thread);
+ type,
+ thread,
+ sample->time);

if (map == NULL)
goto out_problem;
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 62ca9f2..fac9d34 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -123,7 +123,7 @@ static inline bool replace_android_lib(const char *filename, char *newfilename)
}

void map__init(struct map *map, enum map_type type,
- u64 start, u64 end, u64 pgoff, struct dso *dso)
+ u64 start, u64 end, u64 pgoff, struct dso *dso, u64 ts)
{
map->type = type;
map->start = start;
@@ -137,12 +137,13 @@ void map__init(struct map *map, enum map_type type,
map->groups = NULL;
map->referenced = false;
map->erange_warned = false;
+ map->time = ts;
}

struct map *map__new(struct machine *machine, u64 start, u64 len,
u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
u64 ino_gen, u32 prot, u32 flags, char *filename,
- enum map_type type, struct thread *thread)
+ enum map_type type, struct thread *thread, u64 ts)
{
struct map *map = malloc(sizeof(*map));

@@ -182,7 +183,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
if (dso == NULL)
goto out_delete;

- map__init(map, type, start, start + len, pgoff, dso);
+ map__init(map, type, start, start + len, pgoff, dso, ts);

if (anon || no_dso) {
map->map_ip = map->unmap_ip = identity__map_ip;
@@ -215,7 +216,7 @@ struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
/*
* ->end will be filled after we load all the symbols
*/
- map__init(map, type, start, 0, 0, dso);
+ map__init(map, type, start, 0, 0, dso, 0);
}

return map;
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 0e42438..9320bf8 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -42,6 +42,7 @@ struct map {
u32 maj, min; /* only valid for MMAP2 record */
u64 ino; /* only valid for MMAP2 record */
u64 ino_generation;/* only valid for MMAP2 record */
+ u64 time;

/* ip -> dso rip */
u64 (*map_ip)(struct map *, u64);
@@ -135,11 +136,11 @@ struct thread;
typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);

void map__init(struct map *map, enum map_type type,
- u64 start, u64 end, u64 pgoff, struct dso *dso);
+ u64 start, u64 end, u64 pgoff, struct dso *dso, u64 ts);
struct map *map__new(struct machine *machine, u64 start, u64 len,
u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
u64 ino_gen, u32 prot, u32 flags,
- char *filename, enum map_type type, struct thread *thread);
+ char *filename, enum map_type type, struct thread *thread, u64 time);
struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
void map__delete(struct map *map);
struct map *map__clone(struct map *map);
--
1.9.1