Add subsystem APIs css_mount and css_umount which will be called during
cgroup_mount and umount respectively. This will let the subsystem
perform any specific setup during mount/umount.
This will be used in code data prioritization code later.

Signed-off-by: Vikas Shivappa <vikas.shiva...@linux.intel.com>
---
 include/linux/cgroup.h |  2 ++
 kernel/cgroup.c        | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 292ed97..3ded186 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -655,6 +655,8 @@ struct cgroup_subsys {
                     struct cgroup_subsys_state *old_css,
                     struct task_struct *task);
        void (*bind)(struct cgroup_subsys_state *root_css);
+       void (*css_mount)(void *mount_info);
+       void (*css_umount)(void);
 
        int disabled;
        int early_init;
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 668f614..e139504 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1345,6 +1345,7 @@ struct cgroup_sb_opts {
        char *name;
        /* User explicitly requested empty subsystem */
        bool none;
+       void *mount_info;
 };
 
 static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
@@ -1787,6 +1788,11 @@ static struct dentry *cgroup_mount(struct 
file_system_type *fs_type,
        if (ret)
                goto out_unlock;
 
+       for_each_subsys(ss, i) {
+               if ((opts.subsys_mask && (1U << i)) && ss->css_mount)
+                       ss->css_mount(opts.mount_info);
+       }
+
        /* look for a matching existing root */
        if (opts.flags & CGRP_ROOT_SANE_BEHAVIOR) {
                cgrp_dfl_root_visible = true;
@@ -1928,7 +1934,13 @@ static void cgroup_kill_sb(struct super_block *sb)
 {
        struct kernfs_root *kf_root = kernfs_root_from_sb(sb);
        struct cgroup_root *root = cgroup_root_from_kf(kf_root);
+       struct cgroup_subsys *ss;
+       int i;
 
+       for_each_subsys(ss, i) {
+               if ((root->subsys_mask && (1U << i)) && ss->css_umount)
+                       ss->css_umount();
+       }
        /*
         * If @root doesn't have any mounts or children, start killing it.
         * This prevents new mounts by disabling percpu_ref_tryget_live().
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to