diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2019-01-09 04:18:32 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-06 08:00:40 -0500 |
commit | 90c2cda7056e3a7555d874a27aae12fd46ca802e (patch) | |
tree | 340a388f52486638cead41e9327797084df20d78 | |
parent | e7a3a055f2b88ebd0bdae8b0aade1e7d80c8a81e (diff) |
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: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20190109091835.5570-4-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/thread-stack.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c index 93ba3ab6a602..7f8eff018c16 100644 --- a/tools/perf/util/thread-stack.c +++ b/tools/perf/util/thread-stack.c | |||
@@ -591,34 +591,36 @@ static int thread_stack__no_call_return(struct thread *thread, | |||
591 | struct addr_location *to_al, u64 ref) | 591 | struct addr_location *to_al, u64 ref) |
592 | { | 592 | { |
593 | struct call_path_root *cpr = ts->crp->cpr; | 593 | struct call_path_root *cpr = ts->crp->cpr; |
594 | struct call_path *root = &cpr->call_path; | ||
595 | struct symbol *fsym = from_al->sym; | ||
596 | struct symbol *tsym = to_al->sym; | ||
594 | struct call_path *cp, *parent; | 597 | struct call_path *cp, *parent; |
595 | u64 ks = ts->kernel_start; | 598 | u64 ks = ts->kernel_start; |
599 | u64 addr = sample->addr; | ||
600 | u64 tm = sample->time; | ||
601 | u64 ip = sample->ip; | ||
596 | int err; | 602 | int err; |
597 | 603 | ||
598 | if (sample->ip >= ks && sample->addr < ks) { | 604 | if (ip >= ks && addr < ks) { |
599 | /* Return to userspace, so pop all kernel addresses */ | 605 | /* Return to userspace, so pop all kernel addresses */ |
600 | while (thread_stack__in_kernel(ts)) { | 606 | while (thread_stack__in_kernel(ts)) { |
601 | err = thread_stack__call_return(thread, ts, --ts->cnt, | 607 | err = thread_stack__call_return(thread, ts, --ts->cnt, |
602 | sample->time, ref, | 608 | tm, ref, true); |
603 | true); | ||
604 | if (err) | 609 | if (err) |
605 | return err; | 610 | return err; |
606 | } | 611 | } |
607 | 612 | ||
608 | /* If the stack is empty, push the userspace address */ | 613 | /* If the stack is empty, push the userspace address */ |
609 | if (!ts->cnt) { | 614 | if (!ts->cnt) { |
610 | cp = call_path__findnew(cpr, &cpr->call_path, | 615 | cp = call_path__findnew(cpr, root, tsym, addr, ks); |
611 | to_al->sym, sample->addr, | 616 | return thread_stack__push_cp(ts, 0, tm, ref, cp, true, |
612 | ts->kernel_start); | 617 | false); |
613 | return thread_stack__push_cp(ts, 0, sample->time, ref, | ||
614 | cp, true, false); | ||
615 | } | 618 | } |
616 | } else if (thread_stack__in_kernel(ts) && sample->ip < ks) { | 619 | } else if (thread_stack__in_kernel(ts) && ip < ks) { |
617 | /* Return to userspace, so pop all kernel addresses */ | 620 | /* Return to userspace, so pop all kernel addresses */ |
618 | while (thread_stack__in_kernel(ts)) { | 621 | while (thread_stack__in_kernel(ts)) { |
619 | err = thread_stack__call_return(thread, ts, --ts->cnt, | 622 | err = thread_stack__call_return(thread, ts, --ts->cnt, |
620 | sample->time, ref, | 623 | tm, ref, true); |
621 | true); | ||
622 | if (err) | 624 | if (err) |
623 | return err; | 625 | return err; |
624 | } | 626 | } |
@@ -627,19 +629,16 @@ static int thread_stack__no_call_return(struct thread *thread, | |||
627 | if (ts->cnt) | 629 | if (ts->cnt) |
628 | parent = ts->stack[ts->cnt - 1].cp; | 630 | parent = ts->stack[ts->cnt - 1].cp; |
629 | else | 631 | else |
630 | parent = &cpr->call_path; | 632 | parent = root; |
631 | 633 | ||
632 | /* This 'return' had no 'call', so push and pop top of stack */ | 634 | /* This 'return' had no 'call', so push and pop top of stack */ |
633 | cp = call_path__findnew(cpr, parent, from_al->sym, sample->ip, | 635 | cp = call_path__findnew(cpr, parent, fsym, ip, ks); |
634 | ts->kernel_start); | ||
635 | 636 | ||
636 | err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp, | 637 | err = thread_stack__push_cp(ts, addr, tm, ref, cp, true, false); |
637 | true, false); | ||
638 | if (err) | 638 | if (err) |
639 | return err; | 639 | return err; |
640 | 640 | ||
641 | return thread_stack__pop_cp(thread, ts, sample->addr, sample->time, ref, | 641 | return thread_stack__pop_cp(thread, ts, addr, tm, ref, tsym); |
642 | to_al->sym); | ||
643 | } | 642 | } |
644 | 643 | ||
645 | static int thread_stack__trace_begin(struct thread *thread, | 644 | static int thread_stack__trace_begin(struct thread *thread, |