diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5f3ad9c37bea..904e9a9c223d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/swap.h> | 29 | #include <linux/swap.h> |
30 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
31 | #include <linux/fs.h> | 31 | #include <linux/fs.h> |
32 | #include <linux/seq_file.h> | ||
32 | 33 | ||
33 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
34 | 35 | ||
@@ -794,6 +795,49 @@ static ssize_t mem_force_empty_read(struct cgroup *cont, | |||
794 | } | 795 | } |
795 | 796 | ||
796 | 797 | ||
798 | static const struct mem_cgroup_stat_desc { | ||
799 | const char *msg; | ||
800 | u64 unit; | ||
801 | } mem_cgroup_stat_desc[] = { | ||
802 | [MEM_CGROUP_STAT_CACHE] = { "cache", PAGE_SIZE, }, | ||
803 | [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, }, | ||
804 | }; | ||
805 | |||
806 | static int mem_control_stat_show(struct seq_file *m, void *arg) | ||
807 | { | ||
808 | struct cgroup *cont = m->private; | ||
809 | struct mem_cgroup *mem_cont = mem_cgroup_from_cont(cont); | ||
810 | struct mem_cgroup_stat *stat = &mem_cont->stat; | ||
811 | int i; | ||
812 | |||
813 | for (i = 0; i < ARRAY_SIZE(stat->cpustat[0].count); i++) { | ||
814 | s64 val; | ||
815 | |||
816 | val = mem_cgroup_read_stat(stat, i); | ||
817 | val *= mem_cgroup_stat_desc[i].unit; | ||
818 | seq_printf(m, "%s %lld\n", mem_cgroup_stat_desc[i].msg, | ||
819 | (long long)val); | ||
820 | } | ||
821 | return 0; | ||
822 | } | ||
823 | |||
824 | static const struct file_operations mem_control_stat_file_operations = { | ||
825 | .read = seq_read, | ||
826 | .llseek = seq_lseek, | ||
827 | .release = single_release, | ||
828 | }; | ||
829 | |||
830 | static int mem_control_stat_open(struct inode *unused, struct file *file) | ||
831 | { | ||
832 | /* XXX __d_cont */ | ||
833 | struct cgroup *cont = file->f_dentry->d_parent->d_fsdata; | ||
834 | |||
835 | file->f_op = &mem_control_stat_file_operations; | ||
836 | return single_open(file, mem_control_stat_show, cont); | ||
837 | } | ||
838 | |||
839 | |||
840 | |||
797 | static struct cftype mem_cgroup_files[] = { | 841 | static struct cftype mem_cgroup_files[] = { |
798 | { | 842 | { |
799 | .name = "usage_in_bytes", | 843 | .name = "usage_in_bytes", |
@@ -821,6 +865,10 @@ static struct cftype mem_cgroup_files[] = { | |||
821 | .write = mem_force_empty_write, | 865 | .write = mem_force_empty_write, |
822 | .read = mem_force_empty_read, | 866 | .read = mem_force_empty_read, |
823 | }, | 867 | }, |
868 | { | ||
869 | .name = "stat", | ||
870 | .open = mem_control_stat_open, | ||
871 | }, | ||
824 | }; | 872 | }; |
825 | 873 | ||
826 | static struct mem_cgroup init_mem_cgroup; | 874 | static struct mem_cgroup init_mem_cgroup; |