public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Definition of sched_clock broken
@ 2008-09-23 21:04 Jeremy Fitzhardinge
  2008-10-08 12:59 ` Dave Kleikamp
  0 siblings, 1 reply; 10+ messages in thread
From: Jeremy Fitzhardinge @ 2008-09-23 21:04 UTC (permalink / raw)
  To: Peter Zijlstra, Steven Rostedt; +Cc: Ingo Molnar, Linux Kernel Mailing List

kernel/sched_clock.c has the comment:

 * The clock: sched_clock_cpu() is monotonic per cpu, and should be somewhat
 * consistent between cpus (never more than 2 jiffies difference).


The two jiffy restriction is way too restrictive.

Historically sched_clock() is intended to measure the amount of
schedulable time occurring on a CPU.  On a virtual cpu, that is affected
by the amount of physical cpu time the hypervisor schedules for a vcpu,
and can therefore advance in a very non-continuous way, depending on the
overall load on the host system.  It is, however, the only timebase that
gives the kernel a reasonable hope of determining how much cpu a process
actually got scheduled.

The net result is that the sched_clock timebase is 1) monotonic, 2)
loses arbitrary amounts of time against a system monotonic clock, 3)
per-cpu, with 4) arbitrary drift between different cpu's sched_clocks.

Tying the sched_clocks of different cpus together in any way loses these
properties, and just turns it into another system wide monotonic clock,
which seems redundant given that we already have one (I understand that
the relatively loose synchronization allows it to be implemented more
efficiently than a normal monotonic clock).

At the moment the x86 sched_clock is hooked through paravirt_ops so that
the underlying hypervisor can provide precise scheduled time
information, with the hope that the scheduler will use it to make better
decisions.  However if the scheduler needs to be lied to then I can do
that too, but it's a pity to throw away information that's available to it.

    J

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-10-10  9:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-23 21:04 Definition of sched_clock broken Jeremy Fitzhardinge
2008-10-08 12:59 ` Dave Kleikamp
2008-10-08 13:00   ` [PATCH] sched_clock: prevent scd->clock from moving backwards Dave Kleikamp
2008-10-08 23:05     ` Peter Zijlstra
2008-10-09  9:06       ` Ingo Molnar
2008-10-09 15:17         ` Ingo Molnar
2008-10-09 17:54           ` Dave Kleikamp
2008-10-09 18:21             ` Dave Kleikamp
2008-10-10  9:17               ` Ingo Molnar
2008-10-09 21:22             ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox