aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2006-03-28 19:11:28 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-28 21:36:44 -0500
commitdac27f4a09c274db048e80d2511102e540ac9e3a (patch)
treefeb4af6d7b1a784ece9909b8d5f11bd6ad83cdca
parenta7e5328a06a2beee3a2bbfaf87ce2a7bbe937de1 (diff)
[PATCH] simplify do_signal_stop()
do_signal_stop() considers 'thread_group_empty()' as a special case. This was needed to avoid taking tasklist_lock. Since this lock is unneeded any longer, we can remove this special case and simplify the code even more. Also, before this patch, finish_stop() was called with stop_count == -1 for 'thread_group_empty()' case. This is not strictly wrong, but confusing and unneeded. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: john stultz <johnstul@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--kernel/signal.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index 2dfaa5076c31..efba39626e66 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1685,8 +1685,7 @@ out:
1685static int do_signal_stop(int signr) 1685static int do_signal_stop(int signr)
1686{ 1686{
1687 struct signal_struct *sig = current->signal; 1687 struct signal_struct *sig = current->signal;
1688 struct sighand_struct *sighand = current->sighand; 1688 int stop_count;
1689 int stop_count = -1;
1690 1689
1691 if (!likely(sig->flags & SIGNAL_STOP_DEQUEUED)) 1690 if (!likely(sig->flags & SIGNAL_STOP_DEQUEUED))
1692 return 0; 1691 return 0;
@@ -1696,30 +1695,14 @@ static int do_signal_stop(int signr)
1696 * There is a group stop in progress. We don't need to 1695 * There is a group stop in progress. We don't need to
1697 * start another one. 1696 * start another one.
1698 */ 1697 */
1699 signr = sig->group_exit_code;
1700 stop_count = --sig->group_stop_count; 1698 stop_count = --sig->group_stop_count;
1701 current->exit_code = signr; 1699 } else {
1702 set_current_state(TASK_STOPPED);
1703 if (stop_count == 0)
1704 sig->flags = SIGNAL_STOP_STOPPED;
1705 }
1706 else if (thread_group_empty(current)) {
1707 /*
1708 * Lock must be held through transition to stopped state.
1709 */
1710 current->exit_code = current->signal->group_exit_code = signr;
1711 set_current_state(TASK_STOPPED);
1712 sig->flags = SIGNAL_STOP_STOPPED;
1713 }
1714 else {
1715 /* 1700 /*
1716 * (sig->group_stop_count == 0)
1717 * There is no group stop already in progress. 1701 * There is no group stop already in progress.
1718 * We must initiate one now. 1702 * We must initiate one now.
1719 */ 1703 */
1720 struct task_struct *t; 1704 struct task_struct *t;
1721 1705
1722 current->exit_code = signr;
1723 sig->group_exit_code = signr; 1706 sig->group_exit_code = signr;
1724 1707
1725 stop_count = 0; 1708 stop_count = 0;
@@ -1735,13 +1718,14 @@ static int do_signal_stop(int signr)
1735 signal_wake_up(t, 0); 1718 signal_wake_up(t, 0);
1736 } 1719 }
1737 sig->group_stop_count = stop_count; 1720 sig->group_stop_count = stop_count;
1738
1739 set_current_state(TASK_STOPPED);
1740 if (stop_count == 0)
1741 sig->flags = SIGNAL_STOP_STOPPED;
1742 } 1721 }
1743 1722
1744 spin_unlock_irq(&sighand->siglock); 1723 if (stop_count == 0)
1724 sig->flags = SIGNAL_STOP_STOPPED;
1725 current->exit_code = sig->group_exit_code;
1726 __set_current_state(TASK_STOPPED);
1727
1728 spin_unlock_irq(&current->sighand->siglock);
1745 finish_stop(stop_count); 1729 finish_stop(stop_count);
1746 return 1; 1730 return 1;
1747} 1731}