cleanup __exit_signal()
PATCH 3/4 cleanup __exit_signal()
This patch factors out duplicated code under 'if' branches. Also, BUG_ON() conversions and whitespace cleanups.
kernel/signal.c renamed from kernel/signal.c~3_ESIG +15 -16
@@ -341,24 +341,20 @@ void __exit_sighand(struct task_struct **/ void __exit_signal (struct task_struct *tsk) { -struct signal_struct * sig = tsk->signal; -struct sighand_struct * sighand; +struct signal_struct *sig = tsk->signal; +struct sighand_struct *sighand; + +BUG_ON (!sig); +BUG_ON (!atomic_read (&sig->count)); -if (!sig) -BUG (); -if (!atomic_read (&sig->count)) -BUG ();rcu_read_lock (); sighand =rcu_dereference (tsk->sighand);spin_lock (&sighand->siglock); +posix_cpu_timers_exit (tsk); -if (atomic_dec_and_test (&sig->count)) { +if (atomic_dec_and_test (&sig->count))posix_cpu_timers_exit_group (tsk); - tsk->signal =NULL ; -__exit_sighand (tsk); -spin_unlock (&sighand->siglock); -flush_sigqueue (&sig->shared_pending); - }else { +else {/* * If there is any task waiting for the group exit * then notify it:
@@ -369,7 +365,6 @@ void __exit_signal(struct task_struct *t }if (tsk == sig->curr_target) sig->curr_target =next_thread (tsk); - tsk->signal =NULL ;/* * Accumulate here the counters for all threads but the * group leader as they die, so they can be added into
@@ -387,14 +382,18 @@ void __exit_signal(struct task_struct *t sig->nvcsw += tsk->nvcsw; sig->nivcsw += tsk->nivcsw; sig->sched_time += tsk->sched_time; -__exit_sighand (tsk); -spin_unlock (&sighand->siglock); - sig =NULL ;/* Marker for below. */ + sig =NULL ;/* Marker for below. */ } + + tsk->signal =NULL ; +__exit_sighand (tsk); +spin_unlock (&sighand->siglock);rcu_read_unlock (); +clear_tsk_thread_flag (tsk,TIF_SIGPENDING );flush_sigqueue (&tsk->pending);if (sig) { +flush_sigqueue (&sig->shared_pending);__cleanup_signal (sig); } }
Quoted 2 lines · Oleg Nesterov
This patch factors out duplicated code under 'if' branches. Also,
BUG_ON()conversions and whitespace cleanups.
Passed steamroller. Looks sane to me.
Thanx, Paul
Quoted 67 lines
Signed-off-by Oleg Nesterov <[email protected]>kernel/signal.c renamed from kernel/signal.c~3_ESIG +15
-16@@ -341,24 +341,20 @@ void __exit_sighand(struct task_struct **/ void __exit_signal (struct task_struct *tsk) { -struct signal_struct * sig = tsk->signal; -struct sighand_struct * sighand; +struct signal_struct *sig = tsk->signal; +struct sighand_struct *sighand; + +BUG_ON (!sig); +BUG_ON (!atomic_read (&sig->count)); -if (!sig) -BUG (); -if (!atomic_read (&sig->count)) -BUG ();rcu_read_lock (); sighand =rcu_dereference (tsk->sighand);spin_lock (&sighand->siglock); +posix_cpu_timers_exit (tsk); -if (atomic_dec_and_test (&sig->count)) { +if (atomic_dec_and_test (&sig->count))posix_cpu_timers_exit_group (tsk); - tsk->signal =NULL ; -__exit_sighand (tsk); -spin_unlock (&sighand->siglock); -flush_sigqueue (&sig->shared_pending); - }else { +else {/* * If there is any task waiting for the group exit * then notify it: @@ -369,7 +365,6 @@ void __exit_signal(struct task_struct *t }if (tsk == sig->curr_target) sig->curr_target =next_thread (tsk); - tsk->signal =NULL ;/* * Accumulate here the counters for all threads but the * group leader as they die, so they can be added into @@ -387,14 +382,18 @@ void __exit_signal(struct task_struct *t sig->nvcsw += tsk->nvcsw; sig->nivcsw += tsk->nivcsw; sig->sched_time += tsk->sched_time; -__exit_sighand (tsk); -spin_unlock (&sighand->siglock); - sig =NULL ;/* Marker for below. */ + sig =NULL ;/* Marker for below. */ } + + tsk->signal =NULL ; +__exit_sighand (tsk); +spin_unlock (&sighand->siglock);rcu_read_unlock (); +clear_tsk_thread_flag (tsk,TIF_SIGPENDING );flush_sigqueue (&tsk->pending);if (sig) { +flush_sigqueue (&sig->shared_pending);__cleanup_signal (sig); } }
Quoted 6 lines · Paul E. McKenney
Quoted 2 lines · Oleg Nesterov
This patch factors out duplicated code under 'if' branches. Also,
BUG_ON()conversions and whitespace cleanups.Passed steamroller. Looks sane to me.
Oh, thanks!
I forgot to say it, but I had run steamroller tests too before I sent "some tasklist_lock removals" series.
Do you know any other test which may be useful too?
Oleg.
Quoted 6 lines · Oleg Nesterov
Quoted 5 lines · Paul E. McKenney
Quoted 2 lines · Oleg Nesterov
This patch factors out duplicated code under 'if' branches. Also,
BUG_ON()conversions and whitespace cleanups.
Quoted 6 lines
Quoted 1 line
Passed steamroller. Looks sane to me.
Oh, thanks!
I forgot to say it, but I had run steamroller tests too before I sent "some
tasklist_lockremovals" series.
Glad to hear it!
Quoted 1 line
Do you know any other test which may be useful too?
Matt Wilcox mentioned that a full build of gdb ran some tests that do a good job of exercising signals. I have not yet tried this myself (but am giving it a shot).
Also, my guess is that you ran steamroller on x86 (how many CPUs?). I ran on ppc64.
Thanx, Paul