os::current_thread_id on Linux
Jeremy Manson
jeremymanson at google.com
Wed Jul 22 18:52:49 UTC 2015
Example of where this would help:
Current output of SIGQUIT:
"C1 CompilerThread3" #8 daemon prio=9 os_prio=0 tid=0x00007f0890247800
nid=0x2e3d waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007f0890245000
nid=0x2e3c waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007f0890243800
nid=0x2e3b waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007f0890240800
nid=0x2e3a waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Current directory listing from /tmp with -XX:+UnlockDiagnosticVMOptions
-XX:+LogCompilation:
$ ls -d /tmp/hs*
hs_c139673756251904_pid11818.log hs_c139673759409920_pid11818.log
hs_c139673757304576_pid11818.log hsperfdata_jeremymanson/
hs_c139673758357248_pid11818.log hsperfdata_root/
Output with this change would look like:
$ ls -d /tmp/hs*
hs_c11837_pid11818.log hs_c11834_pid11818.log
hs_c11836_pid11818.log hsperfdata_jeremymanson/
hs_c11835_pid11818.log hsperfdata_root/
Where 1183x maps neatly back to 0x2e3x in the SIGQUIT dump.
Jeremy
On Wed, Jul 22, 2015 at 11:22 AM, Jeremy Manson <jeremymanson at google.com>
wrote:
> Hey folks,
>
> os::current_thread_id on Linux now maps to pthread_self. The problem with
> pthread_self is that it only makes sense in the context of the running
> process. When it is written out to the log (as it is in several places),
> there really isn't a way (AFAICT) for the user to map it back to anything
> useful.
>
> As it happens, that value is mostly used to write to the log. The places
> where it doesn't do so don't seem to need to use pthread_self for any
> particular reason.
>
> Meanwhile, the SIGQUIT stack dump
> uses java_thread->osthread()->thread_id() as the nid. On Linux, that maps
> back to os::Linux::gettid(), whish is also what gets exposed in /proc.
> That makes it much easier to see what threads might be doing the log write.
>
> Would it be okay to change os::current_thread_id to point
> to os::Linux::gettid()? That way, it can be mapped back to the output of a
> SIGQUIT dump.
>
> The downside of gettid() is that it is only available on Linux>2.4.11, but
> that dates from 2001. If we really still want to support it, we could
> check for that.
>
> Thoughts?
>
> Jeremy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20150722/f69d775b/attachment.html>
More information about the serviceability-dev
mailing list