aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-10-11 14:19:42 +0200
committerDmitry Vyukov <dvyukov@google.com>2021-10-12 15:25:31 +0200
commit607ad2b370822491f074f06a4e751c23cfefce05 (patch)
tree4ecdc0a0a2ddccb3f6e366dff55523d9427aab5d
parentfe37c8029dd9595e960f518080e12f79f832386a (diff)
executor: setup cgroups once
Currently we setup cgroups on every test process start (along with sandbox creation). That's unnecessary because that's global per-machine setup. Move cgroup setup into setup section that's executed once per machine from pkg/host.Setup.
-rw-r--r--executor/common.h3
-rw-r--r--executor/common_linux.h7
-rw-r--r--executor/executor.cc1
-rw-r--r--executor/executor_bsd.h4
-rw-r--r--pkg/csource/generated.go10
5 files changed, 11 insertions, 14 deletions
diff --git a/executor/common.h b/executor/common.h
index 7a36cfe8d..1e6eca5ae 100644
--- a/executor/common.h
+++ b/executor/common.h
@@ -763,6 +763,9 @@ int main(void)
#if SYZ_SYSCTL
setup_sysctl();
#endif
+#if SYZ_CGROUPS
+ setup_cgroups();
+#endif
#if SYZ_BINFMT_MISC
setup_binfmt_misc();
#endif
diff --git a/executor/common_linux.h b/executor/common_linux.h
index 173533a5e..16880d00e 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -3481,10 +3481,6 @@ static void mount_cgroups(const char* dir, const char** controllers, int count)
static void setup_cgroups()
{
-#if SYZ_EXECUTOR
- if (!flag_cgroups)
- return;
-#endif
// We want to cover both cgroup and cgroup2.
// Each resource controller can be bound to only one of them,
// so to cover both we divide all controllers into 3 arbitrary groups.
@@ -3636,9 +3632,6 @@ static void setup_common()
if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) {
debug("mount(fusectl) failed: %d\n", errno);
}
-#if SYZ_EXECUTOR || SYZ_CGROUPS
- setup_cgroups();
-#endif
}
#include <sched.h>
diff --git a/executor/executor.cc b/executor/executor.cc
index 25e3be69d..76b1d284a 100644
--- a/executor/executor.cc
+++ b/executor/executor.cc
@@ -1522,6 +1522,7 @@ void setup_features(char** enable, int n)
flag_debug = true;
#if SYZ_HAVE_FEATURES
setup_sysctl();
+ setup_cgroups();
#endif
for (int i = 0; i < n; i++) {
bool found = false;
diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h
index 873d6c906..db02c61b7 100644
--- a/executor/executor_bsd.h
+++ b/executor/executor_bsd.h
@@ -179,4 +179,8 @@ static feature_t features[] = {
static void setup_sysctl(void)
{
}
+
+static void setup_cgroups(void)
+{
+}
#endif
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index 4662a8b84..69da1124d 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -8128,10 +8128,6 @@ static void mount_cgroups(const char* dir, const char** controllers, int count)
static void setup_cgroups()
{
-#if SYZ_EXECUTOR
- if (!flag_cgroups)
- return;
-#endif
const char* unified_controllers[] = {"+cpu", "+memory", "+io", "+pids", "+rdma"};
const char* net_controllers[] = {"net", "net_cls", "net_prio", "devices", "blkio", "freezer"};
const char* cpu_controllers[] = {"cpuset", "cpuacct", "perf_event", "hugetlb", "rlimit"};
@@ -8260,9 +8256,6 @@ static void setup_common()
if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) {
debug("mount(fusectl) failed: %d\n", errno);
}
-#if SYZ_EXECUTOR || SYZ_CGROUPS
- setup_cgroups();
-#endif
}
#include <sched.h>
@@ -10660,6 +10653,9 @@ int main(void)
#if SYZ_SYSCTL
setup_sysctl();
#endif
+#if SYZ_CGROUPS
+ setup_cgroups();
+#endif
#if SYZ_BINFMT_MISC
setup_binfmt_misc();
#endif