Skip to content

Commit 2e9e868

Browse files
ahunter6acmel
authored andcommitted
perf thread-stack: Factor out thread_stack__init()
In preparation for fixing thread stack processing for the idle task, factor out thread_stack__init(). Signed-off-by: Adrian Hunter <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f6060ac commit 2e9e868

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

tools/perf/util/thread-stack.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ static int thread_stack__grow(struct thread_stack *ts)
9393
return 0;
9494
}
9595

96+
static int thread_stack__init(struct thread_stack *ts, struct thread *thread,
97+
struct call_return_processor *crp)
98+
{
99+
int err;
100+
101+
err = thread_stack__grow(ts);
102+
if (err)
103+
return err;
104+
105+
if (thread->mg && thread->mg->machine)
106+
ts->kernel_start = machine__kernel_start(thread->mg->machine);
107+
else
108+
ts->kernel_start = 1ULL << 63;
109+
ts->crp = crp;
110+
111+
return 0;
112+
}
113+
96114
static struct thread_stack *thread_stack__new(struct thread *thread,
97115
struct call_return_processor *crp)
98116
{
@@ -104,17 +122,11 @@ static struct thread_stack *thread_stack__new(struct thread *thread,
104122

105123
ts->arr_sz = 1;
106124

107-
if (thread_stack__grow(ts)) {
125+
if (thread_stack__init(ts, thread, crp)) {
108126
free(ts);
109127
return NULL;
110128
}
111129

112-
if (thread->mg && thread->mg->machine)
113-
ts->kernel_start = machine__kernel_start(thread->mg->machine);
114-
else
115-
ts->kernel_start = 1ULL << 63;
116-
ts->crp = crp;
117-
118130
thread->ts = ts;
119131

120132
return ts;

0 commit comments

Comments
 (0)