# HG changeset patch # User aeriksso # Date 1394477299 0 # Node ID 24391b7e49b5230d2239a2e48f1f07c08c4fe270 # Parent cbdd11a54b82eb7731d16abbc6df3c9b4d42c78b 8026887: Make issues due to failed large pages allocations easier to debug Reviewed-by: stefank, mcastegr, poonam diff -r cbdd11a54b82 -r 24391b7e49b5 src/os/linux/vm/os_linux.cpp --- 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 diff -r cbdd11a54b82 -r 24391b7e49b5 src/os/linux/vm/os_linux.hpp --- 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); diff -r cbdd11a54b82 -r 24391b7e49b5 src/share/vm/utilities/vmError.cpp --- 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()) {