8064471: Port 8013895: G1: G1SummarizeRSetStats output on Linux needs improvement to AIX
authorsimonis
Thu, 13 Nov 2014 16:58:56 +0100
changeset 27668 d373a4781717
parent 27667 3c814b51da6c
child 27669 c2c526bc1a18
child 27670 e86850ef14cf
8064471: Port 8013895: G1: G1SummarizeRSetStats output on Linux needs improvement to AIX Reviewed-by: dholmes, simonis Contributed-by: gunter.haug@sap.com
hotspot/src/os/aix/vm/os_aix.cpp
--- a/hotspot/src/os/aix/vm/os_aix.cpp	Mon Nov 17 11:26:43 2014 -0500
+++ b/hotspot/src/os/aix/vm/os_aix.cpp	Thu Nov 13 16:58:56 2014 +0100
@@ -107,6 +107,12 @@
 #include <sys/vminfo.h>
 #include <sys/wait.h>
 
+// If RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
+// getrusage() is prepared to handle the associated failure.
+#ifndef RUSAGE_THREAD
+#define RUSAGE_THREAD   (1)               /* only the calling thread */
+#endif
+
 // Add missing declarations (should be in procinfo.h but isn't until AIX 6.1).
 #if !defined(_AIXVERSION_610)
 extern "C" {
@@ -1072,15 +1078,19 @@
   return (1000 * 1000);
 }
 
-// For now, we say that linux does not support vtime. I have no idea
-// whether it can actually be made to (DLD, 9/13/05).
-
-bool os::supports_vtime() { return false; }
+bool os::supports_vtime() { return true; }
 bool os::enable_vtime()   { return false; }
 bool os::vtime_enabled()  { return false; }
+
 double os::elapsedVTime() {
-  // better than nothing, but not much
-  return elapsedTime();
+  struct rusage usage;
+  int retval = getrusage(RUSAGE_THREAD, &usage);
+  if (retval == 0) {
+    return usage.ru_utime.tv_sec + usage.ru_stime.tv_sec + (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000.0 * 1000);
+  } else {
+    // better than nothing, but not much
+    return elapsedTime();
+  }
 }
 
 jlong os::javaTimeMillis() {