From: Helge Hafting <helge.hafting@aitel.hist.no>
To: Leon Woestenberg <leon.woestenberg@gmail.com>
Cc: 7eggert@gmx.de, Peter Zijlstra <a.p.zijlstra@chello.nl>,
Jakub Jozwicki <jozwicki@aster.pl>,
linux-kernel@vger.kernel.org, Robert Hancock <hancockr@shaw.ca>
Subject: Re: sched_yield() on 2.6.25
Date: Thu, 12 Jun 2008 10:09:16 +0200 [thread overview]
Message-ID: <4850D9AC.3040706@aitel.hist.no> (raw)
In-Reply-To: <c384c5ea0806111545g6e6128bek519ce6022a301339@mail.gmail.com>
Leon Woestenberg wrote:
[...]
> That's not the definition of sched_yield(). See the earlier emails,
> and the quote above.
>
> As the code after sched_yield() has to be executed the thread will be
> rescheduled soon (or even immediately) anyway.
>
> The users not understanding the limited scope where sched_yield()
> behaves deterministicly, seem to think that _yield() will yield() AND
> lower the thread's dynamic priority for SCHED_OTHER. Is downgrading
> the dynamic priority a behavioral option?
>
That can be done of course, but that too will cause breakage.
Consider a multithreaded app mistakenly relying on sched_yield.
Priority downgrading might work really well as long as this app runs alone,
the yielding thread stops and the others progress, so sched_yield works
for "userspace locking". And it works so well, the app uses it a lot.
Then someone recompiles the distro or runs some other kinds of cpu hogs
that drives the load well above 1. Users expect the apps to run a little
slower because of this. But a load of 5 still ought to give you 1/5
of the cpu - and with today's CPU's that might still be better than
a 5-year old machine. Interactive software should almost not notice,
as it don't use the cpu that much anyway - and it gets priority over
cpu hogs when it occationally needs to do something.
But now this multithreaded app practically
stops because it yields a lot - an everytime it lowers its priority
below not only its own other threads, but below the various
cpu hogs as well. (Compilers gets dynamic boosts too, as they
wait a little for the disk now and then. A parallel compile still
keeps the total load high.)
I remember seeing openoffice taking 5min to start some years ago,
with a compile going on. Of course there were other problems
like swapping and a smaller computer, but other apps were merely slow,
not that glacial.
> On the other hand, I don't think anything should encourage the use of
> sched_yield() outside of the rare SCHED_FIFO/RR case.
>
Exactly. There seems to be no way to make sched_yield work "as expected"
for all the ways it is abused, so better use something else.
Helge Hafting
next prev parent reply other threads:[~2008-06-12 8:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <aCBfw-3Cv-23@gated-at.bofh.it>
[not found] ` <aCBfw-3Cv-21@gated-at.bofh.it>
[not found] ` <aCJd6-3IF-11@gated-at.bofh.it>
[not found] ` <aCRaM-8cM-33@gated-at.bofh.it>
2008-06-11 15:28 ` sched_yield() on 2.6.25 Bodo Eggert
2008-06-11 22:45 ` Leon Woestenberg
2008-06-12 8:09 ` Helge Hafting [this message]
2008-06-12 22:33 ` Bodo Eggert
2008-06-13 8:37 ` Helge Hafting
[not found] <fa.5iKTy3xTJkKWZLGio+GIHXi3+0o@ifi.uio.no>
2008-06-08 22:09 ` Robert Hancock
2008-06-09 6:37 ` Jakub Jozwicki
2008-06-09 9:03 ` Helge Hafting
2008-06-09 15:04 ` Peter Zijlstra
2008-06-08 11:34 Jakub W. Jozwicki
2008-06-09 9:35 ` Andrew Morton
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=4850D9AC.3040706@aitel.hist.no \
--to=helge.hafting@aitel.hist.no \
--cc=7eggert@gmx.de \
--cc=a.p.zijlstra@chello.nl \
--cc=hancockr@shaw.ca \
--cc=jozwicki@aster.pl \
--cc=leon.woestenberg@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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