Skip to content

Commit

Permalink
Fixes after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jerboaa committed Jul 1, 2024
1 parent 9a0fd10 commit ba23e06
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CgroupV1Controller: public CgroupController {
char* subsystem_path() override { return _path; }
bool is_read_only() override { return _read_only; }
bool needs_hierarchy_adjustment() override;
char *mount_point() override { return _mount_point; }
char *mount_point() { return _mount_point; }
};

class CgroupV1MemoryController final : public CgroupMemoryController {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class CgroupV2Controller: public CgroupController {

char *subsystem_path() override { return _path; }
bool needs_hierarchy_adjustment() override;
char * mount_point() override { return _mount_path; };
// Allow for optional updates of the subsystem path
void set_subsystem_path(char* cgroup_path) override;
void set_subsystem_path(char* cgroup_path);
bool is_read_only() override { return _read_only; }
char * mount_point() { return _mount_path; };
};

class CgroupV2CpuController: public CgroupCpuController {
Expand Down
62 changes: 47 additions & 15 deletions test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,53 +471,85 @@ TEST(cgroupTest, set_cgroupv2_subsystem_path) {
}

TEST(cgroupTest, cgroupv2_is_hierarchy_walk_needed) {
CgroupV2Controller* test = new CgroupV2Controller( (char*)"/sys/fs/cgroup", (char*)"/" /* cgroup_path */);
bool controller_read_only = false; // value irrelevant;
CgroupV2Controller* test = new CgroupV2Controller((char*)"/sys/fs/cgroup",
(char*)"/" /* cgroup_path */,
controller_read_only);
EXPECT_FALSE(test->needs_hierarchy_adjustment());
test = new CgroupV2Controller( (char*)"/sys/fs/cgroup", (char*)"/bar" /* cgroup_path */);
test = new CgroupV2Controller((char*)"/sys/fs/cgroup",
(char*)"/bar" /* cgroup_path */,
controller_read_only);
EXPECT_TRUE(test->needs_hierarchy_adjustment());
test = new CgroupV2Controller( (char*)"/sys/fs/cgroup/b", (char*)"/a/b" /* cgroup_path */);
test = new CgroupV2Controller((char*)"/sys/fs/cgroup/b",
(char*)"/a/b" /* cgroup_path */,
controller_read_only);
EXPECT_TRUE(test->needs_hierarchy_adjustment());

CgroupCpuController* test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup", (char*)"/" /* cgroup_path */));
CgroupCpuController* test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup",
(char*)"/" /* cgroup_path */,
controller_read_only));
EXPECT_FALSE(test2->needs_hierarchy_adjustment());
test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup", (char*)"/bar" /* cgroup_path */));
test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup",
(char*)"/bar" /* cgroup_path */,
controller_read_only));
EXPECT_TRUE(test2->needs_hierarchy_adjustment());
test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup/b", (char*)"/a/b" /* cgroup_path */));
test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup/b",
(char*)"/a/b" /* cgroup_path */,
controller_read_only));
EXPECT_TRUE(test2->needs_hierarchy_adjustment());

CgroupMemoryController* test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup", (char*)"/" /* cgroup_path */));
CgroupMemoryController* test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup",
(char*)"/" /* cgroup_path */,
controller_read_only));
EXPECT_FALSE(test3->needs_hierarchy_adjustment());
test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup", (char*)"/bar" /* cgroup_path */));
test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup",
(char*)"/bar" /* cgroup_path */,
controller_read_only));
EXPECT_TRUE(test3->needs_hierarchy_adjustment());
test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup/b", (char*)"/a/b" /* cgroup_path */));
test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup/b",
(char*)"/a/b" /* cgroup_path */,
controller_read_only));
EXPECT_TRUE(test3->needs_hierarchy_adjustment());
}

TEST(cgroupTest, cgroupv1_is_hierarchy_walk_needed) {
CgroupV1Controller* test = new CgroupV1Controller( (char*)"/a/b/c" /* root */, (char*)"/sys/fs/cgroup/memory" /* mount_path */);
bool controller_read_only = true; // shouldn't matter;
CgroupV1Controller* test = new CgroupV1Controller((char*)"/a/b/c" /* root */,
(char*)"/sys/fs/cgroup/memory" /* mount_path */,
controller_read_only);
test->set_subsystem_path((char*)"/a/b/c");
EXPECT_FALSE(test->needs_hierarchy_adjustment());
test->set_subsystem_path((char*)"/");
EXPECT_TRUE(test->needs_hierarchy_adjustment());
test = new CgroupV1Controller( (char*)"/a/b/c" /* root */, (char*)"/"/* mount_path */);
test = new CgroupV1Controller((char*)"/a/b/c" /* root */,
(char*)"/"/* mount_path */,
controller_read_only);
test->set_subsystem_path((char*)"/");
EXPECT_TRUE(test->needs_hierarchy_adjustment());

CgroupCpuController* test2 = new CgroupV1CpuController(CgroupV1Controller((char*)"/a/b/c" /* root */, (char*)"/sys/fs/cgroup/memory" /* mount_path */));
CgroupCpuController* test2 = new CgroupV1CpuController(CgroupV1Controller((char*)"/a/b/c" /* root */,
(char*)"/sys/fs/cgroup/memory" /* mount_path */,
controller_read_only));
static_cast<CgroupV1CpuController*>(test2)->set_subsystem_path((char*)"/a/b/c");
EXPECT_FALSE(test2->needs_hierarchy_adjustment());
static_cast<CgroupV1CpuController*>(test2)->set_subsystem_path((char*)"/");
EXPECT_TRUE(test2->needs_hierarchy_adjustment());
test2 = new CgroupV1CpuController(CgroupV1Controller((char*)"/a/b/c" /* root */, (char*)"/"/* mount_path */));
test2 = new CgroupV1CpuController(CgroupV1Controller((char*)"/a/b/c" /* root */,
(char*)"/"/* mount_path */,
controller_read_only));
static_cast<CgroupV1CpuController*>(test2)->set_subsystem_path((char*)"/");
EXPECT_TRUE(test2->needs_hierarchy_adjustment());

CgroupMemoryController* test3 = new CgroupV1MemoryController(CgroupV1Controller((char*)"/a/b/c" /* root */, (char*)"/sys/fs/cgroup/memory" /* mount_path */));
CgroupMemoryController* test3 = new CgroupV1MemoryController(CgroupV1Controller((char*)"/a/b/c" /* root */,
(char*)"/sys/fs/cgroup/memory" /* mount_path */,
controller_read_only));
static_cast<CgroupV1MemoryController*>(test3)->set_subsystem_path((char*)"/a/b/c");
EXPECT_FALSE(test3->needs_hierarchy_adjustment());
static_cast<CgroupV1MemoryController*>(test3)->set_subsystem_path((char*)"/");
EXPECT_TRUE(test3->needs_hierarchy_adjustment());
test3 = new CgroupV1MemoryController(CgroupV1Controller((char*)"/a/b/c" /* root */, (char*)"/"/* mount_path */));
test3 = new CgroupV1MemoryController(CgroupV1Controller((char*)"/a/b/c" /* root */,
(char*)"/"/* mount_path */,
controller_read_only));
static_cast<CgroupV1MemoryController*>(test3)->set_subsystem_path((char*)"/");
EXPECT_TRUE(test3->needs_hierarchy_adjustment());
}
Expand Down

0 comments on commit ba23e06

Please sign in to comment.