Commit 90c2cda7 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf thread-stack: Tidy thread_stack__no_call_return() by adding more local variables

Make thread_stack__no_call_return() more readable by adding more local
variables.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20190109091835.5570-4-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e7a3a055
...@@ -591,34 +591,36 @@ static int thread_stack__no_call_return(struct thread *thread, ...@@ -591,34 +591,36 @@ static int thread_stack__no_call_return(struct thread *thread,
struct addr_location *to_al, u64 ref) struct addr_location *to_al, u64 ref)
{ {
struct call_path_root *cpr = ts->crp->cpr; struct call_path_root *cpr = ts->crp->cpr;
struct call_path *root = &cpr->call_path;
struct symbol *fsym = from_al->sym;
struct symbol *tsym = to_al->sym;
struct call_path *cp, *parent; struct call_path *cp, *parent;
u64 ks = ts->kernel_start; u64 ks = ts->kernel_start;
u64 addr = sample->addr;
u64 tm = sample->time;
u64 ip = sample->ip;
int err; int err;
if (sample->ip >= ks && sample->addr < ks) { if (ip >= ks && addr < ks) {
/* Return to userspace, so pop all kernel addresses */ /* Return to userspace, so pop all kernel addresses */
while (thread_stack__in_kernel(ts)) { while (thread_stack__in_kernel(ts)) {
err = thread_stack__call_return(thread, ts, --ts->cnt, err = thread_stack__call_return(thread, ts, --ts->cnt,
sample->time, ref, tm, ref, true);
true);
if (err) if (err)
return err; return err;
} }
/* If the stack is empty, push the userspace address */ /* If the stack is empty, push the userspace address */
if (!ts->cnt) { if (!ts->cnt) {
cp = call_path__findnew(cpr, &cpr->call_path, cp = call_path__findnew(cpr, root, tsym, addr, ks);
to_al->sym, sample->addr, return thread_stack__push_cp(ts, 0, tm, ref, cp, true,
ts->kernel_start); false);
return thread_stack__push_cp(ts, 0, sample->time, ref,
cp, true, false);
} }
} else if (thread_stack__in_kernel(ts) && sample->ip < ks) { } else if (thread_stack__in_kernel(ts) && ip < ks) {
/* Return to userspace, so pop all kernel addresses */ /* Return to userspace, so pop all kernel addresses */
while (thread_stack__in_kernel(ts)) { while (thread_stack__in_kernel(ts)) {
err = thread_stack__call_return(thread, ts, --ts->cnt, err = thread_stack__call_return(thread, ts, --ts->cnt,
sample->time, ref, tm, ref, true);
true);
if (err) if (err)
return err; return err;
} }
...@@ -627,19 +629,16 @@ static int thread_stack__no_call_return(struct thread *thread, ...@@ -627,19 +629,16 @@ static int thread_stack__no_call_return(struct thread *thread,
if (ts->cnt) if (ts->cnt)
parent = ts->stack[ts->cnt - 1].cp; parent = ts->stack[ts->cnt - 1].cp;
else else
parent = &cpr->call_path; parent = root;
/* This 'return' had no 'call', so push and pop top of stack */ /* This 'return' had no 'call', so push and pop top of stack */
cp = call_path__findnew(cpr, parent, from_al->sym, sample->ip, cp = call_path__findnew(cpr, parent, fsym, ip, ks);
ts->kernel_start);
err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp, err = thread_stack__push_cp(ts, addr, tm, ref, cp, true, false);
true, false);
if (err) if (err)
return err; return err;
return thread_stack__pop_cp(thread, ts, sample->addr, sample->time, ref, return thread_stack__pop_cp(thread, ts, addr, tm, ref, tsym);
to_al->sym);
} }
static int thread_stack__trace_begin(struct thread *thread, static int thread_stack__trace_begin(struct thread *thread,
......
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