SIGBUS on linux in perfMemory_init

Severin Gehwolf sgehwolf at redhat.com
Fri May 6 08:17:16 UTC 2022


On Thu, 2022-05-05 at 12:43 -0700, Ioi Lam wrote:
> 
> 
> On 5/5/2022 11:06 AM, Ioi Lam wrote:
> > 
> > 
> > On 5/5/2022 3:05 AM, Severin Gehwolf wrote:
> > > On Wed, 2022-05-04 at 12:13 -0700, Ioi Lam wrote:
> > > > ====================================
> > > > 
> > > > How about this:
> > > > 
> > > > When a JVM starts up, it creates the hsperfdata with a UUID instead of
> > > > PID. E.g.,
> > > > 
> > > >       /tmp/hsperfdata_user/0da29ace76f76f61
> > > > 
> > > > Today, jps reads /proc/*/status to determine the NSpid, so we are doing
> > > > a lot of processing already. Instead, we should read /proc/*/maps and
> > > > scan for something with this pattern:
> > > > 
> > > >       7ffb2536d000-7ffb25375000 rw-s ....
> > > > /tmp/hsperfdata_user/0da29ace76f76f61
> > > > 
> > > > If we can find this pattern, we know we have a JVM process that the
> > > > current user can attach to.
> > > > 
> > > > When attaching to this process, we will use this file instead
> > > > 
> > > > /proc/$PID/root/tmp/.java_pid0da29ace76f76f61
> > > > 
> > > > This should work with
> > > > 
> > > > - shared /tmp across containers
> > > > - nested containers
> > > Wouldn't this break with the work-around Vitaly employed? I.e. using
> > > 
> > > -XX:+PerfDisableSharedMem
> > > 
> > > $ ps ax | grep java
> > >    10449 pts/4    Sl+    0:00 
> > > ./build/linux-x86_64-normal-server-fastdebug/images/jdk/bin/java 
> > > -XX:+PerfDisableSharedMem Hello
> > >    10744 pts/5    S+     0:00 grep --color=auto java
> > > $ grep hsperf /proc/10449/maps
> > > $ jcmd 10449 VM.version
> > > 10449:
> > > OpenJDK 64-Bit Server VM version 
> > > 11.0.16-internal+0-adhoc.sgehwolf.jdk11u-dev
> > > JDK 11.0.16
> > > $ jcmd -l
> > > 10857 jdk.jcmd/sun.tools.jcmd.JCmd -l
> > 
> > I think we can create a fake mmap region when 
> > -XX:+PerfDisableSharedMem is used. E.g.,
> > 
> > 7ffb2536d000-7ffb25375000 rw-s .... 
> > /tmp/hsperfdata_user/0da29ace76f76f61-disabled
> > 
> > So we can reliably discover the .java_pidxxxxx file used for attachment:
> > 
> > jcmd $PID
> > -> /proc/$PID/maps
> > -> /tmp/hsperfdata_user/0da29ace76f76f61-disabled
> > -> /proc/$PID/root/tmp/.java_pid0da29ace76f76f61
> > 
> 
> An alternative is to set an environment variable like 
> JVM_ATTACH_UUID=0da29ace76f76f61 and we can get that from 
> /proc/*/environ , which might be more light-weight.

That idea sounds good to me. +1

Thanks,
Severin



More information about the hotspot-runtime-dev mailing list