aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorPaul Menage <menage@google.com>2008-04-29 04:00:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:08 -0400
commitc64745cf0f34f2cb08fc28c93d844e583d0d591d (patch)
treed957cd0cd83917ee69c72eb92d1db0c4cb2ed2bc /mm
parent9179656961adcea3c25403365597e486d851ac5e (diff)
CGroup API files: use cgroup map for memcontrol stats file
Remove the seq_file boilerplate used to construct the memcontrol stats map, and instead use the new map representation for cgroup control files Signed-off-by: Paul Menage <menage@google.com> Cc: "Li Zefan" <lizf@cn.fujitsu.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Jackson <pj@sgi.com> Cc: Pavel Emelyanov <xemul@openvz.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: "YAMAMOTO Takashi" <yamamoto@valinux.co.jp> 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.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e227d7c5989f..496ab700e0a4 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -899,9 +899,9 @@ static const struct mem_cgroup_stat_desc {
899 [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, }, 899 [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, },
900}; 900};
901 901
902static int mem_control_stat_show(struct seq_file *m, void *arg) 902static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
903 struct cgroup_map_cb *cb)
903{ 904{
904 struct cgroup *cont = m->private;
905 struct mem_cgroup *mem_cont = mem_cgroup_from_cont(cont); 905 struct mem_cgroup *mem_cont = mem_cgroup_from_cont(cont);
906 struct mem_cgroup_stat *stat = &mem_cont->stat; 906 struct mem_cgroup_stat *stat = &mem_cont->stat;
907 int i; 907 int i;
@@ -911,8 +911,7 @@ static int mem_control_stat_show(struct seq_file *m, void *arg)
911 911
912 val = mem_cgroup_read_stat(stat, i); 912 val = mem_cgroup_read_stat(stat, i);
913 val *= mem_cgroup_stat_desc[i].unit; 913 val *= mem_cgroup_stat_desc[i].unit;
914 seq_printf(m, "%s %lld\n", mem_cgroup_stat_desc[i].msg, 914 cb->fill(cb, mem_cgroup_stat_desc[i].msg, val);
915 (long long)val);
916 } 915 }
917 /* showing # of active pages */ 916 /* showing # of active pages */
918 { 917 {
@@ -922,27 +921,12 @@ static int mem_control_stat_show(struct seq_file *m, void *arg)
922 MEM_CGROUP_ZSTAT_INACTIVE); 921 MEM_CGROUP_ZSTAT_INACTIVE);
923 active = mem_cgroup_get_all_zonestat(mem_cont, 922 active = mem_cgroup_get_all_zonestat(mem_cont,
924 MEM_CGROUP_ZSTAT_ACTIVE); 923 MEM_CGROUP_ZSTAT_ACTIVE);
925 seq_printf(m, "active %ld\n", (active) * PAGE_SIZE); 924 cb->fill(cb, "active", (active) * PAGE_SIZE);
926 seq_printf(m, "inactive %ld\n", (inactive) * PAGE_SIZE); 925 cb->fill(cb, "inactive", (inactive) * PAGE_SIZE);
927 } 926 }
928 return 0; 927 return 0;
929} 928}
930 929
931static const struct file_operations mem_control_stat_file_operations = {
932 .read = seq_read,
933 .llseek = seq_lseek,
934 .release = single_release,
935};
936
937static int mem_control_stat_open(struct inode *unused, struct file *file)
938{
939 /* XXX __d_cont */
940 struct cgroup *cont = file->f_dentry->d_parent->d_fsdata;
941
942 file->f_op = &mem_control_stat_file_operations;
943 return single_open(file, mem_control_stat_show, cont);
944}
945
946static struct cftype mem_cgroup_files[] = { 930static struct cftype mem_cgroup_files[] = {
947 { 931 {
948 .name = "usage_in_bytes", 932 .name = "usage_in_bytes",
@@ -967,7 +951,7 @@ static struct cftype mem_cgroup_files[] = {
967 }, 951 },
968 { 952 {
969 .name = "stat", 953 .name = "stat",
970 .open = mem_control_stat_open, 954 .read_map = mem_control_stat_show,
971 }, 955 },
972}; 956};
973 957