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 all commits
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 |
---|---|---|
@@ -249,3 +249,16 @@ 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 |
||
GET_CONTAINER_INFO(jlong, _unified, "/pids.current", | ||
"Current number of tasks is: " JLONG_FORMAT, JLONG_FORMAT, pids_current); | ||
return pids_current; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -46,6 +46,8 @@ | ||
public class TestPids { | ||
private static final String imageName = Common.imageName("pids"); | ||
|
||
static final String warning_kernel_no_pids_support = "WARNING: Your kernel does not support pids limit capabilities"; | ||
|
||
public static void main(String[] args) throws Exception { | ||
if (!DockerTestUtils.canTestDocker()) { | ||
return; | ||
@@ -83,7 +85,7 @@ private static void checkResult(List<String> lines, String lineMarker, String ex | ||
boolean lineMarkerFound = false; | ||
|
||
for (String line : lines) { | ||
if (line.contains("WARNING: Your kernel does not support pids limit capabilities")) { | ||
if (line.contains(warning_kernel_no_pids_support)) { | ||
System.out.println("Docker pids limitation seems not to work, avoiding check"); | ||
return; | ||
} | ||
@@ -93,6 +95,17 @@ 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("any_integer")) { | ||
Asserts.assertEquals(parts.length, 2); | ||
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. Is "no_value_expected" generated by Docker? I searched the entire HotSpot source code and couldn't find it. I also couldn't find "WARNING: Your kernel does not support pids limit capabilities". To make it easier to understand this test, I would suggest grouping all messages that were generated outside of HotSpot into something like:
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. Oh, I misunderstood the test. "no_value_expected" was passed in from 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.
+1 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.
Hi, this warning is showing up on some of our Linux ppc64le machines where the pids limit capabilities is not supported. Best regards, Matthias 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. Hello, I adjusted to any_integer, and introduced the "final String warning_kernel_no_pids_support" . I think the message is more related to the kernel features so I did not add the add the 'generated by Docker' comment. Best regards, Matthias |
||
String ivalue = parts[1].replaceAll("\\s",""); | ||
try { | ||
int ai = Integer.parseInt(ivalue); | ||
System.out.println("Found " + lineMarker + " with value: " + ai + ". PASS."); | ||
} catch (NumberFormatException ex) { | ||
throw new RuntimeException("Could not convert " + ivalue + " to an integer, log line was " + line); | ||
} | ||
break; | ||
} | ||
|
||
Asserts.assertEquals(parts.length, 2); | ||
String actual = parts[1].replaceAll("\\s",""); | ||
@@ -137,6 +150,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: ", "any_integer"); | ||
} | ||
|
||
} |
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.
pids.current
never contains a stringmax
(for unlimited). Therefore, we shouldn't need to do thepids_current_val
->limit_from_str()
trick. We should be able to useGET_CONTAINER_INFO(int, [...]
akin tocpu_quota
.int
orlong
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.