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
Conversation
|
Webrevs
|
This could get simplified a bit as we don't need to consider max
values for pids.current
.
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
pids.current
never contains a string max
(for unlimited). Therefore, we shouldn't need to do the pids_current_val
-> limit_from_str()
trick. We should be able to use GET_CONTAINER_INFO(int, [...]
akin to cpu_quota
. int
or long
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.
String pidsCurrentStr = CgroupSubsystemController.getStringValue(pids, "pids.current"); | ||
return CgroupSubsystem.limitFromString(pidsCurrentStr); |
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.
return getLongValue(pids, "pids.current");
should be sufficient here.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this debug print could say System.out.println("Found '" + lineMarker + "' with value: '" + <value> +"');
and actually parse the number as we'd expect an integer there?
Hi Severin, I added another commit dealing with your comments. |
Sorry for not being clear earlier. I meant that we can do those simplifications throughout.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed.
@@ -252,6 +252,15 @@ char* CgroupV1Subsystem::pids_max_val() { | |||
return os::strdup(pidsmax); | |||
} | |||
|
|||
char* CgroupV1Subsystem::pids_current_val() { |
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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need that function.
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
This should use something akin to memory_usage_in_bytes
in this class. pids_current_val()
isn't needed.
String pidsCurrentStr = CgroupSubsystemController.getStringValue(unified, "pids.current"); | ||
return CgroupSubsystem.limitFromString(pidsCurrentStr); |
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 should use: return getLongVal("pids.current");
instead.
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should add this to -XshowSettings:system
output at all. What's reported there is enforced limits. Note that current memory usage isn't shown either.
System.out.println("Found " + lineMarker + " with value: " + ivalue); | ||
try { | ||
int ai = Integer.parseInt(ivalue); |
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.
Could you move the debug print line to after line 101, please. It could say:
System.out.println("Found " + lineMarker + " with value: " + ai + ". PASS.");
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.
the debug println has been moved down.
Hi Severin, I adjusted my change following your latest comments. Thanks, Matthias |
Looks fine. I suggest to move the debug printing from line 99 to after line 101 as suggested here:
#5437 (comment)
HotSpot changes look good to me. I have a comment on the test.
@@ -93,6 +93,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("no_value_expected")) { | |||
Asserts.assertEquals(parts.length, 2); |
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.
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:
// These messages are generated by Docker
static final String warning_kernel_no_pids_support = "WARNING: Your kernel does not support pids limit capabilities";
static final String no_value_expected = "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.
Oh, I misunderstood the test. "no_value_expected" was passed in from testPids()
in this file, but that's confusing because you are expecting an integer value. Maybe it should be "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.
Maybe it should be "any_integer"?
+1
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.
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".
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 comment
The 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
@MBaesken This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 85 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
/integrate |
Going to push as commit d4546b6.
Your commit was automatically rebased without conflicts. |
https://bugs.openjdk.java.net/browse/JDK-8266490
extended the OSContainer API in order to also support the pids controller of cgroups. However only pids.max output was added with 8266490.
There is a second parameter pids.current , see https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#pid
that would be helpful too and can be added to the OSContainer API .
pids.current :
A read-only single value file which exists on all cgroups.
The number of processes currently in the cgroup and its descendants.
Best regards, Matthias
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5437/head:pull/5437
$ git checkout pull/5437
Update a local copy of the PR:
$ git checkout pull/5437
$ git pull https://git.openjdk.java.net/jdk pull/5437/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5437
View PR using the GUI difftool:
$ git pr show -t 5437
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5437.diff