do_wait: simplify retval/tsk_result/notask_error mess

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, June 18, 2009 - 3:00 pm

Gitweb:     http://git.kernel.org/linus/64a16caf5e3417ee32f670debcb5857b02a9e08e
Commit:     64a16caf5e3417ee32f670debcb5857b02a9e08e
Parent:     9e8ae01d1c86dcaa6443c897662545d088036e4c
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Wed Jun 17 16:27:40 2009 -0700
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Thu Jun 18 13:03:53 2009 -0700

    do_wait: simplify retval/tsk_result/notask_error mess
    
    Now that we don't pass &retval down to other helpers we can simplify
    the code more.
    
    - kill tsk_result, just use retval
    
    - add the "notask" label right after the main loop, and
      s/got end/goto notask/ after the fastpath pid check.
    
      This way we don't need to initialize retval before this
      check and the code becomes a bit more clean, if this pid
      has no attached tasks we should just skip the list search.
    
    Signed-off-by: Oleg Nesterov <oleg@redhat.com>
    Cc: Ingo Molnar <mingo@elte.hu>
    Acked-by: Roland McGrath <roland@redhat.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 kernel/exit.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 29622e4..9c6881a 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1576,27 +1576,22 @@ repeat:
 	 * might later match our criteria, even if we are not able to reap
 	 * it yet.
 	 */
-	retval = wo->notask_error = -ECHILD;
+	wo->notask_error = -ECHILD;
 	if ((wo->wo_type < PIDTYPE_MAX) &&
 	   (!wo->wo_pid || hlist_empty(&wo->wo_pid->tasks[wo->wo_type])))
-		goto end;
+		goto notask;
 
 	current->state = TASK_INTERRUPTIBLE;
 	read_lock(&tasklist_lock);
 	tsk = current;
 	do {
-		int tsk_result = do_wait_thread(wo, tsk);
-
-		if (!tsk_result)
-			tsk_result = ptrace_do_wait(wo, tsk);
+		retval = do_wait_thread(wo, tsk);
+		if (retval)
+			goto end;
 
-		if (tsk_result) {
-			/*
-			 * tasklist_lock is unlocked and we have a final result.
-			 */
-			retval = tsk_result;
+		retval = ptrace_do_wait(wo, tsk);
+		if (retval)
 			goto end;
-		}
 
 		if (wo->wo_flags & __WNOTHREAD)
 			break;
@@ -1605,6 +1600,7 @@ repeat:
 	} while (tsk != current);
 	read_unlock(&tasklist_lock);
 
+notask:
 	retval = wo->notask_error;
 	if (!retval && !(wo->wo_flags & WNOHANG)) {
 		retval = -ERESTARTSYS;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
do_wait: simplify retval/tsk_result/notask_error mess, Linux Kernel Mailing ..., (Thu Jun 18, 3:00 pm)