Skip to content

Commit 2cc5435

Browse files
committed
Move methods to Machine/Container inner classes + clarifying documentation
1 parent 785fb8a commit 2cc5435

File tree

9 files changed

+112
-96
lines changed

9 files changed

+112
-96
lines changed

src/hotspot/os/aix/os_aix.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,15 @@ bool os::free_memory(physical_memory_size_type& value) {
258258
return Aix::available_memory(value);
259259
}
260260

261-
bool os::machine_free_memory(physical_memory_size_type& value) {
261+
bool os::Machine::free_memory(physical_memory_size_type& value) {
262262
return Aix::available_memory(value);
263263
}
264264

265265
bool os::available_memory(physical_memory_size_type& value) {
266266
return Aix::available_memory(value);
267267
}
268268

269-
bool os::machine_available_memory(physical_memory_size_type& value) {
269+
bool os::Machine::available_memory(physical_memory_size_type& value) {
270270
return Aix::available_memory(value);
271271
}
272272

@@ -281,10 +281,10 @@ bool os::Aix::available_memory(physical_memory_size_type& value) {
281281
}
282282

283283
bool os::total_swap_space(physical_memory_size_type& value) {
284-
return machine_total_swap_space(value);
284+
return Machine::total_swap_space(value);
285285
}
286286

287-
bool os::machine_total_swap_space(physical_memory_size_type& value) {
287+
bool os::Machine::total_swap_space(physical_memory_size_type& value) {
288288
perfstat_memory_total_t memory_info;
289289
if (libperfstat::perfstat_memory_total(nullptr, &memory_info, sizeof(perfstat_memory_total_t), 1) == -1) {
290290
return false;
@@ -294,10 +294,10 @@ bool os::machine_total_swap_space(physical_memory_size_type& value) {
294294
}
295295

296296
bool os::free_swap_space(physical_memory_size_type& value) {
297-
return machine_free_swap_space(value);
297+
return Machine::free_swap_space(value);
298298
}
299299

300-
bool os::machine_free_swap_space(physical_memory_size_type& value) {
300+
bool os::Machine::free_swap_space(physical_memory_size_type& value) {
301301
perfstat_memory_total_t memory_info;
302302
if (libperfstat::perfstat_memory_total(nullptr, &memory_info, sizeof(perfstat_memory_total_t), 1) == -1) {
303303
return false;
@@ -310,7 +310,7 @@ physical_memory_size_type os::physical_memory() {
310310
return Aix::physical_memory();
311311
}
312312

313-
physical_memory_size_type os::machine_physical_memory() {
313+
physical_memory_size_type os::Machine::physical_memory() {
314314
return Aix::physical_memory();
315315
}
316316

@@ -2279,10 +2279,10 @@ int os::active_processor_count() {
22792279
return ActiveProcessorCount;
22802280
}
22812281

2282-
return machine_active_processor_count();
2282+
return Machine::active_processor_count();
22832283
}
22842284

2285-
int os::machine_active_processor_count() {
2285+
int os::Machine::active_processor_count() {
22862286
int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
22872287
assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
22882288
return online_cpus;

src/hotspot/os/bsd/os_bsd.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ bool os::available_memory(physical_memory_size_type& value) {
137137
return Bsd::available_memory(value);
138138
}
139139

140-
bool os::machine_available_memory(physical_memory_size_type& value) {
140+
bool os::Machine::available_memory(physical_memory_size_type& value) {
141141
return Bsd::available_memory(value);
142142
}
143143

144144
bool os::free_memory(physical_memory_size_type& value) {
145145
return Bsd::available_memory(value);
146146
}
147147

148-
bool os::machine_free_memory(physical_memory_size_type& value) {
148+
bool os::Machine::free_memory(physical_memory_size_type& value) {
149149
return Bsd::available_memory(value);
150150
}
151151

@@ -189,10 +189,10 @@ void os::Bsd::print_uptime_info(outputStream* st) {
189189
}
190190

191191
bool os::total_swap_space(physical_memory_size_type& value) {
192-
return machine_total_swap_space(value);
192+
return Machine::total_swap_space(value);
193193
}
194194

195-
bool os::machine_total_swap_space(physical_memory_size_type& value) {
195+
bool os::Machine::total_swap_space(physical_memory_size_type& value) {
196196
#if defined(__APPLE__)
197197
struct xsw_usage vmusage;
198198
size_t size = sizeof(vmusage);
@@ -207,10 +207,10 @@ bool os::machine_total_swap_space(physical_memory_size_type& value) {
207207
}
208208

209209
bool os::free_swap_space(physical_memory_size_type& value) {
210-
return machine_free_swap_space(value);
210+
return Machine::free_swap_space(value);
211211
}
212212

213-
bool os::machine_free_swap_space(physical_memory_size_type& value) {
213+
bool os::Machine::free_swap_space(physical_memory_size_type& value) {
214214
#if defined(__APPLE__)
215215
struct xsw_usage vmusage;
216216
size_t size = sizeof(vmusage);
@@ -228,7 +228,7 @@ physical_memory_size_type os::physical_memory() {
228228
return Bsd::physical_memory();
229229
}
230230

231-
physical_memory_size_type os::machine_physical_memory() {
231+
physical_memory_size_type os::Machine::physical_memory() {
232232
return Bsd::physical_memory();
233233
}
234234

@@ -2120,10 +2120,10 @@ int os::active_processor_count() {
21202120
return ActiveProcessorCount;
21212121
}
21222122

2123-
return machine_active_processor_count();
2123+
return Machine::active_processor_count();
21242124
}
21252125

2126-
int os::machine_active_processor_count() {
2126+
int os::Machine::active_processor_count() {
21272127
return _processor_count;
21282128
}
21292129

src/hotspot/os/linux/osContainer_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ bool OSContainer::available_memory_in_container(julong& value) {
122122

123123
jlong OSContainer::memory_limit_in_bytes() {
124124
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
125-
julong phys_mem = static_cast<julong>(os::machine_physical_memory());
125+
julong phys_mem = static_cast<julong>(os::Machine::physical_memory());
126126
return cgroup_subsystem->memory_limit_in_bytes(phys_mem);
127127
}
128128

src/hotspot/os/linux/os_linux.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ bool os::is_containerized() {
217217
return OSContainer::is_containerized();
218218
}
219219

220-
bool os::container_memory_limit(physical_memory_size_type& value) {
220+
bool os::Container::memory_limit(physical_memory_size_type& value) {
221221
assert(is_containerized(), "must be running containerized");
222222
jlong mem_limit = OSContainer::memory_limit_in_bytes();
223223
if (mem_limit <= 0) {
@@ -227,7 +227,7 @@ bool os::container_memory_limit(physical_memory_size_type& value) {
227227
value = static_cast<physical_memory_size_type>(mem_limit);
228228
return true;
229229
}
230-
bool os::container_memory_soft_limit(physical_memory_size_type& value) {
230+
bool os::Container::memory_soft_limit(physical_memory_size_type& value) {
231231
assert(is_containerized(), "must be running containerized");
232232
jlong mem_limit = OSContainer::memory_soft_limit_in_bytes();
233233
if (mem_limit <= 0) {
@@ -238,7 +238,7 @@ bool os::container_memory_soft_limit(physical_memory_size_type& value) {
238238
return true;
239239
}
240240

241-
bool os::container_memory_throttle_limit(physical_memory_size_type& value) {
241+
bool os::Container::memory_throttle_limit(physical_memory_size_type& value) {
242242
assert(is_containerized(), "must be running containerized");
243243
jlong mem_limit = OSContainer::memory_throttle_limit_in_bytes();
244244
if (mem_limit <= 0) {
@@ -249,7 +249,7 @@ bool os::container_memory_throttle_limit(physical_memory_size_type& value) {
249249
return true;
250250
}
251251

252-
bool os::container_used_memory(physical_memory_size_type& value) {
252+
bool os::Container::used_memory(physical_memory_size_type& value) {
253253
assert(is_containerized(), "must be running containerized");
254254
jlong mem_usage = OSContainer::memory_usage_in_bytes();
255255
if (mem_usage <= 0) {
@@ -261,19 +261,19 @@ bool os::container_used_memory(physical_memory_size_type& value) {
261261
}
262262

263263
bool os::available_memory(physical_memory_size_type& value) {
264-
if (is_containerized() && container_available_memory(value)) {
264+
if (is_containerized() && Container::available_memory(value)) {
265265
log_trace(os)("available container memory: " PHYS_MEM_TYPE_FORMAT, value);
266266
return true;
267267
}
268268

269-
return machine_available_memory(value);
269+
return Machine::available_memory(value);
270270
}
271271

272-
bool os::machine_available_memory(physical_memory_size_type& value) {
272+
bool os::Machine::available_memory(physical_memory_size_type& value) {
273273
return Linux::available_memory(value);
274274
}
275275

276-
bool os::container_available_memory(physical_memory_size_type& value) {
276+
bool os::Container::available_memory(physical_memory_size_type& value) {
277277
assert(is_containerized(), "must be running containerized");
278278
julong avail_mem = 0;
279279
if (OSContainer::available_memory_in_container(avail_mem)) {
@@ -310,15 +310,15 @@ bool os::Linux::available_memory(physical_memory_size_type& value) {
310310
}
311311

312312
bool os::free_memory(physical_memory_size_type& value) {
313-
if (is_containerized() && container_available_memory(value)) {
313+
if (is_containerized() && Container::available_memory(value)) {
314314
log_trace(os)("free container memory: " PHYS_MEM_TYPE_FORMAT, value);
315315
return true;
316316
}
317317

318-
return machine_free_memory(value);
318+
return Machine::free_memory(value);
319319
}
320320

321-
bool os::machine_free_memory(physical_memory_size_type& value) {
321+
bool os::Machine::free_memory(physical_memory_size_type& value) {
322322
return Linux::free_memory(value);
323323
}
324324

@@ -337,13 +337,13 @@ bool os::Linux::free_memory(physical_memory_size_type& value) {
337337
}
338338

339339
bool os::total_swap_space(physical_memory_size_type& value) {
340-
if (is_containerized() && container_total_swap_space(value)) {
340+
if (is_containerized() && Container::total_swap_space(value)) {
341341
return true;
342342
} // fallback to the host swap space if the container value fails
343-
return machine_total_swap_space(value);
343+
return Machine::total_swap_space(value);
344344
}
345345

346-
bool os::machine_total_swap_space(physical_memory_size_type& value) {
346+
bool os::Machine::total_swap_space(physical_memory_size_type& value) {
347347
struct sysinfo si;
348348
int ret = sysinfo(&si);
349349
if (ret != 0) {
@@ -354,7 +354,7 @@ bool os::machine_total_swap_space(physical_memory_size_type& value) {
354354
return true;
355355
}
356356

357-
bool os::container_total_swap_space(physical_memory_size_type& value) {
357+
bool os::Container::total_swap_space(physical_memory_size_type& value) {
358358
assert(is_containerized(), "must be running containerized");
359359
jlong memory_and_swap_limit_in_bytes = OSContainer::memory_and_swap_limit_in_bytes();
360360
jlong memory_limit_in_bytes = OSContainer::memory_limit_in_bytes();
@@ -386,7 +386,7 @@ bool os::free_swap_space(physical_memory_size_type& value) {
386386
}
387387
size_t host_free_swap_val = MIN2(total_swap_space, host_free_swap);
388388
if (is_containerized()) {
389-
if (container_free_swap_space(value)) {
389+
if (Container::free_swap_space(value)) {
390390
return true;
391391
} else {
392392
// unlimited or not supported. Fall through to return host value
@@ -401,11 +401,11 @@ bool os::free_swap_space(physical_memory_size_type& value) {
401401
return true;
402402
}
403403

404-
bool os::machine_free_swap_space(physical_memory_size_type& value) {
404+
bool os::Machine::free_swap_space(physical_memory_size_type& value) {
405405
return host_free_swap_f(value);
406406
}
407407

408-
bool os::container_free_swap_space(physical_memory_size_type& value) {
408+
bool os::Container::free_swap_space(physical_memory_size_type& value) {
409409
assert(is_containerized(), "must be running containerized");
410410
jlong mem_swap_limit = OSContainer::memory_and_swap_limit_in_bytes();
411411
jlong mem_limit = OSContainer::memory_limit_in_bytes();
@@ -432,18 +432,18 @@ bool os::container_free_swap_space(physical_memory_size_type& value) {
432432
physical_memory_size_type os::physical_memory() {
433433
if (is_containerized()) {
434434
physical_memory_size_type mem_limit;
435-
if (container_memory_limit(mem_limit)) {
435+
if (Container::memory_limit(mem_limit)) {
436436
log_trace(os)("total container memory: " PHYS_MEM_TYPE_FORMAT, mem_limit);
437437
return mem_limit;
438438
}
439439
}
440440

441-
physical_memory_size_type phys_mem = machine_physical_memory();
441+
physical_memory_size_type phys_mem = Machine::physical_memory();
442442
log_trace(os)("total system memory: " PHYS_MEM_TYPE_FORMAT, phys_mem);
443443
return phys_mem;
444444
}
445445

446-
physical_memory_size_type os::machine_physical_memory() {
446+
physical_memory_size_type os::Machine::physical_memory() {
447447
return Linux::physical_memory();
448448
}
449449

@@ -4751,22 +4751,22 @@ int os::active_processor_count() {
47514751
}
47524752

47534753
if (is_containerized()) {
4754-
double cpu_quota = container_processor_count();
4754+
double cpu_quota = Container::processor_count();
47554755
int active_cpus = ceilf(cpu_quota); // Round fractional CPU quota up.
4756-
assert(active_cpus <= machine_active_processor_count(), "must be");
4756+
assert(active_cpus <= Machine::active_processor_count(), "must be");
47574757
log_trace(os)("active_processor_count: determined by OSContainer: %d",
47584758
active_cpus);
47594759
return active_cpus;
47604760
}
47614761

4762-
return machine_active_processor_count();
4762+
return Machine::active_processor_count();
47634763
}
47644764

4765-
int os::machine_active_processor_count() {
4765+
int os::Machine::active_processor_count() {
47664766
return os::Linux::active_processor_count();
47674767
}
47684768

4769-
double os::container_processor_count() {
4769+
double os::Container::processor_count() {
47704770
assert(is_containerized(), "must be running containerized");
47714771
return OSContainer::active_processor_count();
47724772
}

src/hotspot/os/windows/os_windows.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -838,15 +838,15 @@ bool os::available_memory(physical_memory_size_type& value) {
838838
return win32::available_memory(value);
839839
}
840840

841-
bool os::machine_available_memory(physical_memory_size_type& value) {
841+
bool os::Machine::available_memory(physical_memory_size_type& value) {
842842
return win32::available_memory(value);
843843
}
844844

845845
bool os::free_memory(physical_memory_size_type& value) {
846846
return win32::available_memory(value);
847847
}
848848

849-
bool os::machine_free_memory(physical_memory_size_type& value) {
849+
bool os::Machine::free_memory(physical_memory_size_type& value) {
850850
return win32::available_memory(value);
851851
}
852852

@@ -866,10 +866,10 @@ bool os::win32::available_memory(physical_memory_size_type& value) {
866866
}
867867

868868
bool os::total_swap_space(physical_memory_size_type& value) {
869-
return machine_total_swap_space(value);
869+
return Machine::total_swap_space(value);
870870
}
871871

872-
bool os::machine_total_swap_space(physical_memory_size_type& value) {
872+
bool os::Machine::total_swap_space(physical_memory_size_type& value) {
873873
MEMORYSTATUSEX ms;
874874
ms.dwLength = sizeof(ms);
875875
BOOL res = GlobalMemoryStatusEx(&ms);
@@ -883,10 +883,10 @@ bool os::machine_total_swap_space(physical_memory_size_type& value) {
883883
}
884884

885885
bool os::free_swap_space(physical_memory_size_type& value) {
886-
return machine_free_swap_space(value);
886+
return Machine::free_swap_space(value);
887887
}
888888

889-
bool os::machine_free_swap_space(physical_memory_size_type& value) {
889+
bool os::Machine::free_swap_space(physical_memory_size_type& value) {
890890
MEMORYSTATUSEX ms;
891891
ms.dwLength = sizeof(ms);
892892
BOOL res = GlobalMemoryStatusEx(&ms);
@@ -903,7 +903,7 @@ physical_memory_size_type os::physical_memory() {
903903
return win32::physical_memory();
904904
}
905905

906-
physical_memory_size_type os::machine_physical_memory() {
906+
physical_memory_size_type os::Machine::physical_memory() {
907907
return win32::physical_memory();
908908
}
909909

@@ -930,10 +930,10 @@ int os::active_processor_count() {
930930
return ActiveProcessorCount;
931931
}
932932

933-
return machine_active_processor_count();
933+
return Machine::active_processor_count();
934934
}
935935

936-
int os::machine_active_processor_count() {
936+
int os::Machine::active_processor_count() {
937937
bool schedules_all_processor_groups = win32::is_windows_11_or_greater() || win32::is_windows_server_2022_or_greater();
938938
if (UseAllWindowsProcessorGroups && !schedules_all_processor_groups && !win32::processor_group_warning_displayed()) {
939939
win32::set_processor_group_warning_displayed(true);

0 commit comments

Comments
 (0)