+struct cg_controller_desc {
+ const char *name;
+ int optional;
+};
+
+typedef enum {
+ CG_MEMORY = 0,
+ CG_CPUACCT,
+ CG_CPUSET,
+ CG_NUM_CONTROLLERS,
+} cg_controller;
+
+static const struct cg_controller_desc cg_controllers[CG_NUM_CONTROLLERS+1] = {
+ [CG_MEMORY] = { "memory", 0 },
+ [CG_CPUACCT] = { "cpuacct", 0 },
+ [CG_CPUSET] = { "cpuset", 1 },
+ [CG_NUM_CONTROLLERS] = { NULL, 0 },
+};
+
+#define FOREACH_CG_CONTROLLER(_controller) \
+ for (cg_controller (_controller) = 0; \
+ (_controller) < CG_NUM_CONTROLLERS; (_controller)++)
+
+static const char *cg_controller_name(cg_controller c)
+{
+ return cg_controllers[c].name;
+}
+
+static const int cg_controller_optional(cg_controller c)
+{
+ return cg_controllers[c].optional;
+}
+
+static char cg_name[256];