浏览代码

memcg: generate file modified notifications on "memory.events"

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>
Tejun Heo 10 年之前
父节点
当前提交
472912a2b5
共有 2 个文件被更改,包括 5 次插入0 次删除
  1. 4 0
      include/linux/memcontrol.h
  2. 1 0
      mm/memcontrol.c

+ 4 - 0
include/linux/memcontrol.h

@@ -213,6 +213,9 @@ struct mem_cgroup {
 	/* OOM-Killer disable */
 	/* OOM-Killer disable */
 	int		oom_kill_disable;
 	int		oom_kill_disable;
 
 
+	/* handle for "memory.events" */
+	struct cgroup_file events_file;
+
 	/* protect arrays of thresholds */
 	/* protect arrays of thresholds */
 	struct mutex thresholds_lock;
 	struct mutex thresholds_lock;
 
 
@@ -286,6 +289,7 @@ static inline void mem_cgroup_events(struct mem_cgroup *memcg,
 		       unsigned int nr)
 		       unsigned int nr)
 {
 {
 	this_cpu_add(memcg->stat->events[idx], 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);
 bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg);

+ 1 - 0
mm/memcontrol.c

@@ -5202,6 +5202,7 @@ static struct cftype memory_files[] = {
 	{
 	{
 		.name = "events",
 		.name = "events",
 		.flags = CFTYPE_NOT_ON_ROOT,
 		.flags = CFTYPE_NOT_ON_ROOT,
+		.file_offset = offsetof(struct mem_cgroup, events_file),
 		.seq_show = memory_events_show,
 		.seq_show = memory_events_show,
 	},
 	},
 	{ }	/* terminate */
 	{ }	/* terminate */