]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
cgroup: replace "cgroup.populated" with "cgroup.events"
authorTejun Heo <tj@kernel.org>
Fri, 18 Sep 2015 21:54:22 +0000 (17:54 -0400)
committerTejun Heo <tj@kernel.org>
Fri, 18 Sep 2015 21:54:22 +0000 (17:54 -0400)
memcg already uses "memory.events" for event reporting and other
controllers may need event reporting too.  Let's standardize on
"$SUBSYS.events" interface file for reporting events which don't
happen too frequently and thus can share event notification.

"cgroup.populated" is replaced with "populated" field in
"cgroup.events" and documentation is updated accordingly.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Documentation/cgroups/unified-hierarchy.txt
include/linux/cgroup-defs.h
kernel/cgroup.c

index e0975c2cf03ded24709ca7189152094e220023a7..176b940f8327936c97efa50e96188b26d773041e 100644 (file)
@@ -341,11 +341,11 @@ is riddled with issues.
   unnecessarily complicated and probably done this way because event
   delivery itself was expensive.
 
-Unified hierarchy implements an interface file "cgroup.populated"
-which can be used to monitor whether the cgroup's subhierarchy has
-tasks in it or not.  Its value is 0 if there is no task in the cgroup
-and its descendants; otherwise, 1.  poll and [id]notify events are
-triggered when the value changes.
+Unified hierarchy implements "populated" field in "cgroup.events"
+interface file which can be used to monitor whether the cgroup's
+subhierarchy has tasks in it or not.  Its value is 0 if there is no
+task in the cgroup and its descendants; otherwise, 1.  poll and
+[id]notify events are triggered when the value changes.
 
 This is significantly lighter and simpler and trivially allows
 delegating management of subhierarchy - subhierarchy monitoring can
@@ -435,6 +435,11 @@ may be specified in any order and not all pairs have to be specified.
   the first entry in the file.  Specific entries can use "default" as
   its value to indicate inheritance of the default value.
 
+- For events which are not very high frequency, an interface file
+  "events" should be created which lists event key value pairs.
+  Whenever a notifiable event happens, file modified event should be
+  generated on the file.
+
 
 5-4. Per-Controller Changes
 
index c5d41c3c1f003bd4acc69390f6488ab711959903..d95cc88e9dc28e09f87e0b16e29c211982444afd 100644 (file)
@@ -226,7 +226,7 @@ struct cgroup {
 
        struct kernfs_node *kn;         /* cgroup kernfs entry */
        struct kernfs_node *procs_kn;   /* kn for "cgroup.procs" */
-       struct kernfs_node *populated_kn; /* kn for "cgroup.subtree_populated" */
+       struct kernfs_node *events_kn;  /* kn for "cgroup.events" */
 
        /*
         * The bitmask of subsystems enabled on the child cgroups.
index c24f929fdeb70433714660711ce4076c4f9041b4..75eba25d8dfded3f0d1c89020c8bfbba5b592abb 100644 (file)
@@ -611,8 +611,8 @@ static void cgroup_update_populated(struct cgroup *cgrp, bool populated)
                if (!trigger)
                        break;
 
-               if (cgrp->populated_kn)
-                       kernfs_notify(cgrp->populated_kn);
+               if (cgrp->events_kn)
+                       kernfs_notify(cgrp->events_kn);
                cgrp = cgroup_parent(cgrp);
        } while (cgrp);
 }
@@ -3045,9 +3045,10 @@ err_undo_css:
        goto out_unlock;
 }
 
-static int cgroup_populated_show(struct seq_file *seq, void *v)
+static int cgroup_events_show(struct seq_file *seq, void *v)
 {
-       seq_printf(seq, "%d\n", (bool)seq_css(seq)->cgroup->populated_cnt);
+       seq_printf(seq, "populated %d\n",
+                  (bool)seq_css(seq)->cgroup->populated_cnt);
        return 0;
 }
 
@@ -3214,8 +3215,8 @@ static int cgroup_add_file(struct cgroup *cgrp, struct cftype *cft)
 
        if (cft->write == cgroup_procs_write)
                cgrp->procs_kn = kn;
-       else if (cft->seq_show == cgroup_populated_show)
-               cgrp->populated_kn = kn;
+       else if (cft->seq_show == cgroup_events_show)
+               cgrp->events_kn = kn;
        return 0;
 }
 
@@ -4388,9 +4389,9 @@ static struct cftype cgroup_dfl_base_files[] = {
                .write = cgroup_subtree_control_write,
        },
        {
-               .name = "cgroup.populated",
+               .name = "cgroup.events",
                .flags = CFTYPE_NOT_ON_ROOT,
-               .seq_show = cgroup_populated_show,
+               .seq_show = cgroup_events_show,
        },
        { }     /* terminate */
 };