aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorGreg Thelen <gthelen@google.com>2013-11-12 18:07:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 22:09:06 -0500
commit25485de6e90ef1684c55a203988fad5eab7a45d6 (patch)
tree9ac488bb581da5cf4f78178a251945dd8b5f6b33 /mm/memcontrol.c
parentb76ac7e734608d706bf225be062a7a46d165dda6 (diff)
memcg: refactor mem_control_numa_stat_show()
Refactor mem_control_numa_stat_show() to use a new stats structure for smaller and simpler code. This consolidates nearly identical code. text data bss dec hex filename 8,137,679 1,703,496 1,896,448 11,737,623 b31a17 vmlinux.before 8,136,911 1,703,496 1,896,448 11,736,855 b31717 vmlinux.after Signed-off-by: Greg Thelen <gthelen@google.com> Signed-off-by: Ying Han <yinghan@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3427de9897a5..91b5d3a62059 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5369,45 +5369,33 @@ static int mem_cgroup_move_charge_write(struct cgroup_subsys_state *css,
5369static int memcg_numa_stat_show(struct cgroup_subsys_state *css, 5369static int memcg_numa_stat_show(struct cgroup_subsys_state *css,
5370 struct cftype *cft, struct seq_file *m) 5370 struct cftype *cft, struct seq_file *m)
5371{ 5371{
5372 struct numa_stat {
5373 const char *name;
5374 unsigned int lru_mask;
5375 };
5376
5377 static const struct numa_stat stats[] = {
5378 { "total", LRU_ALL },
5379 { "file", LRU_ALL_FILE },
5380 { "anon", LRU_ALL_ANON },
5381 { "unevictable", BIT(LRU_UNEVICTABLE) },
5382 };
5383 const struct numa_stat *stat;
5372 int nid; 5384 int nid;
5373 unsigned long total_nr, file_nr, anon_nr, unevictable_nr; 5385 unsigned long nr;
5374 unsigned long node_nr;
5375 struct mem_cgroup *memcg = mem_cgroup_from_css(css); 5386 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
5376 5387
5377 total_nr = mem_cgroup_nr_lru_pages(memcg, LRU_ALL); 5388 for (stat = stats; stat < stats + ARRAY_SIZE(stats); stat++) {
5378 seq_printf(m, "total=%lu", total_nr); 5389 nr = mem_cgroup_nr_lru_pages(memcg, stat->lru_mask);
5379 for_each_node_state(nid, N_MEMORY) { 5390 seq_printf(m, "%s=%lu", stat->name, nr);
5380 node_nr = mem_cgroup_node_nr_lru_pages(memcg, nid, LRU_ALL); 5391 for_each_node_state(nid, N_MEMORY) {
5381 seq_printf(m, " N%d=%lu", nid, node_nr); 5392 nr = mem_cgroup_node_nr_lru_pages(memcg, nid,
5382 } 5393 stat->lru_mask);
5383 seq_putc(m, '\n'); 5394 seq_printf(m, " N%d=%lu", nid, nr);
5384 5395 }
5385 file_nr = mem_cgroup_nr_lru_pages(memcg, LRU_ALL_FILE); 5396 seq_putc(m, '\n');
5386 seq_printf(m, "file=%lu", file_nr);
5387 for_each_node_state(nid, N_MEMORY) {
5388 node_nr = mem_cgroup_node_nr_lru_pages(memcg, nid,
5389 LRU_ALL_FILE);
5390 seq_printf(m, " N%d=%lu", nid, node_nr);
5391 }
5392 seq_putc(m, '\n');
5393
5394 anon_nr = mem_cgroup_nr_lru_pages(memcg, LRU_ALL_ANON);
5395 seq_printf(m, "anon=%lu", anon_nr);
5396 for_each_node_state(nid, N_MEMORY) {
5397 node_nr = mem_cgroup_node_nr_lru_pages(memcg, nid,
5398 LRU_ALL_ANON);
5399 seq_printf(m, " N%d=%lu", nid, node_nr);
5400 } 5397 }
5401 seq_putc(m, '\n');
5402 5398
5403 unevictable_nr = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_UNEVICTABLE));
5404 seq_printf(m, "unevictable=%lu", unevictable_nr);
5405 for_each_node_state(nid, N_MEMORY) {
5406 node_nr = mem_cgroup_node_nr_lru_pages(memcg, nid,
5407 BIT(LRU_UNEVICTABLE));
5408 seq_printf(m, " N%d=%lu", nid, node_nr);
5409 }
5410 seq_putc(m, '\n');
5411 return 0; 5399 return 0;
5412} 5400}
5413#endif /* CONFIG_NUMA */ 5401#endif /* CONFIG_NUMA */