Messages in this thread Patch in this message | | | From | Lai Jiangshan <> | Subject | [PATCH 1/3] workqueue: free worker earlier in worker_thread() | Date | Tue, 18 Feb 2014 00:24:01 +0800 |
| |
When @worker is set %WORKER_DIE, it is moved out from idle_list&idr, no one can access it excepct kthread_data().
And in worker_thread, its task is clearred %PF_WQ_WORKER, no one can access the @worker via kthread_data(), we can safely free it.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> --- kernel/workqueue.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 783d5f2..fc05700 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1862,7 +1862,6 @@ static void destroy_worker(struct worker *worker) kthread_stop(worker->task); put_task_struct(worker->task); - kfree(worker); spin_lock_irq(&pool->lock); } @@ -2297,6 +2296,8 @@ woke_up: spin_unlock_irq(&pool->lock); WARN_ON_ONCE(!list_empty(&worker->entry)); worker->task->flags &= ~PF_WQ_WORKER; + /* No one can access to @worker now, free it. */ + kfree(worker); return 0; } -- 1.7.7.6
| |