memcg: generate file modified notifications on "memory.events"
authorTejun Heo <tj@kernel.org>
Fri, 18 Sep 2015 22:01:59 +0000 (18:01 -0400)
committerTejun Heo <tj@kernel.org>
Mon, 21 Sep 2015 19:14:47 +0000 (15:14 -0400)
cgroup core only recently grew generic notification support.  Wire up
"memory.events" so that it triggers a file modified event whenever its
content changes.

v2: Refreshed on top of mem_cgroup relocation.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Michal Hocko <mhocko@kernel.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Li Zefan <lizefan@huawei.com>
include/linux/memcontrol.h
mm/memcontrol.c

index 9aa7820c2177e4a7be9b130120a1f216f4eb246d..c83c699a6605b982ca8fbec56f9510d44e2c9cbd 100644 (file)
@@ -213,6 +213,9 @@ struct mem_cgroup {
        /* OOM-Killer disable */
        int             oom_kill_disable;
 
+       /* handle for "memory.events" */
+       struct cgroup_file events_file;
+
        /* protect arrays of thresholds */
        struct mutex thresholds_lock;
 
@@ -286,6 +289,7 @@ static inline void mem_cgroup_events(struct mem_cgroup *memcg,
                       unsigned int nr)
 {
        this_cpu_add(memcg->stat->events[idx], nr);
+       cgroup_file_notify(&memcg->events_file);
 }
 
 bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg);
index e672f2689326a11a35d67377b2e1905fbf17ae15..9f331402e5025fd790b3ca340bdcb946c199d1a5 100644 (file)
@@ -5202,6 +5202,7 @@ static struct cftype memory_files[] = {
        {
                .name = "events",
                .flags = CFTYPE_NOT_ON_ROOT,
+               .file_offset = offsetof(struct mem_cgroup, events_file),
                .seq_show = memory_events_show,
        },
        { }     /* terminate */