aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2012-05-29 18:07:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-29 19:22:27 -0400
commit78ccf5b5ab834080db25d8128e7dd33594cbf4df (patch)
tree999ce4d31c0b98d6bb437a9cb001ad6d938a6489 /mm
parentfada52ca0e48d227f055134e8cc32f583c5b8b53 (diff)
mm: memcg: print statistics directly to seq_file
Being able to use seq_printf() allows being smarter about statistics name strings, which are currently listed twice, with the only difference being a "total_" prefix on the hierarchical version. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Ying Han <yinghan@google.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ba9e1b131b4d..4200f5c59579 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4060,26 +4060,22 @@ struct mcs_total_stat {
4060 s64 stat[NR_MCS_STAT]; 4060 s64 stat[NR_MCS_STAT];
4061}; 4061};
4062 4062
4063static struct { 4063static const char *memcg_stat_strings[NR_MCS_STAT] = {
4064 char *local_name; 4064 "cache",
4065 char *total_name; 4065 "rss",
4066} memcg_stat_strings[NR_MCS_STAT] = { 4066 "mapped_file",
4067 {"cache", "total_cache"}, 4067 "pgpgin",
4068 {"rss", "total_rss"}, 4068 "pgpgout",
4069 {"mapped_file", "total_mapped_file"}, 4069 "swap",
4070 {"pgpgin", "total_pgpgin"}, 4070 "pgfault",
4071 {"pgpgout", "total_pgpgout"}, 4071 "pgmajfault",
4072 {"swap", "total_swap"}, 4072 "inactive_anon",
4073 {"pgfault", "total_pgfault"}, 4073 "active_anon",
4074 {"pgmajfault", "total_pgmajfault"}, 4074 "inactive_file",
4075 {"inactive_anon", "total_inactive_anon"}, 4075 "active_file",
4076 {"active_anon", "total_active_anon"}, 4076 "unevictable",
4077 {"inactive_file", "total_inactive_file"},
4078 {"active_file", "total_active_file"},
4079 {"unevictable", "total_unevictable"}
4080}; 4077};
4081 4078
4082
4083static void 4079static void
4084mem_cgroup_get_local_stat(struct mem_cgroup *memcg, struct mcs_total_stat *s) 4080mem_cgroup_get_local_stat(struct mem_cgroup *memcg, struct mcs_total_stat *s)
4085{ 4081{
@@ -4175,7 +4171,7 @@ static int mem_control_numa_stat_show(struct cgroup *cont, struct cftype *cft,
4175#endif /* CONFIG_NUMA */ 4171#endif /* CONFIG_NUMA */
4176 4172
4177static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, 4173static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
4178 struct cgroup_map_cb *cb) 4174 struct seq_file *m)
4179{ 4175{
4180 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); 4176 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
4181 struct mcs_total_stat mystat; 4177 struct mcs_total_stat mystat;
@@ -4188,16 +4184,18 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
4188 for (i = 0; i < NR_MCS_STAT; i++) { 4184 for (i = 0; i < NR_MCS_STAT; i++) {
4189 if (i == MCS_SWAP && !do_swap_account) 4185 if (i == MCS_SWAP && !do_swap_account)
4190 continue; 4186 continue;
4191 cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]); 4187 seq_printf(m, "%s %llu\n", memcg_stat_strings[i],
4188 (unsigned long long)mystat.stat[i]);
4192 } 4189 }
4193 4190
4194 /* Hierarchical information */ 4191 /* Hierarchical information */
4195 { 4192 {
4196 unsigned long long limit, memsw_limit; 4193 unsigned long long limit, memsw_limit;
4197 memcg_get_hierarchical_limit(memcg, &limit, &memsw_limit); 4194 memcg_get_hierarchical_limit(memcg, &limit, &memsw_limit);
4198 cb->fill(cb, "hierarchical_memory_limit", limit); 4195 seq_printf(m, "hierarchical_memory_limit %llu\n", limit);
4199 if (do_swap_account) 4196 if (do_swap_account)
4200 cb->fill(cb, "hierarchical_memsw_limit", memsw_limit); 4197 seq_printf(m, "hierarchical_memsw_limit %llu\n",
4198 memsw_limit);
4201 } 4199 }
4202 4200
4203 memset(&mystat, 0, sizeof(mystat)); 4201 memset(&mystat, 0, sizeof(mystat));
@@ -4205,7 +4203,8 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
4205 for (i = 0; i < NR_MCS_STAT; i++) { 4203 for (i = 0; i < NR_MCS_STAT; i++) {
4206 if (i == MCS_SWAP && !do_swap_account) 4204 if (i == MCS_SWAP && !do_swap_account)
4207 continue; 4205 continue;
4208 cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]); 4206 seq_printf(m, "total_%s %llu\n", memcg_stat_strings[i],
4207 (unsigned long long)mystat.stat[i]);
4209 } 4208 }
4210 4209
4211#ifdef CONFIG_DEBUG_VM 4210#ifdef CONFIG_DEBUG_VM
@@ -4226,10 +4225,10 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
4226 recent_scanned[0] += rstat->recent_scanned[0]; 4225 recent_scanned[0] += rstat->recent_scanned[0];
4227 recent_scanned[1] += rstat->recent_scanned[1]; 4226 recent_scanned[1] += rstat->recent_scanned[1];
4228 } 4227 }
4229 cb->fill(cb, "recent_rotated_anon", recent_rotated[0]); 4228 seq_printf(m, "recent_rotated_anon %lu\n", recent_rotated[0]);
4230 cb->fill(cb, "recent_rotated_file", recent_rotated[1]); 4229 seq_printf(m, "recent_rotated_file %lu\n", recent_rotated[1]);
4231 cb->fill(cb, "recent_scanned_anon", recent_scanned[0]); 4230 seq_printf(m, "recent_scanned_anon %lu\n", recent_scanned[0]);
4232 cb->fill(cb, "recent_scanned_file", recent_scanned[1]); 4231 seq_printf(m, "recent_scanned_file %lu\n", recent_scanned[1]);
4233 } 4232 }
4234#endif 4233#endif
4235 4234
@@ -4663,7 +4662,7 @@ static struct cftype mem_cgroup_files[] = {
4663 }, 4662 },
4664 { 4663 {
4665 .name = "stat", 4664 .name = "stat",
4666 .read_map = mem_control_stat_show, 4665 .read_seq_string = mem_control_stat_show,
4667 }, 4666 },
4668 { 4667 {
4669 .name = "force_empty", 4668 .name = "force_empty",