RFR: 8302744: Refactor Hotspot container detection code
Severin Gehwolf
sgehwolf at openjdk.org
Tue May 7 09:39:54 UTC 2024
On Mon, 6 May 2024 16:51:33 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> Please review this container detection code refactoring in hotspot. The main point of this is to
>>
>> - get rid of the `GET_CONTAINER_INFO` macros which hide too many things under the hood
>> - prevent refactoring of the code (since `GET_CONTAINER_INFO` macros short-return and are therefore not portable; at least not without some risk)
>> - make the code easier to understand
>> - allow for better testing via `gtest`
>> - separate multi-line parsing from single line parsing for clarity.
>>
>> Testing:
>> - [x] GHA
>> - [x] `gtest:cgroupTest` tests
>> - [x] Container tests on Linux with cgroup v1 (legacy) and cgroup v2. All pass.
>>
>> Thoughts?
>
> src/hotspot/os/linux/cgroupSubsystem_linux.hpp line 87:
>
>> 85: return OSCONTAINER_ERROR;
>> 86: }
>> 87:
>
> We can simplify this coding by just using fscanf. No need to call fgets + sscanf.
I was taking the advise of the `scanf` man page here:
The scanf() family of functions scans input like sscanf(3), but read
from a FILE. It is very difficult to use these functions correctly,
and it is preferable to read entire lines with fgets(3) or getline(3)
and parse them later with sscanf(3) or more specialized functions such
as strtol(3).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19060#discussion_r1592122105
More information about the hotspot-runtime-dev
mailing list