Re: [git pull] scheduler updates

From: Ingo Molnar
Date: Sat Nov 08 2008 - 13:52:59 EST



* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Sat, 8 Nov 2008, Ingo Molnar wrote:
> >
> > Ingo Molnar (2):
> > sched: improve sched_clock() performance
> > sched: optimize sched_clock() a bit
>
> Btw, why do we do that _idiotic_ rdtsc_barrier() AT ALL?
>
> No sane user can possibly want it. If you do 'rdtsc', there's
> nothing you can do about a few cycles difference due to OoO
> _anyway_. Adding barriers is entirely meaningless - it's not going
> to make the return value mean anything else.
>
> Can we please just remove that idiocy? Or can somebody give a _sane_
> argument for it?

yeah, i had the same thinking, so i zapped it for everything but the
vdso driven vgettimeofday GTOD method.

For that one, i chickened out, because we have this use in
arch/x86/kernel/vsyscall_64.c:

now = vread();
base = __vsyscall_gtod_data.clock.cycle_last;
mask = __vsyscall_gtod_data.clock.mask;
mult = __vsyscall_gtod_data.clock.mult;
shift = __vsyscall_gtod_data.clock.shift;

which can be triggered by gettimeofday() on certain systems.

And i couldnt convince myself that this sequence couldnt result in
userspace-observable GTOD time warps there, so i went for the obvious
fix first.

If the "now = vread()"'s RDTSC instruction is speculated to after it
reads cycle_last, and another vdso call shortly after this does
another RDTSC in this same sequence, the two RDTSC's could be mixed up
in theory, resulting in negative time?

I _think_ i heard some noises in the past that this could indeed
happen (and have vague memories that this was the justification for
the barrier's introduction), but have to check the old emails to
figure out what exactly the issue was and on what CPUs.

It's not completely impossible for this to happen, as the vdso calls
are really just simple function calls, so not nearly as strongly
serialized as say a real syscall based gettimeofday() call.

In any case, it failed my "it must be obvious within 1 minute for it
to be eligible for sched/urgent" threshold and i didnt want to
introduce a time warp.

But you are right, and i've queued up the full fix below as well, as a
reminder.

Ingo

----------------->