changeset 3847:24391b7e49b5

8026887: Make issues due to failed large pages allocations easier to debug Reviewed-by: stefank, mcastegr, poonam
author aeriksso
date Mon, 10 Mar 2014 18:48:19 +0000
parents cbdd11a54b82
children 3b188862d691
files src/os/linux/vm/os_linux.cpp src/os/linux/vm/os_linux.hpp src/share/vm/utilities/vmError.cpp
diffstat 3 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/linux/vm/os_linux.cpp	Mon Mar 10 18:09:45 2014 +0000
+++ b/src/os/linux/vm/os_linux.cpp	Mon Mar 10 18:48:19 2014 +0000
@@ -2546,6 +2546,14 @@
           alignment_hint, exec, strerror(err), err);
 }
 
+static void warn_fail_commit_memory(char* addr, size_t size,
+                                    size_t alignment_hint, bool exec,
+                                    int err, const char* msg) {
+  warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT
+          ", " SIZE_FORMAT ", %d) failed; error='%s' (errno=%d); %s", addr, size,
+          alignment_hint, exec, strerror(err), err, msg);
+}
+
 // NOTE: Linux kernel does not really reserve the pages for us.
 //       All it does is to check if there are enough free pages
 //       left at the time of mmap(). This could be a potential
@@ -2596,6 +2604,8 @@
 #define MADV_HUGEPAGE 14
 #endif
 
+volatile jint os::Linux::num_largepage_commit_fails = 0;
+
 int os::Linux::commit_memory_impl(char* addr, size_t size,
                                   size_t alignment_hint, bool exec) {
   int err;
@@ -2620,7 +2630,9 @@
       // from the loss. For now, we just issue a warning and we don't
       // call vm_exit_out_of_memory(). This issue is being tracked by
       // JBS-8007074.
-      warn_fail_commit_memory(addr, size, alignment_hint, exec, err);
+      Atomic::inc(&os::Linux::num_largepage_commit_fails);
+      warn_fail_commit_memory(addr, size, alignment_hint, exec, err,
+        "Cannot allocate large pages, falling back to regular pages");
 //    vm_exit_out_of_memory(size, "committing reserved memory.");
     }
     // Fall through and try to use small pages
--- a/src/os/linux/vm/os_linux.hpp	Mon Mar 10 18:09:45 2014 +0000
+++ b/src/os/linux/vm/os_linux.hpp	Mon Mar 10 18:48:19 2014 +0000
@@ -98,6 +98,8 @@
   static void print_libversion_info(outputStream* st);
 
  public:
+  static volatile jint num_largepage_commit_fails;
+
   static void init_thread_fpu_state();
   static int  get_fpu_control_word();
   static void set_fpu_control_word(int fpu_control);
--- a/src/share/vm/utilities/vmError.cpp	Mon Mar 10 18:09:45 2014 +0000
+++ b/src/share/vm/utilities/vmError.cpp	Mon Mar 10 18:48:19 2014 +0000
@@ -713,6 +713,18 @@
        st->cr();
      }
 
+#ifdef LINUX
+  STEP(193, "(printing large pages allocation errors)")
+
+     if (_verbose) {
+       jint largepage_failures = os::Linux::num_largepage_commit_fails;
+       if (largepage_failures > 0) {
+         st->print_cr("Large page allocation failures have occurred " INT32_FORMAT " times", largepage_failures);
+         st->cr();
+       }
+     }
+#endif
+
   STEP(195, "(printing code cache information)" )
 
      if (_verbose && Universe::is_fully_initialized()) {