mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
relocate print out to SYSTEM section and remove AIX impl
This commit is contained in:
parent
1f34d2550d
commit
14ca2e29ba
@ -2726,39 +2726,5 @@ void os::jfr_report_memory_info() {}
|
||||
#endif // INCLUDE_JFR
|
||||
|
||||
void os::print_open_file_descriptors(outputStream* st) {
|
||||
char fd_dir[32];
|
||||
snprintf(fd_dir, sizeof(fd_dir), "/proc/%d/fd", getpid());
|
||||
DIR* dirp = opendir(fd_dir);
|
||||
int fds = 0;
|
||||
const int TIMEOUT_MS = 50;
|
||||
struct timespec start, now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
struct dirent* dentp;
|
||||
bool timed_out = false;
|
||||
|
||||
if (dirp == nullptr) {
|
||||
st->print_cr("OpenFileDescriptorCount = unknown");
|
||||
return;
|
||||
}
|
||||
|
||||
// limit proc file read to 50ms
|
||||
while ((dentp = readdir(dirp)) != nullptr) {
|
||||
if (isdigit(dentp->d_name[0])) fds++;
|
||||
if (fds % 100 == 0) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
long elapsed_ms = (now.tv_sec - start.tv_sec) * 1000L +
|
||||
(now.tv_nsec - start.tv_nsec) / 1000000L;
|
||||
if (elapsed_ms > TIMEOUT_MS) {
|
||||
timed_out = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
if (timed_out) {
|
||||
st->print_cr("OpenFileDescriptorCount > %d", fds - 1); // minus the opendir fd itself
|
||||
} else {
|
||||
st->print_cr("OpenFileDescriptorCount = %d", fds - 1);
|
||||
}
|
||||
// File descriptor counting not supported on AIX
|
||||
}
|
||||
|
||||
@ -1467,6 +1467,8 @@ void os::print_os_info(outputStream* st) {
|
||||
|
||||
os::Posix::print_rlimit_info(st);
|
||||
|
||||
os::print_open_file_descriptors(st);
|
||||
|
||||
os::Posix::print_load_average(st);
|
||||
|
||||
VM_Version::print_platform_virtualization_info(st);
|
||||
@ -2592,24 +2594,24 @@ void os::print_open_file_descriptors(outputStream* st) {
|
||||
|
||||
kres = pid_for_task(mach_task_self(), &my_pid);
|
||||
if (kres != KERN_SUCCESS) {
|
||||
st->print_cr("OpenFileDescriptorCount = unknown");
|
||||
st->print_cr("Open File Descriptors: unknown");
|
||||
return;
|
||||
}
|
||||
|
||||
res = proc_pidinfo(my_pid, PROC_PIDLISTFDS, 0, fds, MAX_SAFE_FDS * sizeof(struct proc_fdinfo));
|
||||
if (res <= 0) {
|
||||
st->print_cr("OpenFileDescriptorCount = unknown");
|
||||
st->print_cr("Open File Descriptors: unknown");
|
||||
return;
|
||||
}
|
||||
|
||||
nfiles = res / sizeof(struct proc_fdinfo);
|
||||
if (nfiles >= MAX_SAFE_FDS) {
|
||||
st->print_cr("OpenFileDescriptorCount = unknown");
|
||||
st->print_cr("Open File Descriptors > 1024");
|
||||
return;
|
||||
}
|
||||
|
||||
st->print_cr("OpenFileDescriptorCount = %d", nfiles);
|
||||
st->print_cr("Open File Descriptors: %d", nfiles);
|
||||
#else
|
||||
st->print_cr("OpenFileDescriptorCount = unknown");
|
||||
st->print_cr("Open File Descriptors: unknown");
|
||||
#endif
|
||||
}
|
||||
@ -2094,6 +2094,9 @@ void os::print_os_info(outputStream* st) {
|
||||
|
||||
os::Posix::print_rlimit_info(st);
|
||||
|
||||
os::print_open_file_descriptors(st);
|
||||
st->cr();
|
||||
|
||||
os::Posix::print_load_average(st);
|
||||
st->cr();
|
||||
|
||||
@ -5393,7 +5396,7 @@ void os::print_open_file_descriptors(outputStream* st) {
|
||||
bool timed_out = false;
|
||||
|
||||
if (dirp == nullptr) {
|
||||
st->print_cr("OpenFileDescriptorCount = unknown");
|
||||
st->print_cr("Open File Descriptors: unknown");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5413,9 +5416,9 @@ void os::print_open_file_descriptors(outputStream* st) {
|
||||
|
||||
closedir(dirp);
|
||||
if (timed_out) {
|
||||
st->print_cr("OpenFileDescriptorCount > %d", fds - 1); // minus the opendir fd itself
|
||||
st->print_cr("Open File Descriptors > %d", fds - 1); // minus the opendir fd itself
|
||||
} else {
|
||||
st->print_cr("OpenFileDescriptorCount = %d", fds - 1);
|
||||
st->print_cr("Open File Descriptors: %d", fds - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1228,12 +1228,6 @@ void VMError::report(outputStream* st, bool _verbose) {
|
||||
st->cr();
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
STEP_IF("printing open file descriptor count", _verbose)
|
||||
os::print_open_file_descriptors(st);
|
||||
st->cr();
|
||||
#endif
|
||||
|
||||
STEP_IF("printing GC information", _verbose)
|
||||
if (Universe::heap() != nullptr) {
|
||||
Universe::heap()->print_gc_on(st);
|
||||
@ -1439,12 +1433,6 @@ void VMError::print_vm_info(outputStream* st) {
|
||||
st->cr();
|
||||
}
|
||||
|
||||
// STEP("printing number of open file descriptors")
|
||||
#ifndef _WIN32
|
||||
os::print_open_file_descriptors(st);
|
||||
st->cr();
|
||||
#endif
|
||||
|
||||
// Take heap lock over heap, GC and metaspace printing so that information
|
||||
// is consistent.
|
||||
if (Universe::is_fully_initialized()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user