diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 59edaad3dffbd3ff84cf2e167db4372f133a8601..2df0cae062b2dc7b26d44d1a1f3e8d4328869633 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4793,6 +4793,32 @@ static ssize_t memory_high_write(struct kernfs_open_file *of, return nbytes; } +static void __memory_events_show(struct seq_file *m, atomic_long_t *events) +{ + seq_printf(m, "low %lu\n", atomic_long_read(&events[MEMCG_LOW])); + seq_printf(m, "high %lu\n", atomic_long_read(&events[MEMCG_HIGH])); + seq_printf(m, "max %lu\n", atomic_long_read(&events[MEMCG_MAX])); + seq_printf(m, "oom %lu\n", atomic_long_read(&events[MEMCG_OOM])); + seq_printf(m, "oom_kill %lu\n", + atomic_long_read(&events[MEMCG_OOM_KILL])); +} + +static int memory_events_show(struct seq_file *m, void *v) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); + + __memory_events_show(m, memcg->memory_events); + return 0; +} + +static int memory_events_local_show(struct seq_file *m, void *v) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); + + __memory_events_show(m, memcg->memory_events_local); + return 0; +} + static struct cftype mem_cgroup_legacy_files[] = { { .name = "usage_in_bytes", @@ -4958,6 +4984,18 @@ static struct cftype mem_cgroup_legacy_files[] = { .seq_show = memory_high_show, .write = memory_high_write, }, + { + .name = "events", + .flags = CFTYPE_NOT_ON_ROOT, + .file_offset = offsetof(struct mem_cgroup, events_file), + .seq_show = memory_events_show, + }, + { + .name = "events.local", + .flags = CFTYPE_NOT_ON_ROOT, + .file_offset = offsetof(struct mem_cgroup, events_local_file), + .seq_show = memory_events_local_show, + }, { }, /* terminate */ }; @@ -6236,32 +6274,6 @@ static ssize_t memory_max_write(struct kernfs_open_file *of, return nbytes; } -static void __memory_events_show(struct seq_file *m, atomic_long_t *events) -{ - seq_printf(m, "low %lu\n", atomic_long_read(&events[MEMCG_LOW])); - seq_printf(m, "high %lu\n", atomic_long_read(&events[MEMCG_HIGH])); - seq_printf(m, "max %lu\n", atomic_long_read(&events[MEMCG_MAX])); - seq_printf(m, "oom %lu\n", atomic_long_read(&events[MEMCG_OOM])); - seq_printf(m, "oom_kill %lu\n", - atomic_long_read(&events[MEMCG_OOM_KILL])); -} - -static int memory_events_show(struct seq_file *m, void *v) -{ - struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); - - __memory_events_show(m, memcg->memory_events); - return 0; -} - -static int memory_events_local_show(struct seq_file *m, void *v) -{ - struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); - - __memory_events_show(m, memcg->memory_events_local); - return 0; -} - static int memory_stat_show(struct seq_file *m, void *v) { struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));