From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Peter Williams <pwil3058@bigpond.net.au>
Cc: "Chen, Kenneth W" <kenneth.w.chen@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: bug in sched.c:task_hot()
Date: Tue, 05 Oct 2004 18:42:53 +1000 [thread overview]
Message-ID: <41625E8D.2070101@yahoo.com.au> (raw)
In-Reply-To: <4162565F.60007@bigpond.net.au>
Peter Williams wrote:
> Nick Piggin wrote:
>
>> Peter Williams wrote:
>>
>>>
>>> The interesting question is: How does now get to be less than
>>> timestamp? This probably means that timestamp_last_tick is not a
>>> good way of getting a value for "now".
>>
>>
>>
>> It is the best we can do.
>
>
> You could use sched_clock() which will do better. The setting of
> timestamp in schedule() gives you a pretty good chance that it's value
> will be greater than timestamp_last_tick.
>
sched_clock is not guaranteed to be synchronised across CPUs though.
It may be completely different. So even if you did use sched_clock,
you'd still have to apply the timestamp_last_tick adjustment.
Considering that we really don't need sched_clock resolution here,
it just isn't needed.
Kenneth's overflow fix is definitely required though, even if you
were to use sched_clock.
>>
>>> By the way, neither is sched_clock() when measuring small time
>>> differences as it is not monotonic (something that I had to allow for
>>> in my scheduling code).
>>
>>
>>
>> I'm pretty sure it is monotonic, actually. I know some CPUs can execute
>> rdtsc speculatively, but I don't think it would ever be sane to execute
>> two rdtsc's in the wrong order.
>
Hmm, there may be some jitter when waking a process from a remote
CPU - because in that case, we do have to apply the timestamp_last_tick
correction.
>
> I have experienced it going backwards and I assumed that it was due to
> the timing code applying corrections. (You've got two choices if your
> clock is running fast: one is to mark time until the real world catches
> up with you and the other is to set your clock back to the correct time
> when you notice a discrepancy. I assumed that the second strategy had
> been followed by the time code and didn't bother checking further
> because it was an easy problem to sidestep.) Admittedly, this behaviour
We don't really care what real time is doing here, just so long as the
numbers returned are roughly the same for everyone (all processes).
> was only observed when measuring very short times such as the time spent
> on the runqueue waiting for CPU access when the system was idle BUT it
> was definitely occurring. And it only occurred on a system where the
> lower bits of the values returned by sched_clock() were not zero i.e. a
> reasonably modern one. It was observed on a single CPU machine as well
> and was not, therefore, a result of drift between CPUs.
I don't see how this could happen on a single CPU system. I can
believe you saw it though.
next prev parent reply other threads:[~2004-10-05 8:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-05 2:38 bug in sched.c:task_hot() Chen, Kenneth W
2004-10-05 3:17 ` Nick Piggin
2004-10-05 17:15 ` Chen, Kenneth W
2004-10-05 7:33 ` Peter Williams
2004-10-05 7:44 ` Nick Piggin
2004-10-05 8:07 ` Peter Williams
2004-10-05 8:42 ` Nick Piggin [this message]
2004-10-05 10:03 ` Peter Williams
2004-10-05 17:39 ` Chen, Kenneth W
2004-10-05 22:09 ` Peter Williams
2004-10-05 8:03 ` Ingo Molnar
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=41625E8D.2070101@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=kenneth.w.chen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pwil3058@bigpond.net.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