[PATCH] cleanup __exit_signal->cleanup_sighand path

Move 'tsk->sighand = NULL' from cleanup_sighand() to __exit_signal(). This
makes the exit path more understandable and allows us to do
cleanup_sighand() outside of ->siglock protected section.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Oleg Nesterov and committed by
Linus Torvalds
a7e5328a 4a2c7a78

+5 -8
+1 -1
include/linux/sched.h
··· 1151 1152 extern void exit_files(struct task_struct *); 1153 extern void __cleanup_signal(struct signal_struct *); 1154 - extern void cleanup_sighand(struct task_struct *); 1155 extern void exit_itimers(struct signal_struct *); 1156 1157 extern NORET_TYPE void do_group_exit(int);
··· 1151 1152 extern void exit_files(struct task_struct *); 1153 extern void __cleanup_signal(struct signal_struct *); 1154 + extern void __cleanup_sighand(struct sighand_struct *); 1155 extern void exit_itimers(struct signal_struct *); 1156 1157 extern NORET_TYPE void do_group_exit(int);
+2 -1
kernel/exit.c
··· 114 __unhash_process(tsk); 115 116 tsk->signal = NULL; 117 - cleanup_sighand(tsk); 118 spin_unlock(&sighand->siglock); 119 rcu_read_unlock(); 120 121 clear_tsk_thread_flag(tsk,TIF_SIGPENDING); 122 flush_sigqueue(&tsk->pending); 123 if (sig) {
··· 114 __unhash_process(tsk); 115 116 tsk->signal = NULL; 117 + tsk->sighand = NULL; 118 spin_unlock(&sighand->siglock); 119 rcu_read_unlock(); 120 121 + __cleanup_sighand(sighand); 122 clear_tsk_thread_flag(tsk,TIF_SIGPENDING); 123 flush_sigqueue(&tsk->pending); 124 if (sig) {
+2 -6
kernel/fork.c
··· 803 return 0; 804 } 805 806 - void cleanup_sighand(struct task_struct *tsk) 807 { 808 - struct sighand_struct * sighand = tsk->sighand; 809 - 810 - /* Ok, we're done with the signal handlers */ 811 - tsk->sighand = NULL; 812 if (atomic_dec_and_test(&sighand->count)) 813 kmem_cache_free(sighand_cachep, sighand); 814 } ··· 1229 bad_fork_cleanup_signal: 1230 cleanup_signal(p); 1231 bad_fork_cleanup_sighand: 1232 - cleanup_sighand(p); 1233 bad_fork_cleanup_fs: 1234 exit_fs(p); /* blocking */ 1235 bad_fork_cleanup_files:
··· 803 return 0; 804 } 805 806 + void __cleanup_sighand(struct sighand_struct *sighand) 807 { 808 if (atomic_dec_and_test(&sighand->count)) 809 kmem_cache_free(sighand_cachep, sighand); 810 } ··· 1233 bad_fork_cleanup_signal: 1234 cleanup_signal(p); 1235 bad_fork_cleanup_sighand: 1236 + __cleanup_sighand(p->sighand); 1237 bad_fork_cleanup_fs: 1238 exit_fs(p); /* blocking */ 1239 bad_fork_cleanup_files: