It'll be used to support multiple maps on a same address like dlopen()
and/or JIT compile cases.

Cc: Stephane Eranian <eran...@google.com>
Cc: Frederic Weisbecker <fweis...@gmail.com>
Signed-off-by: Namhyung Kim <namhy...@kernel.org>
---
 tools/perf/util/dso.c         |  2 +-
 tools/perf/util/machine.c     | 29 +++++++++++++++++------------
 tools/perf/util/machine.h     |  2 +-
 tools/perf/util/map.c         | 12 +++++++-----
 tools/perf/util/map.h         |  9 ++++++---
 tools/perf/util/probe-event.c |  2 +-
 tools/perf/util/symbol-elf.c  |  2 +-
 tools/perf/util/symbol.c      |  4 ++--
 8 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 7c0c08386a1d..6cf2c0b095cf 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -859,7 +859,7 @@ struct map *dso__new_map(const char *name)
        struct dso *dso = dso__new(name);
 
        if (dso)
-               map = map__new2(0, dso, MAP__FUNCTION);
+               map = map__new2(0, dso, MAP__FUNCTION, 0);
 
        return map;
 }
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 761b04b970ad..57f9aa1800a2 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -709,7 +709,7 @@ int machine__process_switch_event(struct machine *machine 
__maybe_unused,
 }
 
 struct map *machine__findnew_module_map(struct machine *machine, u64 start,
-                                       const char *filename)
+                                       const char *filename, u64 timestamp)
 {
        struct map *map = NULL;
        struct dso *dso;
@@ -727,7 +727,7 @@ struct map *machine__findnew_module_map(struct machine 
*machine, u64 start,
        if (dso == NULL)
                goto out;
 
-       map = map__new2(start, dso, MAP__FUNCTION);
+       map = map__new2(start, dso, MAP__FUNCTION, timestamp);
        if (map == NULL)
                goto out;
 
@@ -892,7 +892,7 @@ int __machine__create_kernel_maps(struct machine *machine, 
struct dso *kernel)
                struct kmap *kmap;
                struct map *map;
 
-               machine->vmlinux_maps[type] = map__new2(start, kernel, type);
+               machine->vmlinux_maps[type] = map__new2(start, kernel, type, 0);
                if (machine->vmlinux_maps[type] == NULL)
                        return -1;
 
@@ -1192,7 +1192,7 @@ static int machine__create_module(void *arg, const char 
*name, u64 start)
        struct machine *machine = arg;
        struct map *map;
 
-       map = machine__findnew_module_map(machine, start, name);
+       map = machine__findnew_module_map(machine, start, name, 0);
        if (map == NULL)
                return -1;
 
@@ -1293,7 +1293,8 @@ static bool machine__uses_kcore(struct machine *machine)
 }
 
 static int machine__process_kernel_mmap_event(struct machine *machine,
-                                             union perf_event *event)
+                                             union perf_event *event,
+                                             u64 timestamp)
 {
        struct map *map;
        char kmmap_prefix[PATH_MAX];
@@ -1316,7 +1317,8 @@ static int machine__process_kernel_mmap_event(struct 
machine *machine,
        if (event->mmap.filename[0] == '/' ||
            (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
                map = machine__findnew_module_map(machine, event->mmap.start,
-                                                 event->mmap.filename);
+                                                 event->mmap.filename,
+                                                 timestamp);
                if (map == NULL)
                        goto out_problem;
 
@@ -1404,7 +1406,7 @@ out_problem:
 
 int machine__process_mmap2_event(struct machine *machine,
                                 union perf_event *event,
-                                struct perf_sample *sample __maybe_unused)
+                                struct perf_sample *sample)
 {
        u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
        struct thread *thread;
@@ -1417,7 +1419,8 @@ int machine__process_mmap2_event(struct machine *machine,
 
        if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
            cpumode == PERF_RECORD_MISC_KERNEL) {
-               ret = machine__process_kernel_mmap_event(machine, event);
+               ret = machine__process_kernel_mmap_event(machine, event,
+                                                        sample->time);
                if (ret < 0)
                        goto out_problem;
                return 0;
@@ -1440,7 +1443,8 @@ 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_map;
@@ -1458,7 +1462,7 @@ out_problem:
 }
 
 int machine__process_mmap_event(struct machine *machine, union perf_event 
*event,
-                               struct perf_sample *sample __maybe_unused)
+                               struct perf_sample *sample)
 {
        u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
        struct thread *thread;
@@ -1471,7 +1475,8 @@ int machine__process_mmap_event(struct machine *machine, 
union perf_event *event
 
        if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
            cpumode == PERF_RECORD_MISC_KERNEL) {
-               ret = machine__process_kernel_mmap_event(machine, event);
+               ret = machine__process_kernel_mmap_event(machine, event,
+                                                        sample->time);
                if (ret < 0)
                        goto out_problem;
                return 0;
@@ -1491,7 +1496,7 @@ 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_map;
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index f0c2cc9c90ae..98ade93f433f 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -205,7 +205,7 @@ struct symbol *machine__find_kernel_function_by_name(struct 
machine *machine,
 }
 
 struct map *machine__findnew_module_map(struct machine *machine, u64 start,
-                                       const char *filename);
+                                       const char *filename, u64 timestamp);
 
 int machine__load_kallsyms(struct machine *machine, const char *filename,
                           enum map_type type, symbol_filter_t filter);
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index addd4b323027..2034127ac3f0 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -125,7 +125,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 timestamp)
 {
        map->type     = type;
        map->start    = start;
@@ -138,13 +138,14 @@ void map__init(struct map *map, enum map_type type,
        RB_CLEAR_NODE(&map->rb_node);
        map->groups   = NULL;
        map->erange_warned = false;
+       map->timestamp = timestamp;
        atomic_set(&map->refcnt, 1);
 }
 
 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 timestamp)
 {
        struct map *map = malloc(sizeof(*map));
 
@@ -184,7 +185,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, timestamp);
 
                if (anon || no_dso) {
                        map->map_ip = map->unmap_ip = identity__map_ip;
@@ -210,7 +211,8 @@ out_delete:
  * they are loaded) and for vmlinux, where only after we load all the
  * symbols we'll know where it starts and ends.
  */
-struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
+struct map *map__new2(u64 start, struct dso *dso, enum map_type type,
+                     u64 timestamp)
 {
        struct map *map = calloc(1, (sizeof(*map) +
                                     (dso->kernel ? sizeof(struct kmap) : 0)));
@@ -218,7 +220,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, timestamp);
        }
 
        return map;
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 1e3313a22d3a..858f700ea5a3 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -43,6 +43,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                     timestamp;
 
        /* ip -> dso rip */
        u64                     (*map_ip)(struct map *, u64);
@@ -143,12 +144,14 @@ typedef int (*symbol_filter_t)(struct map *map, struct 
symbol *sym);
 
 int arch__compare_symbol_names(const char *namea, const char *nameb);
 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 timestamp);
 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);
-struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
+                    char *filename, enum map_type type, struct thread *thread,
+                    u64 timestamp);
+struct map *map__new2(u64 start, struct dso *dso, enum map_type type,
+                     u64 timestamp);
 void map__delete(struct map *map);
 struct map *map__clone(struct map *map);
 
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 3010abc071ff..01ecfbfe999a 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -167,7 +167,7 @@ static struct map *kernel_get_module_map(const char *module)
 
        /* A file path -- this is an offline module */
        if (module && strchr(module, '/'))
-               return machine__findnew_module_map(host_machine, 0, module);
+               return machine__findnew_module_map(host_machine, 0, module, 0);
 
        if (!module)
                module = "kernel";
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 475d88d0a1c9..b4443bacf811 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1025,7 +1025,7 @@ int dso__load_sym(struct dso *dso, struct map *map,
                                curr_dso->long_name = dso->long_name;
                                curr_dso->long_name_len = dso->long_name_len;
                                curr_map = map__new2(start, curr_dso,
-                                                    map->type);
+                                                    map->type, map->timestamp);
                                if (curr_map == NULL) {
                                        dso__put(curr_dso);
                                        goto out_elf_end;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index bcda43bee4d4..ff2a298f1780 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -799,7 +799,7 @@ static int dso__split_kallsyms(struct dso *dso, struct map 
*map, u64 delta,
 
                        ndso->kernel = dso->kernel;
 
-                       curr_map = map__new2(pos->start, ndso, map->type);
+                       curr_map = map__new2(pos->start, ndso, map->type, 0);
                        if (curr_map == NULL) {
                                dso__put(ndso);
                                return -1;
@@ -1101,7 +1101,7 @@ static int kcore_mapfn(u64 start, u64 len, u64 pgoff, 
void *data)
        struct kcore_mapfn_data *md = data;
        struct map *map;
 
-       map = map__new2(start, md->dso, md->type);
+       map = map__new2(start, md->dso, md->type, 0);
        if (map == NULL)
                return -ENOMEM;
 
-- 
2.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to