aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2010-05-26 17:43:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-27 12:12:46 -0400
commitea6d290ca34c4fd91b7348338c0cc7bdeff94a35 (patch)
tree6e9bd367650d9233c5b6cf1059845f17cb1bc460 /kernel/exit.c
parent4dec2a91fd7e8815d730afbfdcf085cbf53433ac (diff)
signals: make task_struct->signal immutable/refcountable
We have a lot of problems with accessing task_struct->signal, it can "disappear" at any moment. Even current can't use its ->signal safely after exit_notify(). ->siglock helps, but it is not convenient, not always possible, and sometimes it makes sense to use task->signal even after this task has already dead. This patch adds the reference counter, sigcnt, into signal_struct. This reference is owned by task_struct and it is dropped in __put_task_struct(). Perhaps it makes sense to export get/put_signal_struct() later, but currently I don't see the immediate reason. Rename __cleanup_signal() to free_signal_struct() and unexport it. With the previous changes it does nothing except kmem_cache_free(). Change __exit_signal() to not clear/free ->signal, it will be freed when the last reference to any thread in the thread group goes away. Note: - when the last thead exits signal->tty can point to nowhere, see the next patch. - with or without this patch signal_struct->count should go away, or at least it should be "int nr_threads" for fs/proc. This will be addressed later. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Alan Cox <alan@linux.intel.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Acked-by: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 4a72f1753edb..92af5cde9bbe 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -134,8 +134,6 @@ static void __exit_signal(struct task_struct *tsk)
134 * doing sigqueue_free() if we have SIGQUEUE_PREALLOC signals. 134 * doing sigqueue_free() if we have SIGQUEUE_PREALLOC signals.
135 */ 135 */
136 flush_sigqueue(&tsk->pending); 136 flush_sigqueue(&tsk->pending);
137
138 tsk->signal = NULL;
139 tsk->sighand = NULL; 137 tsk->sighand = NULL;
140 spin_unlock(&sighand->siglock); 138 spin_unlock(&sighand->siglock);
141 139
@@ -150,7 +148,6 @@ static void __exit_signal(struct task_struct *tsk)
150 */ 148 */
151 task_rq_unlock_wait(tsk); 149 task_rq_unlock_wait(tsk);
152 tty_kref_put(sig->tty); 150 tty_kref_put(sig->tty);
153 __cleanup_signal(sig);
154 } 151 }
155} 152}
156 153