On Wed, 8 Jul 2026 11:27:50 GMT, Kevin Walls <[email protected]> wrote:

>> src/jdk.internal.jvmstat/linux/classes/sun/jvmstat/PlatformSupportImpl.java 
>> line 207:
>> 
>>> 205:                 seenProc = true;
>>> 206:                 continue;
>>> 207:             }
>> 
>> Q1: How would the above work if the TMP directory was set/customized with 
>> the option:
>>  `-XX:AltTempDir=/work/proc/tmp` ? What happens if there are multiple `proc` 
>> path folders?
>
> I thought I had suggested a fairly naive getLocalVmId(File) in 
> PlatformSupportImpl.java, but it does handle extra "proc" elements.
> It needs to parse directories like:  
> /proc/{pid}/root/tmp/hsperfdata_{user}/{nspid}
> 
> -XX:AltTempDir=/tmp/proc/scratch does not fool it, as it will be parsing 
> /proc/PID/tmp/proc/scratch/...
> 
> ..and only looks at PID after the first "proc".  Subsequent "proc" elements 
> mean nothing.
> 
> What does fool it, is AltTempDir=/tmp/x/hsperfdata_kwalls/foo
> ..where it assumes hsperfdata_ in a path element is followed by a pid/nspid.
> 
> We can handle the Integer parsing, and continue to the next path element.
> 
> But that means it's a problem if using 
> AltTempDir=/tmp/x/hsperfdata_kwalls/foo/123 
> So, remove the "break" and always count the last pid/nspid we see.
> 
> @coleenp This update works with these crazier AltTempDir settings:
> 
> "src/jdk.internal.jvmstat/linux/classes/sun/jvmstat/PlatformSupportImpl.java" 
> line 217 
>             if (seenPerf) {
>                 // Parse pid or nspid after seeing "hsperfdata_"
>                 try {
>                     if (hostpid == -1) {
>                         hostpid = Integer.parseInt(s);
>                     } else {
>                         nspid = Integer.parseInt(s);
>                     }
>                 } catch (NumberFormatException _) {
>                     // e.g. Extra "hsperfdata_" found in path from AltTempDir.
>                 }
>              }

I added this change but not sure how this parsing should work.  If the first 
thing is /proc, we throw NumberFormatException if the second thing isn't a 
number.  What about AltTempDir=/proc/proc/proc ?  In a container is this 
/proc/<pid>/root/proc/proc/proc/hsperfdata_user/pid ?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/31407#discussion_r3543936652

Reply via email to