@@ -136,35 +136,35 @@ bool CgroupV1Controller::needs_hierarchy_adjustment() {
136136}
137137
138138static inline
139- void verbose_log (julong read_mem_limit, julong host_mem ) {
139+ void verbose_log (julong read_mem_limit, julong upper_mem_bound ) {
140140 if (log_is_enabled (Debug, os, container)) {
141141 jlong mem_limit = (jlong)read_mem_limit; // account for negative values
142- if (mem_limit < 0 || read_mem_limit >= host_mem ) {
142+ if (mem_limit < 0 || read_mem_limit >= upper_mem_bound ) {
143143 const char *reason;
144144 if (mem_limit == OSCONTAINER_ERROR) {
145145 reason = " failed" ;
146146 } else if (mem_limit == -1 ) {
147147 reason = " unlimited" ;
148148 } else {
149- assert (read_mem_limit >= host_mem , " Expected read value exceeding host_mem " );
149+ assert (read_mem_limit >= upper_mem_bound , " Expected read value exceeding upper memory bound " );
150150 // Exceeding physical memory is treated as unlimited. This implementation
151151 // caps it at host_mem since Cg v1 has no value to represent 'max'.
152152 reason = " ignored" ;
153153 }
154- log_debug (os, container)(" container memory limit %s: " JLONG_FORMAT " , using host value " JLONG_FORMAT,
155- reason, mem_limit, host_mem );
154+ log_debug (os, container)(" container memory limit %s: " JLONG_FORMAT " , upper bound is " JLONG_FORMAT,
155+ reason, mem_limit, upper_mem_bound );
156156 }
157157 }
158158}
159159
160- jlong CgroupV1MemoryController::read_memory_limit_in_bytes (julong phys_mem ) {
160+ jlong CgroupV1MemoryController::read_memory_limit_in_bytes (julong upper_bound ) {
161161 julong memlimit;
162162 CONTAINER_READ_NUMBER_CHECKED (reader (), " /memory.limit_in_bytes" , " Memory Limit" , memlimit);
163- if (memlimit >= phys_mem ) {
164- verbose_log (memlimit, phys_mem );
163+ if (memlimit >= upper_bound ) {
164+ verbose_log (memlimit, upper_bound );
165165 return (jlong)-1 ;
166166 } else {
167- verbose_log (memlimit, phys_mem );
167+ verbose_log (memlimit, upper_bound );
168168 return (jlong)memlimit;
169169 }
170170}
@@ -181,19 +181,19 @@ jlong CgroupV1MemoryController::read_memory_limit_in_bytes(julong phys_mem) {
181181 * * -1 if there isn't any limit in place (note: includes values which exceed a physical
182182 * upper bound)
183183 */
184- jlong CgroupV1MemoryController::read_mem_swap (julong host_total_memsw ) {
184+ jlong CgroupV1MemoryController::read_mem_swap (julong upper_memsw_bound ) {
185185 julong memswlimit;
186186 CONTAINER_READ_NUMBER_CHECKED (reader (), " /memory.memsw.limit_in_bytes" , " Memory and Swap Limit" , memswlimit);
187- if (memswlimit >= host_total_memsw ) {
187+ if (memswlimit >= upper_memsw_bound ) {
188188 log_trace (os, container)(" Memory and Swap Limit is: Unlimited" );
189189 return (jlong)-1 ;
190190 } else {
191191 return (jlong)memswlimit;
192192 }
193193}
194194
195- jlong CgroupV1MemoryController::memory_and_swap_limit_in_bytes (julong host_mem , julong host_swap ) {
196- jlong memory_swap = read_mem_swap (host_mem + host_swap );
195+ jlong CgroupV1MemoryController::memory_and_swap_limit_in_bytes (julong upper_mem_bound , julong upper_swap_bound ) {
196+ jlong memory_swap = read_mem_swap (upper_mem_bound + upper_swap_bound );
197197 if (memory_swap == -1 ) {
198198 return memory_swap;
199199 }
@@ -202,7 +202,7 @@ jlong CgroupV1MemoryController::memory_and_swap_limit_in_bytes(julong host_mem,
202202 // supported.
203203 jlong swappiness = read_mem_swappiness ();
204204 if (swappiness == 0 || memory_swap == OSCONTAINER_ERROR) {
205- jlong memlimit = read_memory_limit_in_bytes (host_mem );
205+ jlong memlimit = read_memory_limit_in_bytes (upper_mem_bound );
206206 if (memory_swap == OSCONTAINER_ERROR) {
207207 log_trace (os, container)(" Memory and Swap Limit has been reset to " JLONG_FORMAT " because swap is not supported" , memlimit);
208208 } else {
@@ -220,9 +220,9 @@ jlong memory_swap_usage_impl(CgroupController* ctrl) {
220220 return (jlong)memory_swap_usage;
221221}
222222
223- jlong CgroupV1MemoryController::memory_and_swap_usage_in_bytes (julong phys_mem , julong host_swap ) {
224- jlong memory_sw_limit = memory_and_swap_limit_in_bytes (phys_mem, host_swap );
225- jlong memory_limit = read_memory_limit_in_bytes (phys_mem );
223+ jlong CgroupV1MemoryController::memory_and_swap_usage_in_bytes (julong upper_mem_bound , julong upper_swap_bound ) {
224+ jlong memory_sw_limit = memory_and_swap_limit_in_bytes (upper_mem_bound, upper_swap_bound );
225+ jlong memory_limit = read_memory_limit_in_bytes (upper_mem_bound );
226226 if (memory_sw_limit > 0 && memory_limit > 0 ) {
227227 jlong delta_swap = memory_sw_limit - memory_limit;
228228 if (delta_swap > 0 ) {
@@ -238,10 +238,10 @@ jlong CgroupV1MemoryController::read_mem_swappiness() {
238238 return (jlong)swappiness;
239239}
240240
241- jlong CgroupV1MemoryController::memory_soft_limit_in_bytes (julong phys_mem ) {
241+ jlong CgroupV1MemoryController::memory_soft_limit_in_bytes (julong upper_bound ) {
242242 julong memsoftlimit;
243243 CONTAINER_READ_NUMBER_CHECKED (reader (), " /memory.soft_limit_in_bytes" , " Memory Soft Limit" , memsoftlimit);
244- if (memsoftlimit >= phys_mem ) {
244+ if (memsoftlimit >= upper_bound ) {
245245 log_trace (os, container)(" Memory Soft Limit is: Unlimited" );
246246 return (jlong)-1 ;
247247 } else {
@@ -336,10 +336,10 @@ jlong CgroupV1MemoryController::kernel_memory_usage_in_bytes() {
336336 return (jlong)kmem_usage;
337337}
338338
339- jlong CgroupV1MemoryController::kernel_memory_limit_in_bytes (julong phys_mem ) {
339+ jlong CgroupV1MemoryController::kernel_memory_limit_in_bytes (julong upper_bound ) {
340340 julong kmem_limit;
341341 CONTAINER_READ_NUMBER_CHECKED (reader (), " /memory.kmem.limit_in_bytes" , " Kernel Memory Limit" , kmem_limit);
342- if (kmem_limit >= phys_mem ) {
342+ if (kmem_limit >= upper_bound ) {
343343 return (jlong)-1 ;
344344 }
345345 return (jlong)kmem_limit;
@@ -351,9 +351,9 @@ jlong CgroupV1MemoryController::kernel_memory_max_usage_in_bytes() {
351351 return (jlong)kmem_max_usage;
352352}
353353
354- void CgroupV1MemoryController::print_version_specific_info (outputStream* st, julong phys_mem ) {
354+ void CgroupV1MemoryController::print_version_specific_info (outputStream* st, julong mem_bound ) {
355355 jlong kmem_usage = kernel_memory_usage_in_bytes ();
356- jlong kmem_limit = kernel_memory_limit_in_bytes (phys_mem );
356+ jlong kmem_limit = kernel_memory_limit_in_bytes (mem_bound );
357357 jlong kmem_max_usage = kernel_memory_max_usage_in_bytes ();
358358
359359 OSContainer::print_container_helper (st, kmem_limit, " kernel_memory_limit_in_bytes" );
0 commit comments