powerpc: Convert VDSO update function to use new update_vsyscall interface
PATCH 1/1 powerpc: Convert VDSO update function to use new update_vsyscall interface
This converts the powerpc VDSO time update function to use the new interface introduced in commit 576094b7f0aa ("time: Introduce new GENERIC_TIME_VSYSCALL", 2012-09-11). Where the old interface gave us the time as of the last update in seconds and whole nanoseconds, with the new interface we get the nanoseconds part effectively in a binary fixed-point format with tk->tkr_mono.shift bits to the right of the binary point.
With the old interface, the fractional nanoseconds got truncated, meaning that the value returned by the VDSO clock_gettime function would have about 1ns of jitter in it compared to the value computed by the generic timekeeping code in the kernel.
The powerpc VDSO time functions (clock_gettime and gettimeofday) already work in units of 2^-32 seconds, or 0.23283 ns, because that makes it simple to split the result into seconds and fractional seconds, and represent the fractional seconds in either microseconds or nanoseconds. This is good enough accuracy for now, so this patch avoids changing how the VDSO works or the interface in the VDSO data page.
This patch converts the powerpc update_vsyscall_old to be called update_vsyscall and use the new interface. We convert the fractional second to units of 2^-32 seconds without truncating to whole nanoseconds. (There is still a conversion to whole nanoseconds for any legacy users of the vdso_data/systemcfg stamp_xtime field.)
In addition, this improves the accuracy of the computation of tb_to_xs for those systems with high-frequency timebase clocks (>= 268.5 MHz) by doing the right shift in two parts, one before the multiplication and one after, rather than doing the right shift before the multiplication. (We can't do all of the right shift after the multiplication unless we use 128-bit arithmetic.)
--- arch/powerpc/Kconfig | 2 +- arch/powerpc/kernel/time.c | 68 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 53 insertions(+), 17 deletions(-)
arch/powerpc/Kconfig +1 -1
@@ -163,7 +163,7 @@ config PPC select GENERIC_SMP_IDLE_THREAD select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER - select GENERIC_TIME_VSYSCALL_OLD + select GENERIC_TIME_VSYSCALL select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_KGDB
arch/powerpc/kernel/time.c +52 -16
95 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 27 lines · Paul Mackerras
This converts the powerpc VDSO time update function to use the new interface introduced in commit
576094b7f0aa("time: Introduce newGENERIC_TIME_VSYSCALL", 2012-09-11). Where the old interface gave us the time as of the last update in seconds and whole nanoseconds, with the new interface we get the nanoseconds part effectively in a binary fixed-point format withtk->tkr_mono.shiftbits to the right of the binary point.With the old interface, the fractional nanoseconds got truncated, meaning that the value returned by the VDSO
clock_gettimefunction would have about 1ns of jitter in it compared to the value computed by the generic timekeeping code in the kernel.The powerpc VDSO time functions (
clock_gettimeand gettimeofday) already work in units of 2^-32 seconds, or 0.23283 ns, because that makes it simple to split the result into seconds and fractional seconds, and represent the fractional seconds in either microseconds or nanoseconds. This is good enough accuracy for now, so this patch avoids changing how the VDSO works or the interface in the VDSO data page.This patch converts the powerpc
update_vsyscall_oldto be calledupdate_vsyscalland use the new interface. We convert the fractional second to units of 2^-32 seconds without truncating to whole nanoseconds. (There is still a conversion to whole nanoseconds for any legacy users of the vdso_data/systemcfgstamp_xtimefield.)
Quoted 8 lines
In addition, this improves the accuracy of the computation of
tb_to_xsfor those systems with high-frequency timebase clocks (>= 268.5 MHz) by doing the right shift in two parts, one before the multiplication and one after, rather than doing the right shift before the multiplication. (We can't do all of the right shift after the multiplication unless we use 128-bit arithmetic.)Signed-off-by Paul Mackerras <[email protected]>
Apologies again for missing this earlier.
So no objections from me. I can't say I really worked the whole thing out, but you're handling the xtime_nsec field properly and the rest looks reasonable and is well documented.
So for what its worth:
Thanks again for making this update!
-john
Quoted 34 lines · Paul Mackerras
This converts the powerpc VDSO time update function to use the new interface introduced in commit
576094b7f0aa("time: Introduce newGENERIC_TIME_VSYSCALL", 2012-09-11). Where the old interface gave us the time as of the last update in seconds and whole nanoseconds, with the new interface we get the nanoseconds part effectively in a binary fixed-point format withtk->tkr_mono.shiftbits to the right of the binary point.With the old interface, the fractional nanoseconds got truncated, meaning that the value returned by the VDSO
clock_gettimefunction would have about 1ns of jitter in it compared to the value computed by the generic timekeeping code in the kernel.The powerpc VDSO time functions (
clock_gettimeand gettimeofday) already work in units of 2^-32 seconds, or 0.23283 ns, because that makes it simple to split the result into seconds and fractional seconds, and represent the fractional seconds in either microseconds or nanoseconds. This is good enough accuracy for now, so this patch avoids changing how the VDSO works or the interface in the VDSO data page.This patch converts the powerpc
update_vsyscall_oldto be calledupdate_vsyscalland use the new interface. We convert the fractional second to units of 2^-32 seconds without truncating to whole nanoseconds. (There is still a conversion to whole nanoseconds for any legacy users of the vdso_data/systemcfgstamp_xtimefield.)In addition, this improves the accuracy of the computation of
tb_to_xsfor those systems with high-frequency timebase clocks (>= 268.5 MHz) by doing the right shift in two parts, one before the multiplication and one after, rather than doing the right shift before the multiplication. (We can't do all of the right shift after the multiplication unless we use 128-bit arithmetic.)
Quoted 2 lines
Signed-off-by Paul Mackerras <[email protected]>Acked-by John Stultz <[email protected]>
Applied to powerpc next-test, thanks.
https://git.kernel.org/powerpc/c/d4cfb11387ee29ba4626546c676fd2
cheers