RFR: 8321971: Improve the user name detection logic in perfMemory get_user_name_slow [v2]

Chris Plummer cjplummer at openjdk.org
Tue Dec 19 21:53:48 UTC 2023


On Mon, 18 Dec 2023 10:24:06 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Can I please get a review of this change which proposes to improve the code in `get_user_name_slow` function, which is used to identify the target JVM owner's user name? This addresses https://bugs.openjdk.org/browse/JDK-8321971.
>> 
>> As noted in that JBS issue, in its current form, the nested loop ends up iterating over the directory contents of `hsperfdata_xxx` directory and then for each iteration it checks if the name of the entry matches the pid. This iteration shouldn't be needed and instead one could look for a file named `<pid>` within that directory.
>> 
>> No new test has been added, given the nature of this change. Existing tier1, tier2, tier3 and svc_tools tests pass with this change on Linux, Windows and macosx.
>
> Jaikiran Pai has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - David's review comments - reduce if blocks and release the array outside if block
>  - David's review comment - punctuation

src/hotspot/os/posix/perfMemory_posix.cpp line 609:

> 607:     if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) {
> 608: 
> 609:       if (statbuf.st_ctime > oldest_ctime) {

This `if` expression is repeats what we already know to be true from the previous `if` expression.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17104#discussion_r1431895566


More information about the hotspot-runtime-dev mailing list