]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
cgroup: misc changes
authorTejun Heo <tj@kernel.org>
Fri, 11 Aug 2017 12:49:01 +0000 (05:49 -0700)
committerTejun Heo <tj@kernel.org>
Fri, 11 Aug 2017 12:49:01 +0000 (05:49 -0700)
Misc trivial changes to prepare for future changes.  No functional
difference.

* Expose cgroup_get(), cgroup_tryget() and cgroup_parent().

* Implement task_dfl_cgroup() which dereferences css_set->dfl_cgrp.

* Rename cgroup_stats_show() to cgroup_stat_show() for consistency
  with the file name.

Signed-off-by: Tejun Heo <tj@kernel.org>
include/linux/cgroup.h
kernel/cgroup/cgroup.c

index 79faa6467f76c16445bd80a48a76ae9ac6bcd3ca..085056e562b1756695cfe61ac1703e3c159118bb 100644 (file)
@@ -398,6 +398,16 @@ static inline void css_put_many(struct cgroup_subsys_state *css, unsigned int n)
                percpu_ref_put_many(&css->refcnt, n);
 }
 
+static inline void cgroup_get(struct cgroup *cgrp)
+{
+       css_get(&cgrp->self);
+}
+
+static inline bool cgroup_tryget(struct cgroup *cgrp)
+{
+       return css_tryget(&cgrp->self);
+}
+
 static inline void cgroup_put(struct cgroup *cgrp)
 {
        css_put(&cgrp->self);
@@ -510,6 +520,20 @@ static inline struct cgroup *task_cgroup(struct task_struct *task,
        return task_css(task, subsys_id)->cgroup;
 }
 
+static inline struct cgroup *task_dfl_cgroup(struct task_struct *task)
+{
+       return task_css_set(task)->dfl_cgrp;
+}
+
+static inline struct cgroup *cgroup_parent(struct cgroup *cgrp)
+{
+       struct cgroup_subsys_state *parent_css = cgrp->self.parent;
+
+       if (parent_css)
+               return container_of(parent_css, struct cgroup, self);
+       return NULL;
+}
+
 /**
  * cgroup_is_descendant - test ancestry
  * @cgrp: the cgroup to be tested
index f5ca55db1fe15a5a8f6dd578a19e5c65c5069358..c038ccf95b5dd5d53e2f6c0b7ffccd59da9e891f 100644 (file)
@@ -319,15 +319,6 @@ static void cgroup_idr_remove(struct idr *idr, int id)
        spin_unlock_bh(&cgroup_idr_lock);
 }
 
-static struct cgroup *cgroup_parent(struct cgroup *cgrp)
-{
-       struct cgroup_subsys_state *parent_css = cgrp->self.parent;
-
-       if (parent_css)
-               return container_of(parent_css, struct cgroup, self);
-       return NULL;
-}
-
 static bool cgroup_has_tasks(struct cgroup *cgrp)
 {
        return cgrp->nr_populated_csets;
@@ -534,22 +525,12 @@ struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgrp,
        return css;
 }
 
-static void __maybe_unused cgroup_get(struct cgroup *cgrp)
-{
-       css_get(&cgrp->self);
-}
-
 static void cgroup_get_live(struct cgroup *cgrp)
 {
        WARN_ON_ONCE(cgroup_is_dead(cgrp));
        css_get(&cgrp->self);
 }
 
-static bool cgroup_tryget(struct cgroup *cgrp)
-{
-       return css_tryget(&cgrp->self);
-}
-
 struct cgroup_subsys_state *of_css(struct kernfs_open_file *of)
 {
        struct cgroup *cgrp = of->kn->parent->priv;
@@ -3306,7 +3287,7 @@ static int cgroup_events_show(struct seq_file *seq, void *v)
        return 0;
 }
 
-static int cgroup_stats_show(struct seq_file *seq, void *v)
+static int cgroup_stat_show(struct seq_file *seq, void *v)
 {
        struct cgroup *cgroup = seq_css(seq)->cgroup;
 
@@ -4423,7 +4404,7 @@ static struct cftype cgroup_base_files[] = {
        },
        {
                .name = "cgroup.stat",
-               .seq_show = cgroup_stats_show,
+               .seq_show = cgroup_stat_show,
        },
        { }     /* terminate */
 };