diff options
author | Oleg Nesterov <oleg@redhat.com> | 2010-05-26 17:43:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:46 -0400 |
commit | ea6d290ca34c4fd91b7348338c0cc7bdeff94a35 (patch) | |
tree | 6e9bd367650d9233c5b6cf1059845f17cb1bc460 /include/linux/sched.h | |
parent | 4dec2a91fd7e8815d730afbfdcf085cbf53433ac (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 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index a95a2455cebe..32e309df408c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -527,6 +527,7 @@ struct thread_group_cputimer { | |||
527 | * the locking of signal_struct. | 527 | * the locking of signal_struct. |
528 | */ | 528 | */ |
529 | struct signal_struct { | 529 | struct signal_struct { |
530 | atomic_t sigcnt; | ||
530 | atomic_t count; | 531 | atomic_t count; |
531 | atomic_t live; | 532 | atomic_t live; |
532 | 533 | ||
@@ -2101,7 +2102,6 @@ extern void flush_thread(void); | |||
2101 | extern void exit_thread(void); | 2102 | extern void exit_thread(void); |
2102 | 2103 | ||
2103 | extern void exit_files(struct task_struct *); | 2104 | extern void exit_files(struct task_struct *); |
2104 | extern void __cleanup_signal(struct signal_struct *); | ||
2105 | extern void __cleanup_sighand(struct sighand_struct *); | 2105 | extern void __cleanup_sighand(struct sighand_struct *); |
2106 | 2106 | ||
2107 | extern void exit_itimers(struct signal_struct *); | 2107 | extern void exit_itimers(struct signal_struct *); |