Trivial patch about "Use CLOCK_MONOTONIC_RAW if available"
David Holmes
david.holmes at oracle.com
Fri Jan 25 01:05:35 PST 2013
Hi,
On 25/01/2013 5:42 PM, liang xie wrote:
> Hi,
>
> I'm not familiar hotspot dev flow and i don't know how to make a webcr:)
> please feel free to move it to the correct list if wrong.
This list is fine. It could have gone to hotspot-runtime-dev but broder
coverage is fine for this.
> "CLOCK_MONOTONIC_RAW" is available from 2.6.28+, it's a better choice while
> ntp
> slew happened againt CLOCK_MONOTONIC_RAW. This's important for some
> applications, e.g. zookeeper. Please see zookeeper--1616 for details.
>
>
> diff -r 8389681cd7b1 src/os/linux/vm/os_linux.cpp
> --- a/src/os/linux/vm/os_linux.cpp Tue Nov 15 16:44:09 2011 -0800
> +++ b/src/os/linux/vm/os_linux.cpp Fri Jan 25 15:14:55 2013 +0800
> @@ -1444,7 +1444,11 @@
> jlong os::javaTimeNanos() {
> if (Linux::supports_monotonic_clock()) {
> struct timespec tp;
> + #ifdef CLOCK_MONOTONIC_RAW
> + int status = Linux::clock_gettime(CLOCK_MONOTONIC_RAW,&tp);
> + #else
> int status = Linux::clock_gettime(CLOCK_MONOTONIC,&tp);
> + #endif
> assert(status == 0, "gettime error");
> jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) +
> jlong(tp.tv_nsec);
> return result;
Unfortunately today our primary linux build platform is still at 2.6.27
so this would have to wait until we officially update that.
But also we need to be able to run on earlier versions so this would
have to involve a dynamic runtime check not a simple compile-time check.
I've created 8006942 to track this. It will appear on bugs.sun.com in
the next day or so.
Thanks,
David Holmes
More information about the hotspot-dev
mailing list