aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2008-02-07 03:14:25 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:20 -0500
commitd2ceb9b7ddedbb2e8e590bc6ce33c854043016f9 (patch)
tree1c75e7947a86c6891bae16129086f4b0d10abc33
parentd52aa412d43827033a8e2ce4415ef6e8f8d53635 (diff)
memory cgroup enhancements: add memory.stat file
Show accounted information of memory cgroup by memory.stat file [akpm@linux-foundation.org: coding-style fixes] [akpm@linux-foundation.org: fix printk warning] Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Paul Menage <menage@google.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Kirill Korotaev <dev@sw.ru> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: David Rientjes <rientjes@google.com> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/memcontrol.c48
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
798static 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
806static 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
824static const struct file_operations mem_control_stat_file_operations = {
825 .read = seq_read,
826 .llseek = seq_lseek,
827 .release = single_release,
828};
829
830static 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
797static struct cftype mem_cgroup_files[] = { 841static 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
826static struct mem_cgroup init_mem_cgroup; 874static struct mem_cgroup init_mem_cgroup;