]> Pileus Git - ~andy/linux/blobdiff - include/linux/cgroup.h
cgroup: remove cgroup_is_descendant()
[~andy/linux] / include / linux / cgroup.h
index 900af5964f5543f6dd1b5308419e93c70cb0ca07..7e818a3ef60a11e36d594a7c32c07cc9f548acbb 100644 (file)
@@ -44,14 +44,25 @@ extern void cgroup_unload_subsys(struct cgroup_subsys *ss);
 
 extern const struct file_operations proc_cgroup_operations;
 
-/* Define the enumeration of all builtin cgroup subsystems */
+/*
+ * Define the enumeration of all cgroup subsystems.
+ *
+ * We define ids for builtin subsystems and then modular ones.
+ */
 #define SUBSYS(_x) _x ## _subsys_id,
-#define IS_SUBSYS_ENABLED(option) IS_ENABLED(option)
 enum cgroup_subsys_id {
+#define IS_SUBSYS_ENABLED(option) IS_BUILTIN(option)
 #include <linux/cgroup_subsys.h>
+#undef IS_SUBSYS_ENABLED
+       CGROUP_BUILTIN_SUBSYS_COUNT,
+
+       __CGROUP_SUBSYS_TEMP_PLACEHOLDER = CGROUP_BUILTIN_SUBSYS_COUNT - 1,
+
+#define IS_SUBSYS_ENABLED(option) IS_MODULE(option)
+#include <linux/cgroup_subsys.h>
+#undef IS_SUBSYS_ENABLED
        CGROUP_SUBSYS_COUNT,
 };
-#undef IS_SUBSYS_ENABLED
 #undef SUBSYS
 
 /* Per-subsystem/per-cgroup state maintained by the system. */
@@ -150,6 +161,11 @@ enum {
        CGRP_CPUSET_CLONE_CHILDREN,
 };
 
+struct cgroup_name {
+       struct rcu_head rcu_head;
+       char name[];
+};
+
 struct cgroup {
        unsigned long flags;            /* "unsigned long" so bitops work */
 
@@ -172,6 +188,19 @@ struct cgroup {
        struct cgroup *parent;          /* my parent */
        struct dentry *dentry;          /* cgroup fs entry, RCU protected */
 
+       /*
+        * This is a copy of dentry->d_name, and it's needed because
+        * we can't use dentry->d_name in cgroup_path().
+        *
+        * You must acquire rcu_read_lock() to access cgrp->name, and
+        * the only place that can change it is rename(), which is
+        * protected by parent dir's i_mutex.
+        *
+        * Normally you should use cgroup_name() wrapper rather than
+        * access it directly.
+        */
+       struct cgroup_name __rcu *name;
+
        /* Private pointers for each registered subsystem */
        struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
 
@@ -404,6 +433,12 @@ struct cgroup_scanner {
        void *data;
 };
 
+/* Caller should hold rcu_read_lock() */
+static inline const char *cgroup_name(const struct cgroup *cgrp)
+{
+       return rcu_dereference(cgrp->name)->name;
+}
+
 int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
 int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
 
@@ -413,9 +448,6 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
 
 int cgroup_task_count(const struct cgroup *cgrp);
 
-/* Return true if cgrp is a descendant of the task's cgroup */
-int cgroup_is_descendant(const struct cgroup *cgrp, struct task_struct *task);
-
 /*
  * Control Group taskset, used to pass around set of tasks to cgroup_subsys
  * methods.