aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kthread.c')
-rw-r--r--kernel/kthread.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c
index e75950a1092c..c5f3c6613b6d 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -12,6 +12,7 @@
12#include <linux/unistd.h> 12#include <linux/unistd.h>
13#include <linux/file.h> 13#include <linux/file.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/mutex.h>
15#include <asm/semaphore.h> 16#include <asm/semaphore.h>
16 17
17/* 18/*
@@ -41,7 +42,7 @@ struct kthread_stop_info
41 42
42/* Thread stopping is done by setthing this var: lock serializes 43/* Thread stopping is done by setthing this var: lock serializes
43 * multiple kthread_stop calls. */ 44 * multiple kthread_stop calls. */
44static DECLARE_MUTEX(kthread_stop_lock); 45static DEFINE_MUTEX(kthread_stop_lock);
45static struct kthread_stop_info kthread_stop_info; 46static struct kthread_stop_info kthread_stop_info;
46 47
47int kthread_should_stop(void) 48int kthread_should_stop(void)
@@ -114,7 +115,9 @@ static void keventd_create_kthread(void *_create)
114 create->result = ERR_PTR(pid); 115 create->result = ERR_PTR(pid);
115 } else { 116 } else {
116 wait_for_completion(&create->started); 117 wait_for_completion(&create->started);
118 read_lock(&tasklist_lock);
117 create->result = find_task_by_pid(pid); 119 create->result = find_task_by_pid(pid);
120 read_unlock(&tasklist_lock);
118 } 121 }
119 complete(&create->done); 122 complete(&create->done);
120} 123}
@@ -173,7 +176,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
173{ 176{
174 int ret; 177 int ret;
175 178
176 down(&kthread_stop_lock); 179 mutex_lock(&kthread_stop_lock);
177 180
178 /* It could exit after stop_info.k set, but before wake_up_process. */ 181 /* It could exit after stop_info.k set, but before wake_up_process. */
179 get_task_struct(k); 182 get_task_struct(k);
@@ -194,7 +197,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
194 wait_for_completion(&kthread_stop_info.done); 197 wait_for_completion(&kthread_stop_info.done);
195 kthread_stop_info.k = NULL; 198 kthread_stop_info.k = NULL;
196 ret = kthread_stop_info.err; 199 ret = kthread_stop_info.err;
197 up(&kthread_stop_lock); 200 mutex_unlock(&kthread_stop_lock);
198 201
199 return ret; 202 return ret;
200} 203}