< prev index next >

src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp

Print this page
*** 121,10 ***
--- 121,16 ---
      }
      _path = os::strdup(ss.base());
    }
  }
  
+ jlong CgroupV1MemoryController::uses_mem_hierarchy() {
+   julong use_hierarchy;
+   CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.use_hierarchy", "Use Hierarchy", use_hierarchy);
+   return (jlong)use_hierarchy;
+ }
+ 
  /*
   * The common case, containers, we have _root == _cgroup_path, and thus set the
   * controller path to the _mount_point. This is where the limits are exposed in
   * the cgroup pseudo filesystem (at the leaf) and adjustment of the path won't
   * be needed for that reason.

*** 157,17 ***
  }
  
  jlong CgroupV1MemoryController::read_memory_limit_in_bytes(julong phys_mem) {
    julong memlimit;
    CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.limit_in_bytes", "Memory Limit", memlimit);
!   if (memlimit >= phys_mem) {
!     verbose_log(memlimit, phys_mem);
!     return (jlong)-1;
!   } else {
-     verbose_log(memlimit, phys_mem);
-     return (jlong)memlimit;
    }
  }
  
  /* read_mem_swap
   *
   * Determine the memory and swap limit metric. Returns a positive limit value strictly
--- 163,17 ---
  }
  
  jlong CgroupV1MemoryController::read_memory_limit_in_bytes(julong phys_mem) {
    julong memlimit;
    CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.limit_in_bytes", "Memory Limit", memlimit);
!   if (memlimit >= phys_mem && uses_mem_hierarchy()) {
!     CONTAINER_READ_NUMERICAL_KEY_VALUE_CHECKED(reader(), "/memory.stat",
!                                                "hierarchical_memory_limit", "Hierarchical Memory Limit",
!                                                memlimit);
    }
+   verbose_log(memlimit, phys_mem);
+   return (jlong)((memlimit < phys_mem) ? memlimit : -1);
  }
  
  /* read_mem_swap
   *
   * Determine the memory and swap limit metric. Returns a positive limit value strictly

*** 181,16 ***
   *      upper bound)
   */
  jlong CgroupV1MemoryController::read_mem_swap(julong host_total_memsw) {
    julong memswlimit;
    CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.memsw.limit_in_bytes", "Memory and Swap Limit", memswlimit);
!   if (memswlimit >= host_total_memsw) {
!     log_trace(os, container)("Memory and Swap Limit is: Unlimited");
!     return (jlong)-1;
!   } else {
-     return (jlong)memswlimit;
    }
  }
  
  jlong CgroupV1MemoryController::memory_and_swap_limit_in_bytes(julong host_mem, julong host_swap) {
    jlong memory_swap = read_mem_swap(host_mem + host_swap);
    if (memory_swap == -1) {
--- 187,17 ---
   *      upper bound)
   */
  jlong CgroupV1MemoryController::read_mem_swap(julong host_total_memsw) {
    julong memswlimit;
    CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.memsw.limit_in_bytes", "Memory and Swap Limit", memswlimit);
!   if (memswlimit >= host_total_memsw && uses_mem_hierarchy()) {
!       CONTAINER_READ_NUMERICAL_KEY_VALUE_CHECKED(reader(), "/memory.stat",
!                                                  "hierarchical_memsw_limit", "Hierarchical Memory and Swap Limit",
!                                                  memswlimit);
    }
+   verbose_log(memswlimit, host_total_memsw);
+   return (jlong)((memswlimit < host_total_memsw) ? memswlimit : -1);
  }
  
  jlong CgroupV1MemoryController::memory_and_swap_limit_in_bytes(julong host_mem, julong host_swap) {
    jlong memory_swap = read_mem_swap(host_mem + host_swap);
    if (memory_swap == -1) {
< prev index next >