mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-17 12:14:43 +00:00
perf thread-stack: Allocate an array of thread stacks
In preparation for fixing thread stack processing for the idle task, allocate an array of thread stacks. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/20181221120620.9659-7-adrian.hunter@intel.com [ No need to check for NULL when calling zfree(), noticed by Jiri Olsa ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
2e9e868876
commit
139f42f3b3
1 changed files with 16 additions and 11 deletions
|
|
@ -114,20 +114,25 @@ static int thread_stack__init(struct thread_stack *ts, struct thread *thread,
|
||||||
static struct thread_stack *thread_stack__new(struct thread *thread,
|
static struct thread_stack *thread_stack__new(struct thread *thread,
|
||||||
struct call_return_processor *crp)
|
struct call_return_processor *crp)
|
||||||
{
|
{
|
||||||
struct thread_stack *ts;
|
struct thread_stack *ts = thread->ts, *new_ts;
|
||||||
|
unsigned int old_sz = ts ? ts->arr_sz : 0;
|
||||||
|
unsigned int new_sz = 1;
|
||||||
|
|
||||||
ts = zalloc(sizeof(struct thread_stack));
|
if (!ts || new_sz > old_sz) {
|
||||||
if (!ts)
|
new_ts = calloc(new_sz, sizeof(*ts));
|
||||||
return NULL;
|
if (!new_ts)
|
||||||
|
return NULL;
|
||||||
ts->arr_sz = 1;
|
if (ts)
|
||||||
|
memcpy(new_ts, ts, old_sz * sizeof(*ts));
|
||||||
if (thread_stack__init(ts, thread, crp)) {
|
new_ts->arr_sz = new_sz;
|
||||||
free(ts);
|
zfree(&thread->ts);
|
||||||
return NULL;
|
thread->ts = new_ts;
|
||||||
|
ts = new_ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->ts = ts;
|
if (!ts->stack &&
|
||||||
|
thread_stack__init(ts, thread, crp))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue