public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Buytaert_Steven@emc.com, andi@firstfloor.org,
	linux-kernel@vger.kernel.org
Subject: Re: sched_yield proposals/rationale
Date: Thu, 12 Apr 2007 15:00:15 -0700	[thread overview]
Message-ID: <20070412220015.GG2986@holomorphy.com> (raw)
In-Reply-To: <461E33BA.2030104@yahoo.com.au>

On Thu, Apr 12, 2007 at 11:27:22PM +1000, Nick Piggin wrote:
> This one should be pretty rare (actually I think it is dead code in 
> practice, due to the way the page allocator works).
> Avoiding sched_yield is a really good idea outside realtime scheduling. 
> Since we have gone this far with the current semantics, I think it
> would be sad to back down now.
> It would be nice if you could pressure those other components to adapt :)

Outside of realtime scheduling there appear to be two desired behaviors:
(1) busywait: demote as aggressively as possible
(2) CPU burn: give other apps a chance to run but demote lightly at most

There is no way for the scheduler to distinguish which of the two
behaviors is desired. A fresh system call taking an argument to describe
which is the desired behavior is my recommended solution. Most unaware
apps should be able to be dealt with via LD_PRELOAD.

Busywaiters able to be modified could be given more specific scheduling
primitives, in particular "directed yields," which donate timeslice and
possibly dynamic priority to their targets. They would look something
like:
	int yield_to(pid_t);
	int yield_to_futex(int *);
	int yield_to_sem(int);
	/* etc. */
as userspace library functions where yielding to a resource is intended
to donate timeslice to its owner or one of its owners, where those
owner(s) are to be determined by the kernel. Directed yields are a more
direct attack on the priority inversion one most desperately wants to
avoid in the case of sched_yield() -based busywaiters on a resource,
namely the resource owner falling behind the busywaiters in priority or
running out of timeslice. They furthermore reduce the competition for
CPU between resource owners and busywaiters on that resource.

A less direct alternative suggested by Andi Kleen is to have coprocess
groups and an alternative to sched_yield() that directs yielding toward
a member of the same coprocess group as the yielder, possibly using the
standard system call by making that the default behavior when a process
is a member of such a coprocess group.


-- wli

  reply	other threads:[~2007-04-12 22:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-12  8:31 sched_yield proposals/rationale Buytaert_Steven
2007-04-12  9:48 ` Sven-Thorsten Dietrich
2007-04-12 13:31 ` Andi Kleen
2007-04-12 13:05   ` Buytaert_Steven
2007-04-12 13:27     ` Nick Piggin
2007-04-12 22:00       ` William Lee Irwin III [this message]
2007-04-12 13:31     ` Andi Kleen
2007-04-12 14:15       ` Buytaert_Steven
2007-04-12 21:04         ` Thomas Gleixner
2007-04-12 22:32         ` Bill Davidsen
2007-04-13  5:36           ` Buytaert_Steven
2007-04-13 19:46             ` Mark Lord
2007-04-17 19:37               ` Bill Davidsen
2007-04-18  5:40                 ` Buytaert_Steven
2007-04-12 21:37   ` William Lee Irwin III

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=20070412220015.GG2986@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=Buytaert_Steven@emc.com \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    /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