The unconditional spin_lock(->siglock) looks a bit ugly. We can microoptimize the code and take it only when neede. Imho, also makes the code a little bit more understandable.
Signed-off-by: Oleg Nesterov <o...@redhat.com> --- __UTRACE/kernel/utrace.c~6_DO_STOP_SIGLOCK 2009-08-26 16:53:49.000000000 +0200 +++ __UTRACE/kernel/utrace.c 2009-08-26 18:03:36.000000000 +0200 @@ -660,7 +660,6 @@ static bool utrace_do_stop(struct task_s { bool stopped = false; - spin_lock_irq(&target->sighand->siglock); if (unlikely(target->exit_state)) { /* * On the exit path, it's only truly quiescent @@ -674,13 +673,16 @@ static bool utrace_do_stop(struct task_s * Stopped is considered quiescent; when it wakes up, it will * go through utrace_finish_jctl() before doing anything else. */ - __set_task_state(target, TASK_TRACED); - utrace->stopped = stopped = true; + spin_lock_irq(&target->sighand->siglock); + if (likely(task_is_stopped(target))) { + __set_task_state(target, TASK_TRACED); + utrace->stopped = stopped = true; + } + spin_unlock_irq(&target->sighand->siglock); } else if (!utrace->report && !utrace->interrupt) { utrace->report = 1; set_notify_resume(target); } - spin_unlock_irq(&target->sighand->siglock); return stopped; }