Re: [PATCH v4 0/6] Micro-optimize vclock_gettime

From: Andrew Lutomirski
Date: Tue May 17 2011 - 23:18:32 EST


On Tue, May 17, 2011 at 6:59 PM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> On Tue, 17 May 2011, Andi Kleen wrote:
>> Andy Lutomirski <luto@xxxxxxx> writes:
>> >
>> > On KVM on Sandy Bridge, I can emulate a vsyscall that does nothing in 400ns or so.  I'll try to make this code emulate real vsyscalls over the weekend.  This was much easier than I expected.
>>
>> How about the performance of all the statically linked programs? I guess
>
> _ALL_ the statically linked programs? Point out a single one which
> matters and _IS_ performance critical.
>
>> you just declared they don't matter? gettimeofday is quite critical
>> and adding a exception into it is just a performance desaster.
>>
>> Also it's always a dangerous assumption to think that all
>> programs on Linux use glibc ("all world is a Vax")
>>
>> In fact more and more of Linux users are using different libcs these
>> days (like Android or embedded systems or languages with special runtime
>> systems) Who knows if all those other libraries use vDSO?
>
> Which is completely irrelevant to x86_64. Point to a single relevant
> x86_64 embedded system to which one of the above handwaving applies.
>
>> And then there are of course the old glibcs. A lot of people
>> (including me) use new kernels with old userland.
>
> And how is your use case performance critical ?
>
> Furthermore any halfways up to date deployemnt is using VDSO for
> obvious reasons and the archaic stuff which might be affected is not
> using a recent kernel at all (except for akpm on his retro laptop, but
> that "performance penalty" is probably the least of his worries).

Sadly that's not quite true. glibc git right now contains this:

ENTRY (__gettimeofday)
/* Align stack. */
sub $0x8, %rsp
cfi_adjust_cfa_offset(8)
#ifdef SHARED
movq __vdso_gettimeofday(%rip), %rax
PTR_DEMANGLE (%rax)
#else
movq $VSYSCALL_ADDR_vgettimeofday, %rax
#endif
callq *%rax

And time() and sched_getcpu() call the vsyscall page unconditionally.
We should either declare CLOCK_REALTIME_COARSE to be acceptable for
time() or add a new vDSO call.

IMO we should put a note in feature-removal-schedule.txt, add vsyscall
emulation as a config option for 2.6.41 but leave it turned off by
default, and turn it on by default (or just remove the old code) in
2.6.43 or so. That'll give glibc a chance to stop generating *new*
static binaries that call it.

I'm not volunteering to dig around the libdl stuff to fix it myself.

klibc doesn't seem to use vsyscalls or the vDSO. I haven't looked at
uclibc, and I don't think that Bionic has any released version on
x86_64.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/