On Thu, 9 Sep 2021 09:21:59 GMT, Matthias Baesken <mbaes...@openjdk.org> wrote:
> https://bugs.openjdk.java.net/browse/JDK-8266490 > extended the OSContainer API in order to also support the pids controller of > cgroups. However only pids.max output was added with 8266490. > There is a second parameter pids.current , see > https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#pid > that would be helpful too and can be added to the OSContainer API . > pids.current : > A read-only single value file which exists on all cgroups. > The number of processes currently in the cgroup and its descendants. > > Best regards, Matthias This could get simplified a bit as we don't need to consider `max` values for `pids.current`. src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp line 287: > 285: * OSCONTAINER_ERROR for not supported > 286: */ > 287: jlong CgroupV1Subsystem::pids_current() { `pids.current` never contains a string `max` (for unlimited). Therefore, we shouldn't need to do the `pids_current_val` -> `limit_from_str()` trick. We should be able to use `GET_CONTAINER_INFO(int, [...]` akin to `cpu_quota`. `int` or `long` would both be suitable. Up to you to decide which data type to use. I don't think it'll ever be beyond the maximum integrer value. src/java.base/linux/classes/jdk/internal/platform/cgroupv1/CgroupV1Subsystem.java line 421: > 419: public long getPidsCurrent() { > 420: String pidsCurrentStr = > CgroupSubsystemController.getStringValue(pids, "pids.current"); > 421: return CgroupSubsystem.limitFromString(pidsCurrentStr); `return getLongValue(pids, "pids.current");` should be sufficient here. test/hotspot/jtreg/containers/docker/TestPids.java line 97: > 95: System.out.println("DEBUG: parts.length = " + > parts.length); > 96: if (expectedValue.equals("no_value_expected")) { > 97: System.out.println("No value expected for " + > lineMarker); Perhaps this debug print could say `System.out.println("Found '" + lineMarker + "' with value: '" + <value> +"');` and actually parse the number as we'd expect an integer there? ------------- Changes requested by sgehwolf (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/5437