Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8006942

Use CLOCK_MONOTONIC_RAW for nanoTime if available on Linux

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 10
    • 9
    • hotspot

      On 25/01/2013 5:42 PM, liang xie wrote:
      > "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 version so this would have to involve a dynamic runtime check not a simple compile-time check.

            dholmes David Holmes
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: