Skip to content

Commit 9b42765

Browse files
author
Jonathan Dowland
committed
8313083: Print 'rss' and 'cache' as part of the container information
Reviewed-by: andrew, sgehwolf Backport-of: aeb2d2d0ce17da3aa7d49679beb4da2dd6f341ad
1 parent a9de6b6 commit 9b42765

File tree

9 files changed

+46
-1
lines changed

9 files changed

+46
-1
lines changed

src/hotspot/os/linux/cgroupSubsystem_linux.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ class CgroupSubsystem: public CHeapObj<mtInternal> {
252252
virtual jlong memory_and_swap_limit_in_bytes() = 0;
253253
virtual jlong memory_soft_limit_in_bytes() = 0;
254254
virtual jlong memory_max_usage_in_bytes() = 0;
255+
virtual jlong rss_usage_in_bytes() = 0;
256+
virtual jlong cache_usage_in_bytes() = 0;
255257

256258
virtual char * cpu_cpuset_cpus() = 0;
257259
virtual char * cpu_cpuset_memory_nodes() = 0;

src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ jlong CgroupV1Subsystem::memory_max_usage_in_bytes() {
198198
return memmaxusage;
199199
}
200200

201+
jlong CgroupV1Subsystem::rss_usage_in_bytes() {
202+
GET_CONTAINER_INFO_LINE(julong, _memory->controller(), "/memory.stat",
203+
"rss", JULONG_FORMAT, JULONG_FORMAT, rss);
204+
return rss;
205+
}
206+
207+
jlong CgroupV1Subsystem::cache_usage_in_bytes() {
208+
GET_CONTAINER_INFO_LINE(julong, _memory->controller(), "/memory.stat",
209+
"cache", JULONG_FORMAT, JULONG_FORMAT, cache);
210+
return cache;
211+
}
201212

202213
jlong CgroupV1Subsystem::kernel_memory_usage_in_bytes() {
203214
GET_CONTAINER_INFO(jlong, _memory->controller(), "/memory.kmem.usage_in_bytes",

src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class CgroupV1Subsystem: public CgroupSubsystem {
7979
jlong memory_soft_limit_in_bytes();
8080
jlong memory_usage_in_bytes();
8181
jlong memory_max_usage_in_bytes();
82+
jlong rss_usage_in_bytes();
83+
jlong cache_usage_in_bytes();
8284

8385
jlong kernel_memory_usage_in_bytes();
8486
jlong kernel_memory_limit_in_bytes();

src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ jlong CgroupV2Subsystem::memory_max_usage_in_bytes() {
148148
return OSCONTAINER_ERROR; // not supported
149149
}
150150

151+
jlong CgroupV2Subsystem::rss_usage_in_bytes() {
152+
GET_CONTAINER_INFO_LINE(julong, _memory->controller(), "/memory.stat",
153+
"anon", JULONG_FORMAT, JULONG_FORMAT, rss);
154+
return rss;
155+
}
156+
157+
jlong CgroupV2Subsystem::cache_usage_in_bytes() {
158+
GET_CONTAINER_INFO_LINE(julong, _memory->controller(), "/memory.stat",
159+
"file", JULONG_FORMAT, JULONG_FORMAT, cache);
160+
return cache;
161+
}
162+
151163
char* CgroupV2Subsystem::mem_soft_limit_val() {
152164
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.low",
153165
"Memory Soft Limit is: %s", "%s", mem_soft_limit_str, 1024);

src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class CgroupV2Subsystem: public CgroupSubsystem {
7878
jlong memory_soft_limit_in_bytes();
7979
jlong memory_usage_in_bytes();
8080
jlong memory_max_usage_in_bytes();
81+
jlong rss_usage_in_bytes();
82+
jlong cache_usage_in_bytes();
8183

8284
char * cpu_cpuset_cpus();
8385
char * cpu_cpuset_memory_nodes();

src/hotspot/os/linux/osContainer_linux.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ jlong OSContainer::memory_max_usage_in_bytes() {
100100
return cgroup_subsystem->memory_max_usage_in_bytes();
101101
}
102102

103+
jlong OSContainer::rss_usage_in_bytes() {
104+
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
105+
return cgroup_subsystem->rss_usage_in_bytes();
106+
}
107+
108+
jlong OSContainer::cache_usage_in_bytes() {
109+
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
110+
return cgroup_subsystem->cache_usage_in_bytes();
111+
}
112+
103113
void OSContainer::print_version_specific_info(outputStream* st) {
104114
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
105115
cgroup_subsystem->print_version_specific_info(st);

src/hotspot/os/linux/osContainer_linux.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class OSContainer: AllStatic {
5555
static jlong memory_soft_limit_in_bytes();
5656
static jlong memory_usage_in_bytes();
5757
static jlong memory_max_usage_in_bytes();
58+
static jlong rss_usage_in_bytes();
59+
static jlong cache_usage_in_bytes();
5860

5961
static int active_processor_count();
6062

src/hotspot/os/linux/os_linux.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,8 @@ void os::Linux::print_container_info(outputStream* st) {
26142614
OSContainer::print_container_helper(st, OSContainer::memory_soft_limit_in_bytes(), "memory_soft_limit_in_bytes");
26152615
OSContainer::print_container_helper(st, OSContainer::memory_usage_in_bytes(), "memory_usage_in_bytes");
26162616
OSContainer::print_container_helper(st, OSContainer::memory_max_usage_in_bytes(), "memory_max_usage_in_bytes");
2617+
OSContainer::print_container_helper(st, OSContainer::rss_usage_in_bytes(), "rss_usage_in_bytes");
2618+
OSContainer::print_container_helper(st, OSContainer::cache_usage_in_bytes(), "cache_usage_in_bytes");
26172619

26182620
OSContainer::print_version_specific_info(st);
26192621

test/hotspot/jtreg/containers/docker/TestMisc.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ private static void checkContainerInfo(OutputAnalyzer out) throws Exception {
117117
"Maximum Memory Usage",
118118
"memory_max_usage_in_bytes",
119119
"maximum number of tasks",
120-
"current number of tasks"
120+
"current number of tasks",
121+
"rss_usage_in_bytes",
122+
"cache_usage_in_bytes"
121123
};
122124

123125
for (String s : expectedToContain) {

0 commit comments

Comments
 (0)