public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bill Davidsen <davidsen@tmr.com>
To: linux-kernel@vger.kernel.org
To: George Anzinger <george@mvista.com>
Cc: Nick Piggin <piggin@cyberone.com.au>,
	Guillaume Foliard <guifo@wanadoo.fr>,
	linux-kernel@vger.kernel.org
Subject: Re: Scheduler degradation since 2.5.66
Date: Wed, 14 Jan 2004 19:43:56 -0500	[thread overview]
Message-ID: <4005E24C.2030807@tmr.com> (raw)
In-Reply-To: <3FDE5449.60507@mvista.com>

George Anzinger wrote:

> We get the request at some time t between tick tt and tt+1 to sleep for 
> N ticks.
> We round this up to the next higher tick count convert to jiffies 
> dropping any fraction and then add 1.  So that should be 2 right?  This 
> is added to NOW which, in the test code, is pretty well pined to the 
> last tick plus processing time.  So why do you see 3?
> 
> What is missing here is that the request was for 1.000000 ms and a tick 
> is really 0.999849 ms.  So the request is for a bit more than a tick 
> which we are obligated to round up to 2 ticks.  Then adding the 1 tick 
> guard we get the 3 you are seeing.  Now if you actually look at that 
> elapsed time you should see it at about 2.999547 ms and ranging down to 
> 1.999698 ms.

Clearly the rounding between what you want and the resolution of the 
hardware tick is never going to be perfect if there is a non-integer 
ratio between the values. If this is a real concern, you can play with 
the algorithm and/or go to a faster clock. Or both.

You might also be much happier simply setting target times 2ms apart, 
and sleeping for target-NOW ns. That allows for the processing time.

If the kernel had a better idea of when the next tick would be instead 
of assuming counting from NOW instead of "last tick" you could probably 
do better, but I'm not suggesting that overhead be added to the ticks 
code in case someone needs a better nanosleep. I don't know how well 
that would work in the SMP case in any event. Sort of
   wait_ticks = 1 + int((NOW + delay - time_since_last_tick)/ns_per_tick)
or
   wait_ticks =
     int((NOW-delay - time_since_tick + ns_per_tick - 1)/ns_per_tick)

I think there's too much caution about going over, but without playing 
with the code I'm just dropping ideas.
-- 
bill davidsen <davidsen@tmr.com>
   CTO TMR Associates, Inc
   Doing interesting things with small computers since 1979

  parent reply	other threads:[~2004-01-15  0:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-14 19:48 Scheduler degradation since 2.5.66 Guillaume Foliard
2003-12-15  2:45 ` Nick Piggin
2003-12-15  4:18   ` Nick Piggin
2003-12-16  0:39     ` George Anzinger
2003-12-16  0:52       ` Jamie Lokier
2003-12-16  7:45         ` George Anzinger
2004-01-15  0:43       ` Bill Davidsen [this message]
2004-01-15  3:36         ` George Anzinger

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=4005E24C.2030807@tmr.com \
    --to=davidsen@tmr.com \
    --cc=guifo@wanadoo.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=piggin@cyberone.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