< prev index next >

src/hotspot/os/linux/os_linux.cpp

Print this page
@@ -81,10 +81,12 @@
  #if INCLUDE_JFR
  #include "jfr/jfrEvents.hpp"
  #endif
  
  // put OS-includes here
+ # include <ctype.h>
+ # include <stdlib.h>
  # include <sys/types.h>
  # include <sys/mman.h>
  # include <sys/stat.h>
  # include <sys/select.h>
  # include <pthread.h>

@@ -307,10 +309,33 @@
    do {
      c = fgetc(f);
    } while (c != '\n' && c != EOF);
  }
  
+ void os::Linux::kernel_version(long* major, long* minor) {
+   *major = -1;
+   *minor = -1;
+ 
+   struct utsname buffer;
+   int ret = uname(&buffer);
+   if (ret != 0) {
+     log_warning(os)("uname(2) failed to get kernel version: %s", os::errno_name(ret));
+     return;
+   }
+ 
+   char* walker = buffer.release;
+   long* set_v = major;
+   while (*minor == -1 && walker != nullptr) {
+     if (isdigit(walker[0])) {
+       *set_v = strtol(walker, &walker, 10);
+       set_v = minor;
+     } else {
+       ++walker;
+     }
+   }
+ }
+ 
  bool os::Linux::get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu) {
    FILE*         fh;
    uint64_t      userTicks, niceTicks, systemTicks, idleTicks;
    // since at least kernel 2.6 : iowait: time waiting for I/O to complete
    // irq: time  servicing interrupts; softirq: time servicing softirqs

@@ -2143,10 +2168,12 @@
  void os::Linux::print_proc_sys_info(outputStream* st) {
    _print_ascii_file_h("/proc/sys/kernel/threads-max (system-wide limit on the number of threads)",
                        "/proc/sys/kernel/threads-max", st);
    _print_ascii_file_h("/proc/sys/vm/max_map_count (maximum number of memory map areas a process may have)",
                        "/proc/sys/vm/max_map_count", st);
+   _print_ascii_file_h("/proc/sys/vm/swappiness (control to define how aggressively the kernel swaps out anonymous memory)",
+                       "/proc/sys/vm/swappiness", st);
    _print_ascii_file_h("/proc/sys/kernel/pid_max (system-wide limit on number of process identifiers)",
                        "/proc/sys/kernel/pid_max", st);
  }
  
  void os::Linux::print_system_memory_info(outputStream* st) {
< prev index next >