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
JDK-8273526: Extend the OSContainer API pids controller with pids.current #5437
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -252,6 +252,15 @@ char* CgroupV1Subsystem::pids_max_val() { | ||
return os::strdup(pidsmax); | ||
} | ||
|
||
char* CgroupV1Subsystem::pids_current_val() { | ||
GET_CONTAINER_INFO_CPTR(cptr, _pids, "/pids.current", | ||
"Current number of tasks is: %s", "%s %*d", pids_current, 1024); | ||
if (pids_current == NULL) { | ||
return NULL; | ||
} | ||
return os::strdup(pids_current); | ||
} | ||
|
||
/* pids_max | ||
* | ||
* Return the maximum number of tasks available to the process | ||
@@ -266,3 +275,17 @@ jlong CgroupV1Subsystem::pids_max() { | ||
char * pidsmax_str = pids_max_val(); | ||
return limit_from_str(pidsmax_str); | ||
} | ||
|
||
/* pids_current | ||
* | ||
* The number of tasks currently in the cgroup (and its descendants) of the process | ||
* | ||
* return: | ||
* current number of tasks | ||
* OSCONTAINER_ERROR for not supported | ||
*/ | ||
jlong CgroupV1Subsystem::pids_current() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (_pids == NULL) return OSCONTAINER_ERROR; | ||
char * pidscurrent_str = pids_current_val(); | ||
return limit_from_str(pidscurrent_str); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -88,6 +88,7 @@ class CgroupV1Subsystem: public CgroupSubsystem { | ||
int cpu_shares(); | ||
|
||
jlong pids_max(); | ||
jlong pids_current(); | ||
|
||
const char * container_type() { | ||
return "cgroupv1"; | ||
@@ -106,6 +107,7 @@ class CgroupV1Subsystem: public CgroupSubsystem { | ||
CgroupV1Controller* _pids = NULL; | ||
|
||
char * pids_max_val(); | ||
char * pids_current_val(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed. |
||
|
||
public: | ||
CgroupV1Subsystem(CgroupV1Controller* cpuset, | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -235,6 +235,16 @@ char* CgroupV2Subsystem::pids_max_val() { | ||
return os::strdup(pidsmax); | ||
} | ||
|
||
char* CgroupV2Subsystem::pids_current_val() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need that function. |
||
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/pids.current", | ||
"Current number of tasks is: %s", "%s %*d", pids_current, 1024); | ||
if (pids_current == NULL) { | ||
return NULL; | ||
} | ||
return os::strdup(pids_current); | ||
} | ||
|
||
|
||
/* pids_max | ||
* | ||
* Return the maximum number of tasks available to the process | ||
@@ -249,3 +259,15 @@ jlong CgroupV2Subsystem::pids_max() { | ||
return limit_from_str(pidsmax_str); | ||
} | ||
|
||
/* pids_current | ||
* | ||
* The number of tasks currently in the cgroup (and its descendants) of the process | ||
* | ||
* return: | ||
* current number of tasks | ||
* OSCONTAINER_ERROR for not supported | ||
*/ | ||
jlong CgroupV2Subsystem::pids_current() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use something akin to |
||
char * pidscurrent_str = pids_current_val(); | ||
return limit_from_str(pidscurrent_str); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -416,6 +416,11 @@ public long getPidsMax() { | ||
return CgroupSubsystem.limitFromString(pidsMaxStr); | ||
} | ||
|
||
public long getPidsCurrent() { | ||
String pidsCurrentStr = CgroupSubsystemController.getStringValue(pids, "pids.current"); | ||
return CgroupSubsystem.limitFromString(pidsCurrentStr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
/***************************************************************** | ||
* BlKIO Subsystem | ||
****************************************************************/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -311,6 +311,12 @@ public long getPidsMax() { | ||
return CgroupSubsystem.limitFromString(pidsMaxStr); | ||
} | ||
|
||
@Override | ||
public long getPidsCurrent() { | ||
String pidsCurrentStr = CgroupSubsystemController.getStringValue(unified, "pids.current"); | ||
return CgroupSubsystem.limitFromString(pidsCurrentStr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use: |
||
} | ||
|
||
@Override | ||
public long getBlkIOServiceCount() { | ||
return sumTokensIOStat(CgroupV2Subsystem::lineToRandWIOs); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -408,6 +408,11 @@ public static void printSystemMetrics() { | ||
limit = c.getPidsMax(); | ||
ostream.println(formatLimitString(limit, INDENT + "Maximum Processes Limit: ", | ||
longRetvalNotSupported, false)); | ||
|
||
long val = c.getPidsCurrent(); | ||
ostream.println(formatLimitString(val, INDENT + "Current number of processes: ", | ||
longRetvalNotSupported, false)); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we should add this to |
||
ostream.println(""); | ||
} | ||
|
||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -93,6 +93,10 @@ private static void checkResult(List<String> lines, String lineMarker, String ex | ||
String[] parts = line.split(":"); | ||
System.out.println("DEBUG: line = " + line); | ||
System.out.println("DEBUG: parts.length = " + parts.length); | ||
if (expectedValue.equals("no_value_expected")) { | ||
System.out.println("No value expected for " + lineMarker); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this debug print could say |
||
break; | ||
} | ||
|
||
Asserts.assertEquals(parts.length, 2); | ||
String actual = parts[1].replaceAll("\\s",""); | ||
@@ -137,6 +141,8 @@ private static void testPids(String value) throws Exception { | ||
} else { | ||
checkResult(lines, "Maximum number of tasks is: ", value); | ||
} | ||
// current number of tasks value is hard to predict, so better expect no value | ||
checkResult(lines, "Current number of tasks is: ", "no_value_expected"); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can get removed. It's unused now.