Commit b26b218a authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf callchain: Move initial entry call into get_entries function

Moving initial entry call into get_entries function so all entries
processing is on one place. It will be useful for next change that adds
ordering logic.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Tested-by: default avatarMilian Wolff <milian.wolff@kdab.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1447772739-18471-2-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b7883a1c
...@@ -614,10 +614,22 @@ void unwind__finish_access(struct thread *thread) ...@@ -614,10 +614,22 @@ void unwind__finish_access(struct thread *thread)
static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
void *arg, int max_stack) void *arg, int max_stack)
{ {
u64 val;
unw_addr_space_t addr_space; unw_addr_space_t addr_space;
unw_cursor_t c; unw_cursor_t c;
int ret; int ret;
ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP);
if (ret)
return ret;
ret = entry(val, ui->thread, cb, arg);
if (ret)
return -ENOMEM;
if (--max_stack == 0)
return 0;
addr_space = thread__priv(ui->thread); addr_space = thread__priv(ui->thread);
if (addr_space == NULL) if (addr_space == NULL)
return -1; return -1;
...@@ -640,24 +652,17 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, ...@@ -640,24 +652,17 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct thread *thread, struct thread *thread,
struct perf_sample *data, int max_stack) struct perf_sample *data, int max_stack)
{ {
u64 ip;
struct unwind_info ui = { struct unwind_info ui = {
.sample = data, .sample = data,
.thread = thread, .thread = thread,
.machine = thread->mg->machine, .machine = thread->mg->machine,
}; };
int ret;
if (!data->user_regs.regs) if (!data->user_regs.regs)
return -EINVAL; return -EINVAL;
ret = perf_reg_value(&ip, &data->user_regs, PERF_REG_IP); if (max_stack <= 0)
if (ret) return -EINVAL;
return ret;
ret = entry(ip, thread, cb, arg);
if (ret)
return -ENOMEM;
return --max_stack > 0 ? get_entries(&ui, cb, arg, max_stack) : 0; return get_entries(&ui, cb, arg, max_stack);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment