[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>

authored by

Oleg Nesterov and committed by
Linus Torvalds
dac27f4a a7e5328a

+8 -24
+8 -24
kernel/signal.c
··· 1685 1685 static int do_signal_stop(int signr) 1686 1686 { 1687 1687 struct signal_struct *sig = current->signal; 1688 - struct sighand_struct *sighand = current->sighand; 1689 - int stop_count = -1; 1688 + int stop_count; 1690 1689 1691 1690 if (!likely(sig->flags & SIGNAL_STOP_DEQUEUED)) 1692 1691 return 0; ··· 1695 1696 * There is a group stop in progress. We don't need to 1696 1697 * start another one. 1697 1698 */ 1698 - signr = sig->group_exit_code; 1699 1699 stop_count = --sig->group_stop_count; 1700 - current->exit_code = signr; 1701 - set_current_state(TASK_STOPPED); 1702 - if (stop_count == 0) 1703 - sig->flags = SIGNAL_STOP_STOPPED; 1704 - } 1705 - else if (thread_group_empty(current)) { 1700 + } else { 1706 1701 /* 1707 - * Lock must be held through transition to stopped state. 1708 - */ 1709 - current->exit_code = current->signal->group_exit_code = signr; 1710 - set_current_state(TASK_STOPPED); 1711 - sig->flags = SIGNAL_STOP_STOPPED; 1712 - } 1713 - else { 1714 - /* 1715 - * (sig->group_stop_count == 0) 1716 1702 * There is no group stop already in progress. 1717 1703 * We must initiate one now. 1718 1704 */ 1719 1705 struct task_struct *t; 1720 1706 1721 - current->exit_code = signr; 1722 1707 sig->group_exit_code = signr; 1723 1708 1724 1709 stop_count = 0; ··· 1718 1735 signal_wake_up(t, 0); 1719 1736 } 1720 1737 sig->group_stop_count = stop_count; 1721 - 1722 - set_current_state(TASK_STOPPED); 1723 - if (stop_count == 0) 1724 - sig->flags = SIGNAL_STOP_STOPPED; 1725 1738 } 1726 1739 1727 - spin_unlock_irq(&sighand->siglock); 1740 + if (stop_count == 0) 1741 + sig->flags = SIGNAL_STOP_STOPPED; 1742 + current->exit_code = sig->group_exit_code; 1743 + __set_current_state(TASK_STOPPED); 1744 + 1745 + spin_unlock_irq(&current->sighand->siglock); 1728 1746 finish_stop(stop_count); 1729 1747 return 1; 1730 1748 }