linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: David Woodhouse <dwmw2@infradead.org>
Cc: linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	arjan@infradead.org
Subject: Re: [RFC] schedule_timeout_range()
Date: Tue, 22 Jul 2008 14:33:32 +1000	[thread overview]
Message-ID: <200807221433.32412.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <1216699922.18980.66.camel@shinybook.infradead.org>

On Tuesday 22 July 2008 14:12, David Woodhouse wrote:
> On Tue, 2008-07-22 at 13:56 +1000, Nick Piggin wrote:
> > Rather than specific "deadline" values (which we can't guarantee anyway),
> > or vague "can defer" values,
>
> We already _have_ those vague 'can defer' timers. They'll get run the
> next time the CPU happens to be awake after they expire.

Right, but that may be too vague to be really useful. OK, not exactly:
as with anything, if we really need an exact response, we have to wait
with interrupts disabled etc. However I don't think it would hurt to
get away from the all or nothing approach with future APIs that are added
(eventually the old ones could just be implemented over the new).


> >  I would prefer just a small selection of maybe orders of magnitude
> > flags, maybe SECONDS, MILLISECONDS, MICROSECONDS which gives an amount
> > of delay the kernel might add to the timer.
>
> As far as I can tell, any implementation of that ends up being converted
> into what we have at the moment -- a deferrable timer which gets run
> some time after it expires, and a timer which would actually _wake_ a
> sleeping CPU. You have to create a value for that final timer anyway, so
> why not just let the in-kernel caller provide it?

That is a fair point.


> There's no point in trying to coalesce the 'final' timeouts; if just one
> of them wakes the CPU and we're in the range for any other 'range
> timers', those others will happy immediately anyway.

Sure.


> We did ponder the idea of a per-process setting which affects userspace
> delays like nanosleep/poll/select, and introduces a variable extra delay
> if the CPU is actually sleeping. So we can reduce the number of CPU
> wakeup events for thosee userspace apps which aren't timing-sensitive.

Not such a bad idea. Maybe also something to think about adding explicitly
to future syscalls (if not a complete new parameter for delay time, then
at least a flag or two or different variants for different amounts of
accuracy). I guess select/poll is pretty widely used though, so there will
be some good gains just from a per-process setting.


> We were also thinking of extending nanosleep/ppoll/pselect also to take
> a 'range', for those cases where the process-wide setting needs to be
> overridden. The prctl is a simple solution which doesn't involve
> modifying large chunks of userspace to use new system calls, but it's
> not a panacea -- in some places, an app might _want_ a prompt wakeup.
>
> For kernel timers, though, I think it's better to let the caller set a
> non-deferrable timer at a specific time. Although you're right that
> 'deadline' is probably a bad name for it.
>
> How about 'start' and 'end'? Or 'early' and 'late'? I really don't care
> too much what it's called.

Well I think 'timeout' is fine for the "at least this much time", that's
well understood and used. As for the slop... slop? deferrable? Hmm,
precision might come pretty close to the engineering definition, no?

The only thing I dislike about explicit times is that when a driver or
someone doesn't _really_ know how much to specify. Do you say 10s, 100s?
It shouldn't be arbitrary, but we should have a few constants I think.

Some upper bound would be nice, which basically would not have to ever
fire by itself unless there is some CPU activity (so you don't have to
set two timers as a bonus). After that, I wonder, perhaps some "maximum
power savings value but not completely deferred"? Say give it a max of
30s? Or perhaps even that is not future-proof enough if we one day want
to suspend most of the system between external IOs?

if 

  parent reply	other threads:[~2008-07-22  4:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-22  3:02 [RFC] Imprecise timers David Woodhouse
2008-07-22  3:05 ` [RFC] schedule_timeout_range() David Woodhouse
2008-07-22  3:56   ` Nick Piggin
2008-07-22  4:12     ` David Woodhouse
2008-07-22  4:26       ` Arjan van de Ven
2008-07-22  4:34         ` David Woodhouse
2008-07-22  4:33       ` Nick Piggin [this message]
2008-07-22  4:45         ` David Woodhouse
2008-07-22  4:50           ` Nick Piggin
2008-07-22  4:58             ` David Woodhouse
2008-07-22  5:35               ` Jan Engelhardt
2008-07-22  4:33     ` Arjan van de Ven
2008-07-22  7:19 ` [RFC] Imprecise timers Rene Herman
2008-07-22 12:54   ` Arjan van de Ven
2008-07-22 14:04     ` Rene Herman
2008-07-29  0:36 ` Pallipadi, Venkatesh
2008-08-09 12:54   ` Pavel Machek
2008-08-11 17:35     ` Venki Pallipadi
2008-08-12 12:00       ` Pavel Machek
2008-08-12 18:11         ` Venki Pallipadi
2008-08-12 21:55           ` Alan Cox
2008-08-12 21:58           ` Pavel Machek
     [not found] <aSgqr-EJ-15@gated-at.bofh.it>
     [not found] ` <aShcU-3uj-11@gated-at.bofh.it>
     [not found]   ` <aShw5-4ai-9@gated-at.bofh.it>
     [not found]     ` <aShPs-4IY-1@gated-at.bofh.it>
2008-07-23 11:52       ` [RFC] schedule_timeout_range() Bodo Eggert
2008-07-24  0:53         ` Nick Piggin

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=200807221433.32412.nickpiggin@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=arjan@infradead.org \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).