mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-25 22:04:51 +02:00
8031126: java/lang/management/ThreadMXBean/ThreadUserTime.java fails intermittently
Reviewed-by: coleenp, simonis, goetz, gthornbr
This commit is contained in:
parent
0b8b6462e4
commit
a51135b202
1 changed files with 1 additions and 19 deletions
|
@ -5271,7 +5271,6 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
||||||
//
|
//
|
||||||
|
|
||||||
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
||||||
static bool proc_task_unchecked = true;
|
|
||||||
pid_t tid = thread->osthread()->thread_id();
|
pid_t tid = thread->osthread()->thread_id();
|
||||||
char *s;
|
char *s;
|
||||||
char stat[2048];
|
char stat[2048];
|
||||||
|
@ -5284,24 +5283,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
||||||
long ldummy;
|
long ldummy;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
snprintf(proc_name, 64, "/proc/%d/stat", tid);
|
snprintf(proc_name, 64, "/proc/self/task/%d/stat", tid);
|
||||||
|
|
||||||
// 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) {
|
|
||||||
snprintf(proc_name, 64, "/proc/self/task/%d/stat", tid);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fp = fopen(proc_name, "r");
|
fp = fopen(proc_name, "r");
|
||||||
if ( fp == NULL ) return -1;
|
if ( fp == NULL ) return -1;
|
||||||
statlen = fread(stat, 1, 2047, fp);
|
statlen = fread(stat, 1, 2047, fp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue