Skip to content

Commit c9ce3d6

Browse files
committed
8254001: [Metrics] Enhance parsing of cgroup interface files for version detection
Reviewed-by: sgehwolf Backport-of: a50725db2ab621e1a17cb5505f78e4bc73972a27
1 parent b2619cf commit c9ce3d6

File tree

5 files changed

+453
-274
lines changed

5 files changed

+453
-274
lines changed

jdk/src/linux/classes/jdk/internal/platform/CgroupInfo.java

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,86 @@
2626
package jdk.internal.platform;
2727

2828
/**
29-
* Data structure to hold info from /proc/self/cgroup
29+
* Data structure to hold info from /proc/self/cgroup,
30+
* /proc/cgroups and /proc/self/mountinfo
3031
*
3132
* man 7 cgroups
3233
*
3334
* @see CgroupSubsystemFactory
3435
*/
35-
class CgroupInfo {
36+
public class CgroupInfo {
3637

3738
private final String name;
3839
private final int hierarchyId;
3940
private final boolean enabled;
41+
private String mountPoint;
42+
private String mountRoot;
43+
private String cgroupPath;
4044

4145
private CgroupInfo(String name, int hierarchyId, boolean enabled) {
4246
this.name = name;
4347
this.hierarchyId = hierarchyId;
4448
this.enabled = enabled;
4549
}
4650

47-
String getName() {
51+
public String getName() {
4852
return name;
4953
}
5054

51-
int getHierarchyId() {
55+
public int getHierarchyId() {
5256
return hierarchyId;
5357
}
5458

55-
boolean isEnabled() {
59+
public boolean isEnabled() {
5660
return enabled;
5761
}
5862

63+
public String getMountPoint() {
64+
return mountPoint;
65+
}
66+
67+
public void setMountPoint(String mountPoint) {
68+
this.mountPoint = mountPoint;
69+
}
70+
71+
public String getMountRoot() {
72+
return mountRoot;
73+
}
74+
75+
public void setMountRoot(String mountRoot) {
76+
this.mountRoot = mountRoot;
77+
}
78+
79+
public String getCgroupPath() {
80+
return cgroupPath;
81+
}
82+
83+
public void setCgroupPath(String cgroupPath) {
84+
this.cgroupPath = cgroupPath;
85+
}
86+
87+
/*
88+
* Creates a CgroupInfo instance from a line in /proc/cgroups.
89+
* Comment token (hash) is handled by the caller.
90+
*
91+
* Example (annotated):
92+
*
93+
* #subsys_name hierarchy num_cgroups enabled
94+
* cpuset 10 1 1 (a)
95+
* cpu 7 8 1 (b)
96+
* [...]
97+
*
98+
* Line (a) would yield:
99+
* info = new CgroupInfo("cpuset", 10, true);
100+
* return info;
101+
* Line (b) results in:
102+
* info = new CgroupInfo("cpu", 7, true);
103+
* return info;
104+
*
105+
*
106+
* See CgroupSubsystemFactory.determineType()
107+
*
108+
*/
59109
static CgroupInfo fromCgroupsLine(String line) {
60110
String[] tokens = line.split("\\s+");
61111
if (tokens.length != 4) {

0 commit comments

Comments
 (0)