30
30
#include " runtime/globals.hpp"
31
31
#include " runtime/os.hpp"
32
32
#include " utilities/globalDefinitions.hpp"
33
+ #include " os_linux.hpp"
33
34
34
35
/*
35
36
* Set directory to subsystem specific files based
@@ -104,7 +105,7 @@ jlong CgroupV1Subsystem::read_memory_limit_in_bytes() {
104
105
GET_CONTAINER_INFO (julong, _memory->controller (), " /memory.limit_in_bytes" ,
105
106
" Memory Limit is: " JULONG_FORMAT, JULONG_FORMAT, memlimit);
106
107
107
- if (memlimit >= _unlimited_memory ) {
108
+ if (memlimit >= os::Linux::physical_memory () ) {
108
109
if (PrintContainerInfo) {
109
110
tty->print_cr (" Non-Hierarchical Memory Limit is: Unlimited" );
110
111
}
@@ -114,7 +115,7 @@ jlong CgroupV1Subsystem::read_memory_limit_in_bytes() {
114
115
const char * format = " %s " JULONG_FORMAT;
115
116
GET_CONTAINER_INFO_LINE (julong, _memory->controller (), " /memory.stat" , matchline,
116
117
" Hierarchical Memory Limit is: " JULONG_FORMAT, format, hier_memlimit)
117
- if (hier_memlimit >= _unlimited_memory ) {
118
+ if (hier_memlimit >= os::Linux::physical_memory () ) {
118
119
if (PrintContainerInfo) {
119
120
tty->print_cr (" Hierarchical Memory Limit is: Unlimited" );
120
121
}
@@ -130,9 +131,11 @@ jlong CgroupV1Subsystem::read_memory_limit_in_bytes() {
130
131
}
131
132
132
133
jlong CgroupV1Subsystem::memory_and_swap_limit_in_bytes () {
134
+ julong host_total_memsw;
133
135
GET_CONTAINER_INFO (julong, _memory->controller (), " /memory.memsw.limit_in_bytes" ,
134
136
" Memory and Swap Limit is: " JULONG_FORMAT, JULONG_FORMAT, memswlimit);
135
- if (memswlimit >= _unlimited_memory) {
137
+ host_total_memsw = os::Linux::host_swap () + os::Linux::physical_memory ();
138
+ if (memswlimit >= host_total_memsw) {
136
139
if (PrintContainerInfo) {
137
140
tty->print_cr (" Non-Hierarchical Memory and Swap Limit is: Unlimited" );
138
141
}
@@ -142,7 +145,7 @@ jlong CgroupV1Subsystem::memory_and_swap_limit_in_bytes() {
142
145
const char * format = " %s " JULONG_FORMAT;
143
146
GET_CONTAINER_INFO_LINE (julong, _memory->controller (), " /memory.stat" , matchline,
144
147
" Hierarchical Memory and Swap Limit is : " JULONG_FORMAT, format, hier_memlimit)
145
- if (hier_memlimit >= _unlimited_memory ) {
148
+ if (hier_memlimit >= host_total_memsw ) {
146
149
if (PrintContainerInfo) {
147
150
tty->print_cr (" Hierarchical Memory and Swap Limit is: Unlimited" );
148
151
}
@@ -159,7 +162,7 @@ jlong CgroupV1Subsystem::memory_and_swap_limit_in_bytes() {
159
162
jlong CgroupV1Subsystem::memory_soft_limit_in_bytes () {
160
163
GET_CONTAINER_INFO (julong, _memory->controller (), " /memory.soft_limit_in_bytes" ,
161
164
" Memory Soft Limit is: " JULONG_FORMAT, JULONG_FORMAT, memsoftlimit);
162
- if (memsoftlimit >= _unlimited_memory ) {
165
+ if (memsoftlimit >= os::Linux::physical_memory () ) {
163
166
if (PrintContainerInfo) {
164
167
tty->print_cr (" Memory Soft Limit is: Unlimited" );
165
168
}
0 commit comments