RFR(s): backport of 8031126: java/lang/management/ThreadMXBean/ThreadUserTime.java fails intermittently
Fedor Burdun
fedor.burdun at azul.com
Tue Jul 16 17:42:23 UTC 2019
Hello everyone,
The issue described in bugs 8031126/8030631 is still reproducible on java8.
May I request a backport of the changeset http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/af53a220ea60 to java8?
The adjusted patch is:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
--- a/src/os/linux/vm/os_linux.cpp
+++ b/src/os/linux/vm/os_linux.cpp
@@ -6093,8 +6093,6 @@
PRAGMA_DIAG_PUSH
PRAGMA_FORMAT_NONLITERAL_IGNORED
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
- static bool proc_task_unchecked = true;
- static const char *proc_stat_path = "/proc/%d/stat";
pid_t tid = thread->osthread()->thread_id();
char *s;
char stat[2048];
@@ -6107,23 +6105,7 @@
long ldummy;
FILE *fp;
- // The /proc/<tid>/stat aggregates per-process usage on
- // new Linux kernels 2.6+ where NPTL is supported.
- // The /proc/self/task/<tid>/stat still has the per-thread usage.
- // See bug 6328462.
- // There possibly can be cases where there is no directory
- // /proc/self/task, so we check its availability.
- if (proc_task_unchecked && os::Linux::is_NPTL()) {
- // This is executed only once
- proc_task_unchecked = false;
- fp = fopen("/proc/self/task", "r");
- if (fp != NULL) {
- proc_stat_path = "/proc/self/task/%d/stat";
- fclose(fp);
- }
- }
-
- sprintf(proc_name, proc_stat_path, tid);
+ snprintf(proc_name, 64, "/proc/self/task/%d/stat", tid);
fp = fopen(proc_name, "r");
if ( fp == NULL ) return -1;
statlen = fread(stat, 1, 2047, fp);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Unfortunately I can not update OpenJDK bug for such request since I have not OpenJDK id.
Thanks,
Fedor
More information about the jdk8u-dev
mailing list