From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753133AbbERArw (ORCPT ); Sun, 17 May 2015 20:47:52 -0400 Received: from LGEMRELSE6Q.lge.com ([156.147.1.121]:55142 "EHLO lgemrelse6q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752209AbbERAln (ORCPT ); Sun, 17 May 2015 20:41:43 -0400 X-Original-SENDERIP: 10.177.220.203 X-Original-MAILFROM: namhyung@kernel.org From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Adrian Hunter , Andi Kleen , Frederic Weisbecker , Stephane Eranian Subject: [PATCH 19/40] perf callchain: Use thread__find_addr_location_by_time() and friends Date: Mon, 18 May 2015 09:30:34 +0900 Message-Id: <1431909055-21442-20-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: <1431909055-21442-1-git-send-email-namhyung@kernel.org> References: <1431909055-21442-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Find correct thread/map/symbol using proper functions. Cc: Frederic Weisbecker Signed-off-by: Namhyung Kim --- tools/perf/util/machine.c | 25 ++++++++++++-------- .../util/scripting-engines/trace-event-python.c | 4 ++-- tools/perf/util/session.h | 1 - tools/perf/util/unwind-libdw.c | 12 ++++++---- tools/perf/util/unwind-libunwind.c | 27 +++++++++++----------- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 64719692ec77..17e900a6a3c3 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1672,15 +1672,17 @@ static int add_callchain_ip(struct thread *thread, struct symbol **parent, struct addr_location *root_al, u8 *cpumode, - u64 ip) + u64 ip, + u64 timestamp) { struct addr_location al; al.filtered = 0; al.sym = NULL; if (!cpumode) { - thread__find_cpumode_addr_location(thread, MAP__FUNCTION, - ip, &al); + thread__find_cpumode_addr_location_by_time(thread, + MAP__FUNCTION, ip, + &al, timestamp); } else { if (ip >= PERF_CONTEXT_MAX) { switch (ip) { @@ -1705,8 +1707,9 @@ static int add_callchain_ip(struct thread *thread, } return 0; } - thread__find_addr_location(thread, *cpumode, MAP__FUNCTION, - ip, &al); + thread__find_addr_location_by_time(thread, *cpumode, + MAP__FUNCTION, ip, + &al, timestamp); } if (al.sym != NULL) { @@ -1848,7 +1851,8 @@ static int resolve_lbr_callchain_sample(struct thread *thread, ip = lbr_stack->entries[0].to; } - err = add_callchain_ip(thread, parent, root_al, &cpumode, ip); + err = add_callchain_ip(thread, parent, root_al, &cpumode, ip, + sample->time); if (err) return (err < 0) ? err : 0; } @@ -1869,6 +1873,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, struct ip_callchain *chain = sample->callchain; int chain_nr = min(max_stack, (int)chain->nr); u8 cpumode = PERF_RECORD_MISC_USER; + u64 timestamp = sample->time; int i, j, err; int skip_idx = -1; int first_call = 0; @@ -1934,10 +1939,11 @@ static int thread__resolve_callchain_sample(struct thread *thread, for (i = 0; i < nr; i++) { err = add_callchain_ip(thread, parent, root_al, - NULL, be[i].to); + NULL, be[i].to, timestamp); if (!err) err = add_callchain_ip(thread, parent, root_al, - NULL, be[i].from); + NULL, be[i].from, + timestamp); if (err == -EINVAL) break; if (err) @@ -1966,7 +1972,8 @@ static int thread__resolve_callchain_sample(struct thread *thread, #endif ip = chain->ips[j]; - err = add_callchain_ip(thread, parent, root_al, &cpumode, ip); + err = add_callchain_ip(thread, parent, root_al, &cpumode, ip, + timestamp); if (err) return (err < 0) ? err : 0; diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 5544b8cdd1ee..9f51b0dbb087 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -304,8 +304,8 @@ static PyObject *get_field_numeric_entry(struct event_format *event, static PyObject *python_process_callchain(struct perf_sample *sample, - struct perf_evsel *evsel, - struct addr_location *al) + struct perf_evsel *evsel, + struct addr_location *al) { PyObject *pylist; diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 2cf4ee24e40c..b44afc75d1cc 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -136,5 +136,4 @@ int perf_event__synthesize_id_index(struct perf_tool *tool, struct perf_evlist *evlist, struct machine *machine); - #endif /* __PERF_SESSION_H */ diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index 2dcfe9a7c8d0..0dd2b6ff4093 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c @@ -26,9 +26,9 @@ static int __report_module(struct addr_location *al, u64 ip, Dwfl_Module *mod; struct dso *dso = NULL; - thread__find_addr_location(ui->thread, - PERF_RECORD_MISC_USER, - MAP__FUNCTION, ip, al); + thread__find_addr_location_by_time(ui->thread, PERF_RECORD_MISC_USER, + MAP__FUNCTION, ip, al, + ui->sample->time); if (al->map) dso = al->map->dso; @@ -89,8 +89,10 @@ static int access_dso_mem(struct unwind_info *ui, Dwarf_Addr addr, struct addr_location al; ssize_t size; - thread__find_addr_map(ui->thread, PERF_RECORD_MISC_USER, - MAP__FUNCTION, addr, &al); + thread__find_addr_map_by_time(ui->thread, PERF_RECORD_MISC_USER, + MAP__FUNCTION, addr, &al, + ui->sample->time); + if (!al.map) { pr_debug("unwind: no map for %lx\n", (unsigned long)addr); return -1; diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c index 7b09a443a280..0978697341c1 100644 --- a/tools/perf/util/unwind-libunwind.c +++ b/tools/perf/util/unwind-libunwind.c @@ -315,8 +315,10 @@ static struct map *find_map(unw_word_t ip, struct unwind_info *ui) { struct addr_location al; - thread__find_addr_map(ui->thread, PERF_RECORD_MISC_USER, - MAP__FUNCTION, ip, &al); + thread__find_addr_map_by_time(ui->thread, PERF_RECORD_MISC_USER, + MAP__FUNCTION, ip, &al, + ui->sample->time); + return al.map; } @@ -406,20 +408,19 @@ get_proc_name(unw_addr_space_t __maybe_unused as, static int access_dso_mem(struct unwind_info *ui, unw_word_t addr, unw_word_t *data) { - struct addr_location al; + struct map *map; ssize_t size; - thread__find_addr_map(ui->thread, PERF_RECORD_MISC_USER, - MAP__FUNCTION, addr, &al); - if (!al.map) { + map = find_map(addr, ui); + if (!map) { pr_debug("unwind: no map for %lx\n", (unsigned long)addr); return -1; } - if (!al.map->dso) + if (!map->dso) return -1; - size = dso__data_read_addr(al.map->dso, al.map, ui->machine, + size = dso__data_read_addr(map->dso, map, ui->machine, addr, (u8 *) data, sizeof(*data)); return !(size == sizeof(*data)); @@ -511,14 +512,14 @@ static void put_unwind_info(unw_addr_space_t __maybe_unused as, pr_debug("unwind: put_unwind_info called\n"); } -static int entry(u64 ip, struct thread *thread, +static int entry(u64 ip, struct thread *thread, u64 timestamp, unwind_entry_cb_t cb, void *arg) { struct unwind_entry e; struct addr_location al; - thread__find_addr_location(thread, PERF_RECORD_MISC_USER, - MAP__FUNCTION, ip, &al); + thread__find_addr_location_by_time(thread, PERF_RECORD_MISC_USER, + MAP__FUNCTION, ip, &al, timestamp); e.ip = ip; e.map = al.map; @@ -620,7 +621,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, unw_word_t ip; unw_get_reg(&c, UNW_REG_IP, &ip); - ret = ip ? entry(ip, ui->thread, cb, arg) : 0; + ret = ip ? entry(ip, ui->thread, ui->sample->time, cb, arg) : 0; } return ret; @@ -645,7 +646,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, if (ret) return ret; - ret = entry(ip, thread, cb, arg); + ret = entry(ip, thread, data->time, cb, arg); if (ret) return -ENOMEM; -- 2.4.0