From: Linus Torvalds <torvalds@osdl.org>
To: Sripathi Kodi <sripathik@in.ibm.com>
Cc: linux-kernel@vger.kernel.org, Roland McGrath <roland@redhat.com>,
Ingo Molnar <mingo@elte.hu>, Andrew Morton <akpm@osdl.org>,
dino@in.ibm.com
Subject: Re: [PATCH] do_wait fix for 2.6.10-rc1
Date: Mon, 8 Nov 2004 08:01:37 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.58.0411080744320.24286@ppc970.osdl.org> (raw)
In-Reply-To: <418F826C.2060500@in.ibm.com>
On Mon, 8 Nov 2004, Sripathi Kodi wrote:
>
> Thanks for your suggestions. I have attached the re-done patch. I have
> implemented your first suggestion because it was much easier. I hope it
> looks better now.
Hmm.. I'm a grumpy old man, and I'm not happy yet. Feel free to explain to
me why I'm wrong, though - I don't mind.
> --- linux-2.6.10-rc1/kernel/exit.c 2004-11-08 23:38:17.358375128 +0530
> +++ /home/sripathi/12013/patch/take2/exit.c 2004-11-08 23:33:44.973783880 +0530
> @@ -1345,8 +1345,10 @@ repeat:
> break;
> default:
> // case EXIT_DEAD:
> - if (p->exit_state == EXIT_DEAD)
> - continue;
> + if (p->exit_state == EXIT_DEAD) {
> + current->state = TASK_RUNNING;
> + break;
> + }
Why here? We haven't actually released the lock, so I don't see why we'd
consider this a special case..
That said, I wonder if we should consider this kind of task non-eligible.
It may well be a bug to consider a EXIT_DEAD child to be eligible for
waiting, since we can't actually ever reap it any more. So maybe you found
a bug, but the fix might be to check this case in "eligible_child()"?
Roland?
> // case EXIT_ZOMBIE:
> if (p->exit_state == EXIT_ZOMBIE) {
> /*
> @@ -1363,6 +1365,7 @@ repeat:
> /* He released the lock. */
> if (retval != 0)
> goto end;
> + current->state = TASK_RUNNING;
> break;
> }
There are cases where 'wait_task_zombie()' will return 0 _without_
releasing the lock, and you now made those be busy-loops (with a
"schedule()", so the machine still works, it just eats CPU time like mad).
I think the _real_ case is the "wait_noreap_copyout()", case, but that
already returns non-zero in case it released the lock, so it looks all
good already.
In fact, I think the only case we care about is actually in
wait_task_stopped(), in the "bail_ref:" case. That's where we have
released the lock and potentially another process came in and reaped it,
but we still return zero.
That case should set itself to running, so that we don't sleep forever.
In fact, it looks like the "bail_ref" case has _another_ bug: since it
returns zero, we may still be _using_ the task pointer (to get to the next
task), so we must NOT do a "put_task_struct()" intil we've re-acquired the
tasklist_lock.
And I think _those_ two things were the real bugs. Does this patch fix it
for you?
Roland, I'd still love to hear your input on the EXIT_DEAD case. Is it
reapable?
Linus
-----
===== kernel/exit.c 1.166 vs edited =====
--- 1.166/kernel/exit.c 2004-11-04 11:13:19 -08:00
+++ edited/kernel/exit.c 2004-11-08 08:00:12 -08:00
@@ -1200,8 +1200,10 @@
*/
write_unlock_irq(&tasklist_lock);
bail_ref:
- put_task_struct(p);
read_lock(&tasklist_lock);
+ put_task_struct(p);
+ /* When the waiter does a sched(), we need to re-start the loop! */
+ current->state = TASK_RUNNING;
return 0;
}
next prev parent reply other threads:[~2004-11-08 19:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-05 9:57 Sripathi Kodi
2004-11-05 10:03 ` Ingo Molnar
[not found] ` <Pine.LNX.4.58.0411051101500.30457@ppc970.osdl.org>
2004-11-08 14:27 ` Sripathi Kodi
2004-11-08 16:01 ` Linus Torvalds [this message]
2004-11-08 16:13 ` Linus Torvalds
2004-11-08 16:37 ` Linus Torvalds
2004-11-09 1:09 ` Linus Torvalds
2004-11-09 14:31 ` Dinakar Guniguntala
2004-11-09 16:11 ` Linus Torvalds
2004-11-10 14:35 ` Dinakar Guniguntala
2004-11-10 17:04 ` Linus Torvalds
2004-11-11 11:20 ` Sripathi Kodi
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=Pine.LNX.4.58.0411080744320.24286@ppc970.osdl.org \
--to=torvalds@osdl.org \
--cc=akpm@osdl.org \
--cc=dino@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=sripathik@in.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®