Skip to content

Commit

Permalink
perf thread-stack: Factor out thread_stack__init()
Browse files Browse the repository at this point in the history
In preparation for fixing thread stack processing for the idle task,
factor out thread_stack__init().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20181221120620.9659-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed Jan 2, 2019
1 parent f6060ac commit 2e9e868
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions tools/perf/util/thread-stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ static int thread_stack__grow(struct thread_stack *ts)
return 0;
}

static int thread_stack__init(struct thread_stack *ts, struct thread *thread,
struct call_return_processor *crp)
{
int err;

err = thread_stack__grow(ts);
if (err)
return err;

if (thread->mg && thread->mg->machine)
ts->kernel_start = machine__kernel_start(thread->mg->machine);
else
ts->kernel_start = 1ULL << 63;
ts->crp = crp;

return 0;
}

static struct thread_stack *thread_stack__new(struct thread *thread,
struct call_return_processor *crp)
{
Expand All @@ -104,17 +122,11 @@ static struct thread_stack *thread_stack__new(struct thread *thread,

ts->arr_sz = 1;

if (thread_stack__grow(ts)) {
if (thread_stack__init(ts, thread, crp)) {
free(ts);
return NULL;
}

if (thread->mg && thread->mg->machine)
ts->kernel_start = machine__kernel_start(thread->mg->machine);
else
ts->kernel_start = 1ULL << 63;
ts->crp = crp;

thread->ts = ts;

return ts;
Expand Down

0 comments on commit 2e9e868

Please sign in to comment.