]> git.baikalelectronics.ru Git - kernel.git/commit
x86/vdso: Rearrange do_hres() to improve code generation
authorAndy Lutomirski <luto@kernel.org>
Fri, 5 Oct 2018 18:02:43 +0000 (11:02 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 5 Oct 2018 19:03:23 +0000 (21:03 +0200)
commit3dbc4b244a638652d21d69dac5a31d687e9cd466
tree04b6857951f16045aa7970c487ef1ae578e6c7d8
parent38178216a703a046fa455877340b993a5c2b229e
x86/vdso: Rearrange do_hres() to improve code generation

vgetcyc() is full of barriers, so fetching values out of the vvar
page before vgetcyc() for use after vgetcyc() results in poor code
generation.  Put vgetcyc() first to avoid this problem.

Also, pull the tv_sec division into the loop and put all the ts
writes together.  The old code wrote ts->tv_sec on each iteration
before the syscall fallback check and then added in the offset
afterwards, which forced the compiler to pointlessly copy base->sec
to ts->tv_sec on each iteration.  The new version seems to generate
sensible code.

Saves several cycles.  With this patch applied, the result is faster
than before the clock_gettime() rewrite.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/3c05644d010b72216aa286a6d20b5078d5fae5cd.1538762487.git.luto@kernel.org
arch/x86/entry/vdso/vclock_gettime.c