From e7898998d5ab24d7520a03b87c9c6bf491f8f980 Mon Sep 17 00:00:00 2001 From: Jonathan Dowland Date: Wed, 19 Nov 2025 16:34:25 +0000 Subject: [PATCH 1/2] 8313083: Print 'rss' and 'cache' as part of the container information Reviewed-by: andrew, sgehwolf Backport-of: aeb2d2d0ce17da3aa7d49679beb4da2dd6f341ad --- hotspot/src/os/linux/vm/cgroupSubsystem_linux.hpp | 2 ++ hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.cpp | 11 +++++++++++ hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.hpp | 2 ++ hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.cpp | 12 ++++++++++++ hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.hpp | 2 ++ hotspot/src/os/linux/vm/osContainer_linux.cpp | 10 ++++++++++ hotspot/src/os/linux/vm/osContainer_linux.hpp | 2 ++ hotspot/src/os/linux/vm/os_linux.cpp | 2 ++ hotspot/test/runtime/containers/docker/TestMisc.java | 6 +++++- 9 files changed, 48 insertions(+), 1 deletion(-) diff --git a/hotspot/src/os/linux/vm/cgroupSubsystem_linux.hpp b/hotspot/src/os/linux/vm/cgroupSubsystem_linux.hpp index 0cc0d5b628..ba058cd8f1 100644 --- a/hotspot/src/os/linux/vm/cgroupSubsystem_linux.hpp +++ b/hotspot/src/os/linux/vm/cgroupSubsystem_linux.hpp @@ -269,6 +269,8 @@ class CgroupSubsystem: public CHeapObj { virtual jlong memory_and_swap_limit_in_bytes() = 0; virtual jlong memory_soft_limit_in_bytes() = 0; virtual jlong memory_max_usage_in_bytes() = 0; + virtual jlong rss_usage_in_bytes() = 0; + virtual jlong cache_usage_in_bytes() = 0; virtual char * cpu_cpuset_cpus() = 0; virtual char * cpu_cpuset_memory_nodes() = 0; diff --git a/hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.cpp b/hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.cpp index b5c14173f6..054564211c 100644 --- a/hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.cpp +++ b/hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.cpp @@ -201,6 +201,17 @@ jlong CgroupV1Subsystem::memory_max_usage_in_bytes() { return memmaxusage; } +jlong CgroupV1Subsystem::rss_usage_in_bytes() { + GET_CONTAINER_INFO_LINE(julong, _memory->controller(), "/memory.stat", + "rss", JULONG_FORMAT, JULONG_FORMAT, rss); + return rss; +} + +jlong CgroupV1Subsystem::cache_usage_in_bytes() { + GET_CONTAINER_INFO_LINE(julong, _memory->controller(), "/memory.stat", + "cache", JULONG_FORMAT, JULONG_FORMAT, cache); + return cache; +} jlong CgroupV1Subsystem::kernel_memory_usage_in_bytes() { GET_CONTAINER_INFO(jlong, _memory->controller(), "/memory.kmem.usage_in_bytes", diff --git a/hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.hpp b/hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.hpp index bdce7b5631..2008cd2261 100644 --- a/hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.hpp +++ b/hotspot/src/os/linux/vm/cgroupV1Subsystem_linux.hpp @@ -79,6 +79,8 @@ class CgroupV1Subsystem: public CgroupSubsystem { jlong memory_soft_limit_in_bytes(); jlong memory_usage_in_bytes(); jlong memory_max_usage_in_bytes(); + jlong rss_usage_in_bytes(); + jlong cache_usage_in_bytes(); jlong kernel_memory_usage_in_bytes(); jlong kernel_memory_limit_in_bytes(); diff --git a/hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.cpp b/hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.cpp index 840042b247..824679223d 100644 --- a/hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.cpp +++ b/hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.cpp @@ -160,6 +160,18 @@ jlong CgroupV2Subsystem::memory_max_usage_in_bytes() { return OSCONTAINER_ERROR; // not supported } +jlong CgroupV2Subsystem::rss_usage_in_bytes() { + GET_CONTAINER_INFO_LINE(julong, _memory->controller(), "/memory.stat", + "anon", JULONG_FORMAT, JULONG_FORMAT, rss); + return rss; +} + +jlong CgroupV2Subsystem::cache_usage_in_bytes() { + GET_CONTAINER_INFO_LINE(julong, _memory->controller(), "/memory.stat", + "file", JULONG_FORMAT, JULONG_FORMAT, cache); + return cache; +} + char* CgroupV2Subsystem::mem_soft_limit_val() { GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.low", "Memory Soft Limit is: %s", "%s", mem_soft_limit_str, 1024); diff --git a/hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.hpp b/hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.hpp index 22199dc29c..7ca08f8cc5 100644 --- a/hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.hpp +++ b/hotspot/src/os/linux/vm/cgroupV2Subsystem_linux.hpp @@ -78,6 +78,8 @@ class CgroupV2Subsystem: public CgroupSubsystem { jlong memory_soft_limit_in_bytes(); jlong memory_usage_in_bytes(); jlong memory_max_usage_in_bytes(); + jlong rss_usage_in_bytes(); + jlong cache_usage_in_bytes(); char * cpu_cpuset_cpus(); char * cpu_cpuset_memory_nodes(); diff --git a/hotspot/src/os/linux/vm/osContainer_linux.cpp b/hotspot/src/os/linux/vm/osContainer_linux.cpp index 33a7442ea8..0b286cda53 100644 --- a/hotspot/src/os/linux/vm/osContainer_linux.cpp +++ b/hotspot/src/os/linux/vm/osContainer_linux.cpp @@ -104,6 +104,16 @@ jlong OSContainer::memory_max_usage_in_bytes() { return cgroup_subsystem->memory_max_usage_in_bytes(); } +jlong OSContainer::rss_usage_in_bytes() { + assert(cgroup_subsystem != NULL, "cgroup subsystem not available"); + return cgroup_subsystem->rss_usage_in_bytes(); +} + +jlong OSContainer::cache_usage_in_bytes() { + assert(cgroup_subsystem != NULL, "cgroup subsystem not available"); + return cgroup_subsystem->cache_usage_in_bytes(); +} + void OSContainer::print_version_specific_info(outputStream* st) { assert(cgroup_subsystem != NULL, "cgroup subsystem not available"); cgroup_subsystem->print_version_specific_info(st); diff --git a/hotspot/src/os/linux/vm/osContainer_linux.hpp b/hotspot/src/os/linux/vm/osContainer_linux.hpp index eb2f53f2a4..27b71f4228 100644 --- a/hotspot/src/os/linux/vm/osContainer_linux.hpp +++ b/hotspot/src/os/linux/vm/osContainer_linux.hpp @@ -55,6 +55,8 @@ class OSContainer: AllStatic { static jlong memory_soft_limit_in_bytes(); static jlong memory_usage_in_bytes(); static jlong memory_max_usage_in_bytes(); + static jlong rss_usage_in_bytes(); + static jlong cache_usage_in_bytes(); static int active_processor_count(); diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 9b42126ec4..9ef6367f48 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -2347,6 +2347,8 @@ void os::Linux::print_container_info(outputStream* st) { OSContainer::print_container_helper(st, OSContainer::memory_soft_limit_in_bytes(), "memory_soft_limit_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_usage_in_bytes(), "memory_usage_in_bytes"); OSContainer::print_container_helper(st, OSContainer::memory_max_usage_in_bytes(), "memory_max_usage_in_bytes"); + OSContainer::print_container_helper(st, OSContainer::rss_usage_in_bytes(), "rss_usage_in_bytes"); + OSContainer::print_container_helper(st, OSContainer::cache_usage_in_bytes(), "cache_usage_in_bytes"); OSContainer::print_version_specific_info(st); diff --git a/hotspot/test/runtime/containers/docker/TestMisc.java b/hotspot/test/runtime/containers/docker/TestMisc.java index ead0d781b9..f7d154b642 100644 --- a/hotspot/test/runtime/containers/docker/TestMisc.java +++ b/hotspot/test/runtime/containers/docker/TestMisc.java @@ -102,7 +102,11 @@ private static void checkContainerInfo(OutputAnalyzer out) throws Exception { "Memory Soft Limit", "Memory Usage", "Maximum Memory Usage", - "memory_max_usage_in_bytes" + "memory_max_usage_in_bytes", + "maximum number of tasks", + "current number of tasks", + "rss_usage_in_bytes", + "cache_usage_in_bytes" }; for (String s : expectedToContain) { From 0be5b9f27d8422e7a76f5dc89180b8baf3242b95 Mon Sep 17 00:00:00 2001 From: Jonathan Dowland Date: Tue, 25 Nov 2025 10:34:47 +0000 Subject: [PATCH 2/2] remove reporting on tasks included in error; part of context of backport but not added by the backport. Signed-off-by: Jonathan Dowland --- hotspot/test/runtime/containers/docker/TestMisc.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/hotspot/test/runtime/containers/docker/TestMisc.java b/hotspot/test/runtime/containers/docker/TestMisc.java index f7d154b642..c35f87013e 100644 --- a/hotspot/test/runtime/containers/docker/TestMisc.java +++ b/hotspot/test/runtime/containers/docker/TestMisc.java @@ -103,8 +103,6 @@ private static void checkContainerInfo(OutputAnalyzer out) throws Exception { "Memory Usage", "Maximum Memory Usage", "memory_max_usage_in_bytes", - "maximum number of tasks", - "current number of tasks", "rss_usage_in_bytes", "cache_usage_in_bytes" };