From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>, Roland McGrath <roland@redhat.com>,
Vitaly Mayatskikh <vmayatsk@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] do_wait: simplify retval/tsk_result/notask_error mess
Date: Thu, 7 May 2009 08:46:41 +0200 [thread overview]
Message-ID: <20090507064641.GA15864@redhat.com> (raw)
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>
---
kernel/exit.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
--- PTRACE/kernel/exit.c~3_RETVAL 2009-05-07 04:37:49.000000000 +0200
+++ PTRACE/kernel/exit.c 2009-05-07 05:09:51.000000000 +0200
@@ -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;
next reply other threads:[~2009-05-07 6:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 6:46 Oleg Nesterov [this message]
2009-05-07 7:26 ` [PATCH 3/5] do_wait: simplify retval/tsk_result/notask_error mess Roland McGrath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090507064641.GA15864@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=vmayatsk@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.