Skip to content

8313083: Print 'rss' and 'cache' as part of the container information #3639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/hotspot/os/linux/cgroupSubsystem_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ class CgroupSubsystem: public CHeapObj<mtInternal> {
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;
Expand Down
11 changes: 11 additions & 0 deletions src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,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",
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,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", "%1023s", mem_soft_limit_str, 1024);
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/hotspot/os/linux/osContainer_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,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 != nullptr, "cgroup subsystem not available");
return cgroup_subsystem->rss_usage_in_bytes();
}

jlong OSContainer::cache_usage_in_bytes() {
assert(cgroup_subsystem != nullptr, "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);
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/os/linux/osContainer_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,8 @@ bool 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);

Expand Down
4 changes: 3 additions & 1 deletion test/hotspot/jtreg/containers/docker/TestMisc.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ private static void checkContainerInfo(OutputAnalyzer out) throws Exception {
"Maximum Memory Usage",
"memory_max_usage_in_bytes",
"maximum number of tasks",
"current number of tasks"
"current number of tasks",
"rss_usage_in_bytes",
"cache_usage_in_bytes"
};

for (String s : expectedToContain) {
Expand Down