kthread: use buffer from the stack space
struct kthread_create_info is small enough to fit perfectly under the stack space. Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com> Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
This commit is contained in:
parent
518acbdb88
commit
d2baa1092e
@ -302,18 +302,15 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
|
|||||||
{
|
{
|
||||||
DECLARE_COMPLETION_ONSTACK(done);
|
DECLARE_COMPLETION_ONSTACK(done);
|
||||||
struct task_struct *task;
|
struct task_struct *task;
|
||||||
struct kthread_create_info *create = kmalloc(sizeof(*create),
|
struct kthread_create_info create;
|
||||||
GFP_KERNEL);
|
|
||||||
|
|
||||||
if (!create)
|
create.threadfn = threadfn;
|
||||||
return ERR_PTR(-ENOMEM);
|
create.data = data;
|
||||||
create->threadfn = threadfn;
|
create.node = node;
|
||||||
create->data = data;
|
create.done = &done;
|
||||||
create->node = node;
|
|
||||||
create->done = &done;
|
|
||||||
|
|
||||||
spin_lock(&kthread_create_lock);
|
spin_lock(&kthread_create_lock);
|
||||||
list_add_tail(&create->list, &kthread_create_list);
|
list_add_tail(&create.list, &kthread_create_list);
|
||||||
spin_unlock(&kthread_create_lock);
|
spin_unlock(&kthread_create_lock);
|
||||||
|
|
||||||
wake_up_process(kthreadd_task);
|
wake_up_process(kthreadd_task);
|
||||||
@ -328,7 +325,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
|
|||||||
* calls complete(), leave the cleanup of this structure to
|
* calls complete(), leave the cleanup of this structure to
|
||||||
* that thread.
|
* that thread.
|
||||||
*/
|
*/
|
||||||
if (xchg(&create->done, NULL))
|
if (xchg(&create.done, NULL))
|
||||||
return ERR_PTR(-EINTR);
|
return ERR_PTR(-EINTR);
|
||||||
/*
|
/*
|
||||||
* kthreadd (or new kernel thread) will call complete()
|
* kthreadd (or new kernel thread) will call complete()
|
||||||
@ -336,7 +333,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
|
|||||||
*/
|
*/
|
||||||
wait_for_completion(&done);
|
wait_for_completion(&done);
|
||||||
}
|
}
|
||||||
task = create->result;
|
task = create.result;
|
||||||
if (!IS_ERR(task)) {
|
if (!IS_ERR(task)) {
|
||||||
static const struct sched_param param = { .sched_priority = 0 };
|
static const struct sched_param param = { .sched_priority = 0 };
|
||||||
char name[TASK_COMM_LEN];
|
char name[TASK_COMM_LEN];
|
||||||
@ -354,7 +351,6 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
|
|||||||
sched_setscheduler_nocheck(task, SCHED_NORMAL, ¶m);
|
sched_setscheduler_nocheck(task, SCHED_NORMAL, ¶m);
|
||||||
set_cpus_allowed_ptr(task, cpu_all_mask);
|
set_cpus_allowed_ptr(task, cpu_all_mask);
|
||||||
}
|
}
|
||||||
kfree(create);
|
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user