Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d25d227 authored by Park Ju Hyung's avatar Park Ju Hyung Committed by KakatkarAkshay
Browse files

kthread: use buffer from the stack space



struct kthread_create_info is small enough to fit perfectly under
the stack space.

Signed-off-by: default avatarPark Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: default avatarAdam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: default avatarLibXZR <xzr467706992@163.com>
parent 5f402c67
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -289,18 +289,15 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
{
	DECLARE_COMPLETION_ONSTACK(done);
	struct task_struct *task;
	struct kthread_create_info *create = kmalloc(sizeof(*create),
						     GFP_KERNEL);
	struct kthread_create_info create;

	if (!create)
		return ERR_PTR(-ENOMEM);
	create->threadfn = threadfn;
	create->data = data;
	create->node = node;
	create->done = &done;
	create.threadfn = threadfn;
	create.data = data;
	create.node = node;
	create.done = &done;

	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);

	wake_up_process(kthreadd_task);
@@ -315,7 +312,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
		 * calls complete(), leave the cleanup of this structure to
		 * that thread.
		 */
		if (xchg(&create->done, NULL))
		if (xchg(&create.done, NULL))
			return ERR_PTR(-EINTR);
		/*
		 * kthreadd (or new kernel thread) will call complete()
@@ -323,7 +320,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
		 */
		wait_for_completion(&done);
	}
	task = create->result;
	task = create.result;
	if (!IS_ERR(task)) {
		static const struct sched_param param = { .sched_priority = 0 };
		char name[TASK_COMM_LEN];
@@ -341,7 +338,6 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
		sched_setscheduler_nocheck(task, SCHED_NORMAL, &param);
		set_cpus_allowed_ptr(task, cpu_all_mask);
	}
	kfree(create);
	return task;
}