]> err.no Git - linux-2.6/commitdiff
[PATCH] copy_process: cleanup bad_fork_cleanup_sighand
authorOleg Nesterov <oleg@tv-sign.ru>
Wed, 29 Mar 2006 00:11:14 +0000 (16:11 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 29 Mar 2006 02:36:42 +0000 (18:36 -0800)
The only caller of exit_sighand(tsk) is copy_process's error path.  We can
call __exit_sighand() directly and kill exit_sighand().

This 'tsk' was not yet registered in pid_hash[] or init_task.tasks, it has no
external references, nobody can see it, and

IF (clone_flags & CLONE_SIGHAND)
At least 'current' has a reference to ->sighand, this
means atomic_dec_and_test(sighand->count) can't be true.

ELSE
Nobody can see this ->sighand, this means we can free it
without any locking.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: "Paul E. McKenney" <paulmck@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/sched.h
kernel/fork.c
kernel/signal.c

index ca1fd31aae979b75ceb99273a4ecfd4d10f4fcf3..69c2a1e1529e9dfdb95394bc105ec1f8d400da2d 100644 (file)
@@ -1151,7 +1151,6 @@ extern void exit_thread(void);
 extern void exit_files(struct task_struct *);
 extern void exit_signal(struct task_struct *);
 extern void __exit_signal(struct task_struct *);
-extern void exit_sighand(struct task_struct *);
 extern void __exit_sighand(struct task_struct *);
 extern void exit_itimers(struct signal_struct *);
 
index 33ffb5bf0dbc6092ed1ad5bae1c5b46289026efd..8a46ad52be8f3dabd44f6ccf3a2ccf4a37f58794 100644 (file)
@@ -1208,7 +1208,8 @@ bad_fork_cleanup_mm:
 bad_fork_cleanup_signal:
        exit_signal(p);
 bad_fork_cleanup_sighand:
-       exit_sighand(p);
+       if (p->sighand)
+               __exit_sighand(p);
 bad_fork_cleanup_fs:
        exit_fs(p); /* blocking */
 bad_fork_cleanup_files:
index c5b65aa4c2bccfdcc82f919422f4b7589c2015f9..1d7f4463c32d15c14a2b1f9e366da57a35ab20ac 100644 (file)
@@ -336,20 +336,6 @@ void __exit_sighand(struct task_struct *tsk)
                kmem_cache_free(sighand_cachep, sighand);
 }
 
-void exit_sighand(struct task_struct *tsk)
-{
-       write_lock_irq(&tasklist_lock);
-       rcu_read_lock();
-       if (tsk->sighand != NULL) {
-               struct sighand_struct *sighand = rcu_dereference(tsk->sighand);
-               spin_lock(&sighand->siglock);
-               __exit_sighand(tsk);
-               spin_unlock(&sighand->siglock);
-       }
-       rcu_read_unlock();
-       write_unlock_irq(&tasklist_lock);
-}
-
 /*
  * This function expects the tasklist_lock write-locked.
  */