From: Andrea Arcangeli <andrea@suse.de>
To: Rik van Riel <riel@conectiva.com.br>
Cc: Peter Osterlund <peter.osterlund@mailbox.swipnet.se>,
Linus Torvalds <torvalds@transmeta.com>,
Mark Hahn <hahn@coffee.psychology.mcmaster.ca>,
"Adam J. Richter" <adam@yggdrasil.com>,
linux-kernel@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: 2.4.4 sluggish under fork load
Date: Tue, 1 May 2001 18:55:17 +0200 [thread overview]
Message-ID: <20010501185517.A31373@athlon.random> (raw)
In-Reply-To: <20010430195149.F19620@athlon.random> <Pine.LNX.4.21.0104302335490.19012-100000@imladris.rielhome.conectiva> <20010501071849.A16474@athlon.random>
In-Reply-To: <20010501071849.A16474@athlon.random>; from andrea@suse.de on Tue, May 01, 2001 at 07:18:49AM +0200
On Tue, May 01, 2001 at 07:18:49AM +0200, Andrea Arcangeli wrote:
> I'm running with this below patch applied since a some time (I didn't
> submitted it because for some reason unless I do p->policy &=
> ~SCHED_YIELD ksoftirqd deadlocks at boot and I didn't yet investigated
> why, and I'd like to have the whole picture on it first):
OK I found the explanation now. The reason ksoftirqd was deadlocking on
me without the explicit clear of SCHED_YIELD in p->policy is because a
softirq event was pending at the time of the first kernel_thread() and
then while returning from the syscall it was so taking the ret_from_irq
path that skips the reschedule [which was supposed to clear the
sched_yield and to reschedule the child] because CS was pointing to the
kernel descriptor. So init then runs with SCHED_YIELD set and when it
executes kernel_thread(ksoftirqd) also ksoftirqd inherit SCHED_YIELD set
too (copied at top of do_fork) and it never gets scheduled -> deadlock.
Basically there's no guarantee that any kernel_thread will return with
SCHED_YIELD cleared.
And if you fork off a child with its p->policy SCHED_YIELD set it will
never get scheduled in.
Only "just" running tasks can have SCHED_YIELD set.
So the below lines are the *right* and most robust approch as far I can
tell. (plus counter needs to be volatile, as every variable that can
change under the C code, even while it's probably not required by the
code involved with current->counter)
> + {
> + int counter = current->counter >> 1;
> + current->counter = p->counter = counter;
> + p->policy &= ~SCHED_YIELD;
> + current->policy |= SCHED_YIELD;
> + current->need_resched = 1;
> + }
Alan, the patch you merged in 2.4.4ac2 can fail like mine, but it may fail in
a much more subtle way, while I notice if ksoftirqd never get scheduled
because I synchronize on it and I deadlock, your kupdate/bdflush/kswapd
may be forked off correctly but they can all have SCHED_YIELD set and
they will *never* get scheduled. You know what can happen if kupdate
never gets scheduled... I recommend to be careful with 2.4.4ac2.
My patch (part of it quoted above) is the right replacement for the code
in 2.4.4ac2 (you may want to do `counter = current->counter + 1 >> 1'
tricks additionally to that, I will change it a bit too for that minor
part.
Andrea
next prev parent reply other threads:[~2001-05-01 16:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.21.0104281928080.10759-100000@penguin.transmeta.com>
2001-04-29 8:26 ` 2.4.4 sluggish under fork load Peter Osterlund
2001-04-30 17:51 ` Andrea Arcangeli
2001-04-30 21:45 ` Peter Osterlund
2001-05-01 2:38 ` Rik van Riel
2001-05-01 5:18 ` Andrea Arcangeli
2001-05-01 16:55 ` Andrea Arcangeli [this message]
2001-05-01 17:33 ` J . A . Magallon
2001-05-01 20:34 ` Alan Cox
2001-05-03 14:02 Hubertus Franke
-- strict thread matches above, loose matches on Subject: below --
2001-05-01 4:18 Adam J. Richter
2001-04-29 8:04 Adam J. Richter
2001-04-29 7:14 Adam J. Richter
2001-04-28 11:52 Peter Osterlund
2001-04-28 14:16 ` J . A . Magallon
2001-04-28 14:26 ` Mohammad A. Haque
2001-04-28 15:07 ` Rene Puls
2001-04-28 17:10 ` John Kacur
2001-04-28 18:00 ` Peter Osterlund
2001-04-28 17:54 ` Linus Torvalds
2001-04-28 19:14 ` Peter Osterlund
2001-04-28 20:00 ` Harald Dunkel
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=20010501185517.A31373@athlon.random \
--to=andrea@suse.de \
--cc=adam@yggdrasil.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=hahn@coffee.psychology.mcmaster.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.osterlund@mailbox.swipnet.se \
--cc=riel@conectiva.com.br \
--cc=torvalds@transmeta.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