RFR: 8349988: Change cgroup version detection logic to not depend on /proc/cgroups [v4]

Ashutosh Mehra asmehra at openjdk.org
Tue Apr 1 04:40:47 UTC 2025


On Mon, 31 Mar 2025 21:32:31 GMT, Thomas Fitzsimmons <duke at openjdk.org> wrote:

>> src/hotspot/os/linux/cgroupSubsystem_linux.cpp line 81:
>> 
>>> 79:   // file system magic.  If it does not then heuristics are required to determine
>>> 80:   // if cgroups v1 is usable or not.
>>> 81:   if (statfs(sys_fs_cgroup, &fsstat) != -1) {
>> 
>> I feel this logic should be moved to `determine_type` as it is responsible for determining the version of the cgroup subsystem.
>
> OK, I tend to agree; I will investigate alternatives.  I did consider putting the `statfs` logic inside but ended up leaving it outside because `determine_type` is called by the `whitebox` framework, and "mocking" `statfs` is not possible with regular files.  The idea is to allow the test suite to simply mock the `statfs` result via the boolean `cgroups_v2_enabled` argument.

One option is to pass an argument to `determine_type` to indicate it is being called from the test suite and skip the call to `statfs` in such case.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23811#discussion_r2022130118


More information about the hotspot-dev mailing list