equal
deleted
inserted
replaced
5553 return munmap(addr, bytes) == 0; |
5553 return munmap(addr, bytes) == 0; |
5554 } |
5554 } |
5555 |
5555 |
5556 static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time); |
5556 static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time); |
5557 |
5557 |
5558 static clockid_t thread_cpu_clockid(Thread* thread) { |
5558 static jlong fast_cpu_time(Thread *thread) { |
5559 pthread_t tid = thread->osthread()->pthread_id(); |
5559 clockid_t clockid; |
5560 clockid_t clockid; |
5560 int rc = os::Linux::pthread_getcpuclockid(thread->osthread()->pthread_id(), |
5561 |
5561 &clockid); |
5562 // Get thread clockid |
5562 if (rc == 0) { |
5563 int rc = os::Linux::pthread_getcpuclockid(tid, &clockid); |
5563 return os::Linux::fast_thread_cpu_time(clockid); |
5564 assert(rc == 0, "pthread_getcpuclockid is expected to return 0 code"); |
5564 } else { |
5565 return clockid; |
5565 // It's possible to encounter a terminated native thread that failed |
|
5566 // to detach itself from the VM - which should result in ESRCH. |
|
5567 assert_status(rc == ESRCH, rc, "pthread_getcpuclockid failed"); |
|
5568 return -1; |
|
5569 } |
5566 } |
5570 } |
5567 |
5571 |
5568 // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) |
5572 // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) |
5569 // are used by JVM M&M and JVMTI to get user+sys or user CPU time |
5573 // are used by JVM M&M and JVMTI to get user+sys or user CPU time |
5570 // of a thread. |
5574 // of a thread. |
5582 } |
5586 } |
5583 |
5587 |
5584 jlong os::thread_cpu_time(Thread* thread) { |
5588 jlong os::thread_cpu_time(Thread* thread) { |
5585 // consistent with what current_thread_cpu_time() returns |
5589 // consistent with what current_thread_cpu_time() returns |
5586 if (os::Linux::supports_fast_thread_cpu_time()) { |
5590 if (os::Linux::supports_fast_thread_cpu_time()) { |
5587 return os::Linux::fast_thread_cpu_time(thread_cpu_clockid(thread)); |
5591 return fast_cpu_time(thread); |
5588 } else { |
5592 } else { |
5589 return slow_thread_cpu_time(thread, true /* user + sys */); |
5593 return slow_thread_cpu_time(thread, true /* user + sys */); |
5590 } |
5594 } |
5591 } |
5595 } |
5592 |
5596 |
5598 } |
5602 } |
5599 } |
5603 } |
5600 |
5604 |
5601 jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { |
5605 jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { |
5602 if (user_sys_cpu_time && os::Linux::supports_fast_thread_cpu_time()) { |
5606 if (user_sys_cpu_time && os::Linux::supports_fast_thread_cpu_time()) { |
5603 return os::Linux::fast_thread_cpu_time(thread_cpu_clockid(thread)); |
5607 return fast_cpu_time(thread); |
5604 } else { |
5608 } else { |
5605 return slow_thread_cpu_time(thread, user_sys_cpu_time); |
5609 return slow_thread_cpu_time(thread, user_sys_cpu_time); |
5606 } |
5610 } |
5607 } |
5611 } |
5608 |
5612 |