hotspot/src/os/linux/vm/os_linux.cpp
changeset 24424 2658d7834c6e
parent 24352 9ba9e99b1ba7
child 24931 4bba680186bd
equal deleted inserted replaced
24358:8528b67f6562 24424:2658d7834c6e
    99 # include <sys/shm.h>
    99 # include <sys/shm.h>
   100 # include <link.h>
   100 # include <link.h>
   101 # include <stdint.h>
   101 # include <stdint.h>
   102 # include <inttypes.h>
   102 # include <inttypes.h>
   103 # include <sys/ioctl.h>
   103 # include <sys/ioctl.h>
       
   104 
       
   105 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
   104 
   106 
   105 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
   107 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
   106 // getrusage() is prepared to handle the associated failure.
   108 // getrusage() is prepared to handle the associated failure.
   107 #ifndef RUSAGE_THREAD
   109 #ifndef RUSAGE_THREAD
   108 #define RUSAGE_THREAD   (1)               /* only the calling thread */
   110 #define RUSAGE_THREAD   (1)               /* only the calling thread */
  2136   os::Posix::print_uname_info(st);
  2138   os::Posix::print_uname_info(st);
  2137 
  2139 
  2138   // Print warning if unsafe chroot environment detected
  2140   // Print warning if unsafe chroot environment detected
  2139   if (unsafe_chroot_detected) {
  2141   if (unsafe_chroot_detected) {
  2140     st->print("WARNING!! ");
  2142     st->print("WARNING!! ");
  2141     st->print_cr(unstable_chroot_error);
  2143     st->print_cr("%s", unstable_chroot_error);
  2142   }
  2144   }
  2143 
  2145 
  2144   os::Linux::print_libversion_info(st);
  2146   os::Linux::print_libversion_info(st);
  2145 
  2147 
  2146   os::Posix::print_rlimit_info(st);
  2148   os::Posix::print_rlimit_info(st);
  2197 }
  2199 }
  2198 
  2200 
  2199 void os::Linux::print_libversion_info(outputStream* st) {
  2201 void os::Linux::print_libversion_info(outputStream* st) {
  2200   // libc, pthread
  2202   // libc, pthread
  2201   st->print("libc:");
  2203   st->print("libc:");
  2202   st->print(os::Linux::glibc_version()); st->print(" ");
  2204   st->print("%s ", os::Linux::glibc_version());
  2203   st->print(os::Linux::libpthread_version()); st->print(" ");
  2205   st->print("%s ", os::Linux::libpthread_version());
  2204   if (os::Linux::is_LinuxThreads()) {
  2206   if (os::Linux::is_LinuxThreads()) {
  2205      st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed");
  2207      st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed");
  2206   }
  2208   }
  2207   st->cr();
  2209   st->cr();
  2208 }
  2210 }
  3415      //            they are so fragmented after a long run that they can't
  3417      //            they are so fragmented after a long run that they can't
  3416      //            coalesce into large pages. Try to reserve large pages when
  3418      //            coalesce into large pages. Try to reserve large pages when
  3417      //            the system is still "fresh".
  3419      //            the system is still "fresh".
  3418      if (warn_on_failure) {
  3420      if (warn_on_failure) {
  3419        jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno);
  3421        jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno);
  3420        warning(msg);
  3422        warning("%s", msg);
  3421      }
  3423      }
  3422      return NULL;
  3424      return NULL;
  3423   }
  3425   }
  3424 
  3426 
  3425   // attach to the region
  3427   // attach to the region
  3433   shmctl(shmid, IPC_RMID, NULL);
  3435   shmctl(shmid, IPC_RMID, NULL);
  3434 
  3436 
  3435   if ((intptr_t)addr == -1) {
  3437   if ((intptr_t)addr == -1) {
  3436      if (warn_on_failure) {
  3438      if (warn_on_failure) {
  3437        jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
  3439        jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
  3438        warning(msg);
  3440        warning("%s", msg);
  3439      }
  3441      }
  3440      return NULL;
  3442      return NULL;
  3441   }
  3443   }
  3442 
  3444 
  3443   return addr;
  3445   return addr;
  3453 
  3455 
  3454   if (warn_on_failure) {
  3456   if (warn_on_failure) {
  3455     char msg[128];
  3457     char msg[128];
  3456     jio_snprintf(msg, sizeof(msg), "Failed to reserve large pages memory req_addr: "
  3458     jio_snprintf(msg, sizeof(msg), "Failed to reserve large pages memory req_addr: "
  3457         PTR_FORMAT " bytes: " SIZE_FORMAT " (errno = %d).", req_addr, bytes, error);
  3459         PTR_FORMAT " bytes: " SIZE_FORMAT " (errno = %d).", req_addr, bytes, error);
  3458     warning(msg);
  3460     warning("%s", msg);
  3459   }
  3461   }
  3460 }
  3462 }
  3461 
  3463 
  3462 char* os::Linux::reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec) {
  3464 char* os::Linux::reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec) {
  3463   assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages");
  3465   assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages");