lkml.org 
[lkml]   [2018]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 25/49] perf tools: Save timestamp of a map creation
    Date
    From: Namhyung Kim <namhyung@kernel.org>

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

    Cc: Stephane Eranian <eranian@google.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Link: http://lkml.kernel.org/n/tip-p39jo653jdpz7uyzz7ih5xk9@git.kernel.org
    Signed-off-by: Namhyung Kim <namhyung@kernel.org>
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    ---
    tools/perf/util/dso.c | 2 +-
    tools/perf/util/machine.c | 25 +++++++++++++++----------
    tools/perf/util/machine.h | 2 +-
    tools/perf/util/map.c | 12 +++++++-----
    tools/perf/util/map.h | 9 ++++++---
    tools/perf/util/symbol-elf.c | 2 +-
    tools/perf/util/symbol.c | 4 ++--
    7 files changed, 33 insertions(+), 23 deletions(-)

    diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
    index d5b6f7f5baff..41b7def15931 100644
    --- a/tools/perf/util/dso.c
    +++ b/tools/perf/util/dso.c
    @@ -1014,7 +1014,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 26f4fc719601..b1eb0b6672df 100644
    --- a/tools/perf/util/machine.c
    +++ b/tools/perf/util/machine.c
    @@ -807,7 +807,7 @@ static void dso__adjust_kmod_long_name(struct dso *dso, const char *filename)
    }

    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 = NULL;
    @@ -832,7 +832,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;

    @@ -1018,7 +1018,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;

    @@ -1333,7 +1333,7 @@ static int machine__create_module(void *arg, const char *name, u64 start,
    if (arch__fix_module_text_start(&start, name) < 0)
    return -1;

    - map = machine__findnew_module_map(machine, start, name);
    + map = machine__findnew_module_map(machine, start, name, 0);
    if (map == NULL)
    return -1;
    map->end = start + size;
    @@ -1440,7 +1440,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];
    @@ -1463,7 +1464,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;

    @@ -1563,7 +1565,8 @@ int machine__process_mmap2_event(struct machine *machine,

    if (sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
    sample->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;
    @@ -1586,7 +1589,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;
    @@ -1621,7 +1625,8 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event

    if (sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
    sample->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;
    @@ -1641,7 +1646,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
    event->mmap.len, event->mmap.pgoff,
    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 8eca8af88d02..42291b8c397f 100644
    --- a/tools/perf/util/machine.h
    +++ b/tools/perf/util/machine.h
    @@ -229,7 +229,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 arch__fix_module_text_start(u64 *start, const char *name);

    int __machine__load_kallsyms(struct machine *machine, const char *filename,
    diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
    index dbd8c2c3d712..991592718025 100644
    --- a/tools/perf/util/map.c
    +++ b/tools/perf/util/map.c
    @@ -130,7 +130,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;
    @@ -144,12 +144,13 @@ void map__init(struct map *map, enum map_type type,
    map->groups = NULL;
    map->erange_warned = false;
    refcount_set(&map->refcnt, 1);
    + map->timestamp = timestamp;
    }

    struct map *map__new(struct machine *machine, u64 start, u64 len,
    u64 pgoff, 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));
    struct nsinfo *nsi = NULL;
    @@ -203,7 +204,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;
    @@ -231,7 +232,8 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
    * 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)));
    @@ -239,7 +241,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 38d5954771e8..8162d084f50e 100644
    --- a/tools/perf/util/map.h
    +++ b/tools/perf/util/map.h
    @@ -45,6 +45,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 @@ struct thread;
    __map__for_each_symbol_by_name(map, sym_name, (pos))

    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 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/symbol-elf.c b/tools/perf/util/symbol-elf.c
    index 2de770511e70..6f283616d5fa 100644
    --- a/tools/perf/util/symbol-elf.c
    +++ b/tools/perf/util/symbol-elf.c
    @@ -1056,7 +1056,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
    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);
    dso__put(curr_dso);
    if (curr_map == NULL) {
    goto out_elf_end;
    diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
    index cc065d4bfafc..9ba402636ffe 100644
    --- a/tools/perf/util/symbol.c
    +++ b/tools/perf/util/symbol.c
    @@ -843,7 +843,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;
    @@ -1147,7 +1147,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.13.6
    \
     
     \ /
      Last update: 2018-01-14 23:19    [W:4.211 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site