memcg: add memory.numastat api for numa statistics
Subsystems (2)
PATCH v5 1/1 memcg: add memory.numastat api for numa statistics
The new API exports numa_maps per-memcg basis. This is a piece of useful information where it exports per-memcg page distribution across real numa nodes.
One of the usecase is evaluating application performance by combining this information w/ the cpu allocation to the application.
The output of the memory.numastat tries to follow w/ simiar format of numa_maps like:
total=<total pages> N0=<node 0 pages> N1=<node 1 pages> ... file=<total file pages> N0=<node 0 pages> N1=<node 1 pages> ... anon=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ... unevictable=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ...
And we have per-node:
total = file + anon + unevictable
$ cat /dev/cgroup/memory/memory.numa_stat total=250020 N0=87620 N1=52367 N2=45298 N3=64735 file=225232 N0=83402 N1=46160 N2=40522 N3=55148 anon=21053 N0=3424 N1=6207 N2=4776 N3=6646 unevictable=3735 N0=794 N1=0 N2=0 N3=2941
This patch is based on mmotm-2011-05-06-16-39
change v5..v4:
1. disable the API non-NUMA kernel.
change v4..v3:
1. add per-node "unevictable" value.
2. change the functions to be static.
change v3..v2:
1. calculate the "total" based on the per-memcg lru size instead of rss+cache. this makes the "total" value to be consistant w/ the per-node values follows after.
change v2..v1:
1. add also the file and anon pages on per-node distribution.
--- mm/memcontrol.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 155 insertions(+), 0 deletions(-)
mm/memcontrol.c +155 -0
@@ -1162,6 +1162,93 @@ unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,return MEM_CGROUP_ZSTAT (mz, lru); } +#ifdef CONFIG_NUMA +static unsigned long mem_cgroup_node_nr_file_lru_pages (struct mem_cgroup *memcg, +int nid) +{ +unsigned long ret; + + ret =mem_cgroup_get_zonestat_node (memcg, nid,LRU_INACTIVE_FILE ) + +mem_cgroup_get_zonestat_node (memcg, nid,LRU_ACTIVE_FILE ); + +return ret; +} + +static unsigned long mem_cgroup_nr_file_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_file_lru_pages (memcg, nid); + +return total; +} + +static unsigned long mem_cgroup_node_nr_anon_lru_pages (struct mem_cgroup *memcg, +int nid) +{ +unsigned long ret; + + ret =mem_cgroup_get_zonestat_node (memcg, nid,LRU_INACTIVE_ANON ) + +mem_cgroup_get_zonestat_node (memcg, nid,LRU_ACTIVE_ANON ); + +return ret; +} + +static unsigned long mem_cgroup_nr_anon_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_anon_lru_pages (memcg, nid); + +return total; +} + +static unsigned long +mem_cgroup_node_nr_unevictable_lru_pages (struct mem_cgroup *memcg,int nid) +{ +return mem_cgroup_get_zonestat_node (memcg, nid,LRU_UNEVICTABLE ); +} + +static unsigned long +mem_cgroup_nr_unevictable_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_unevictable_lru_pages (memcg, nid); + +return total; +} + +static unsigned long mem_cgroup_node_nr_lru_pages (struct mem_cgroup *memcg, +int nid) +{ +enum lru_list l; +u64 total =0 ; + +for_each_lru (l) + total +=mem_cgroup_get_zonestat_node (memcg, nid, l); + +return total; +} + +static unsigned long mem_cgroup_nr_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_lru_pages (memcg, nid); + +return total; +} +#endif /* CONFIG_NUMA */ +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat (struct mem_cgroup *memcg,struct zone *zone) {
@@ -4048,6 +4135,51 @@ mem_cgroup_get_total_stat(struct mem_cgroup *mem, struct mcs_total_stat *s)mem_cgroup_get_local_stat (iter, s); } +#ifdef CONFIG_NUMA +static int mem_control_numa_stat_show (struct seq_file *m,void *arg) +{ +int nid; +unsigned long total_nr, file_nr, anon_nr, unevictable_nr; +unsigned long node_nr; +struct cgroup *cont = m->private; +struct mem_cgroup *mem_cont =mem_cgroup_from_cont (cont); + + total_nr =mem_cgroup_nr_lru_pages (mem_cont); +seq_printf (m,"total=%lu" , total_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + file_nr =mem_cgroup_nr_file_lru_pages (mem_cont); +seq_printf (m,"file=%lu" , file_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_file_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + anon_nr =mem_cgroup_nr_anon_lru_pages (mem_cont); +seq_printf (m,"anon=%lu" , anon_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_anon_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + unevictable_nr =mem_cgroup_nr_unevictable_lru_pages (mem_cont); +seq_printf (m,"unevictable=%lu" , unevictable_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_unevictable_lru_pages (mem_cont, + nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); +return 0 ; +} +#endif /* CONFIG_NUMA */ +static int mem_control_stat_show (struct cgroup *cont,struct cftype *cft,struct cgroup_map_cb *cb) {
@@ -4058,6 +4190,7 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,memset (&mystat,0 ,sizeof (mystat));mem_cgroup_get_local_stat (mem_cont, &mystat); +for (i =0 ; i <NR_MCS_STAT ; i++) {if (i ==MCS_SWAP && !do_swap_account)continue ;
@@ -4481,6 +4614,22 @@ static int mem_cgroup_oom_control_write(struct cgroup *cgrp,return 0 ; } +#ifdef CONFIG_NUMA +static const struct file_operations mem_control_numa_stat_file_operations = { + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int mem_control_numa_stat_open (struct inode *unused,struct file *file) +{ +struct cgroup *cont = file->f_dentry->d_parent->d_fsdata; + + file->f_op = &mem_control_numa_stat_file_operations; +return single_open (file, mem_control_numa_stat_show, cont); +} +#endif /* CONFIG_NUMA */ +static struct cftype mem_cgroup_files[] = { { .name ="usage_in_bytes" ,
@@ -4544,6 +4693,12 @@ static struct cftype mem_cgroup_files[] = { .unregister_event = mem_cgroup_oom_unregister_event, .private = MEMFILE_PRIVATE(_OOM_TYPE, OOM_CONTROL), }, +#ifdef CONFIG_NUMA + { + .name = "numa_stat", + .open = mem_control_numa_stat_open, + }, +#endif };#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
Signature · 8 lines
1.7.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Ying Han
The new API exports
numa_mapsper-memcg basis. This is a piece of useful information where it exports per-memcg page distribution across real numa nodes.One of the usecase is evaluating application performance by combining this information w/ the cpu allocation to the application.
Quoted 6 lines
The output of the memory.numastat tries to follow w/ simiar format of
numa_mapslike:Signed-off-by Ying Han<[email protected]>Acked-by KAMEZAWA Hiroyuki<[email protected]>Acked-by Daisuke Nishimura<[email protected]>
Signature · 8 lines
All rights reversed -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · On Fri, 20 May 2011 15:01:58 -0700 Ying Han <[email protected]> wrote:
The new API exports
numa_mapsper-memcg basis. This is a piece of useful information where it exports per-memcg page distribution across real numa nodes.One of the usecase is evaluating application performance by combining this information w/ the cpu allocation to the application.
Quoted 8 lines
The output of the memory.numastat tries to follow w/ simiar format of
numa_mapslike:total=<total pages> N0=<node 0 pages> N1=<node 1 pages> ... file=<total file pages> N0=<node 0 pages> N1=<node 1 pages> ... anon=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ... unevictable=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ...
Ah, please update Documentaion please.
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · KAMEZAWA Hiroyuki
Quoted 10 lines · On Fri, 20 May 2011 15:01:58 -0700 Ying Han <[email protected]> wrote:
The new API exports
numa_mapsper-memcg basis. This is a piece of useful information where it exports per-memcg page distribution across real numa nodes.One of the usecase is evaluating application performance by combining this information w/ the cpu allocation to the application.
The output of the memory.numastat tries to follow w/ simiar format of
numa_mapslike:
Quoted 7 lines
Quoted 5 lines
total=<total pages> N0=<node 0 pages> N1=<node 1 pages> ... file=<total file pages> N0=<node 0 pages> N1=<node 1 pages> ... anon=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ... unevictable=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ...
Ah, please update Documentaion please.
Sure, will send out patch for the Documentation.
--Ying
Quoted 6 lines
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 207 lines · Ying Han
The new API exports
numa_mapsper-memcg basis. This is a piece of useful information where it exports per-memcg page distribution across real numa nodes.One of the usecase is evaluating application performance by combining this information w/ the cpu allocation to the application.
The output of the memory.numastat tries to follow w/ simiar format of
numa_mapslike:total=<total pages> N0=<node 0 pages> N1=<node 1 pages> ... file=<total file pages> N0=<node 0 pages> N1=<node 1 pages> ... anon=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ... unevictable=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ...
And we have per-node:
total = file + anon + unevictable$ cat /dev/cgroup/memory/memory.numa_stat total=250020 N0=87620 N1=52367 N2=45298 N3=64735 file=225232 N0=83402 N1=46160 N2=40522 N3=55148 anon=21053 N0=3424 N1=6207 N2=4776 N3=6646 unevictable=3735 N0=794 N1=0 N2=0 N3=2941This patch is based on mmotm-2011-05-06-16-39
change v5..v4:
1. disable the API non-NUMA kernel.change v4..v3:
1. add per-node "unevictable" value.
2. change the functions to be static.change v3..v2:
1. calculate the "total" based on the per-memcg lru size instead of rss+cache. this makes the "total" value to be consistant w/ the per-node values follows after.change v2..v1:
1. add also the file and anon pages on per-node distribution.Signed-off-by Ying Han <[email protected]>--- mm/memcontrol.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 155 insertions(+), 0 deletions(-)mm/memcontrol.c +133
-0@@ -1162,6 +1162,93 @@ unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,return MEM_CGROUP_ZSTAT (mz, lru); } +#ifdef CONFIG_NUMA +static unsigned long mem_cgroup_node_nr_file_lru_pages (struct mem_cgroup *memcg, +int nid) +{ +unsigned long ret; + + ret =mem_cgroup_get_zonestat_node (memcg, nid,LRU_INACTIVE_FILE ) + +mem_cgroup_get_zonestat_node (memcg, nid,LRU_ACTIVE_FILE ); + +return ret; +} + +static unsigned long mem_cgroup_nr_file_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_file_lru_pages (memcg, nid); + +return total; +} + +static unsigned long mem_cgroup_node_nr_anon_lru_pages (struct mem_cgroup *memcg, +int nid) +{ +unsigned long ret; + + ret =mem_cgroup_get_zonestat_node (memcg, nid,LRU_INACTIVE_ANON ) + +mem_cgroup_get_zonestat_node (memcg, nid,LRU_ACTIVE_ANON ); + +return ret; +} + +static unsigned long mem_cgroup_nr_anon_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_anon_lru_pages (memcg, nid); + +return total; +} + +static unsigned long +mem_cgroup_node_nr_unevictable_lru_pages (struct mem_cgroup *memcg,int nid) +{ +return mem_cgroup_get_zonestat_node (memcg, nid,LRU_UNEVICTABLE ); +} + +static unsigned long +mem_cgroup_nr_unevictable_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_unevictable_lru_pages (memcg, nid); + +return total; +} + +static unsigned long mem_cgroup_node_nr_lru_pages (struct mem_cgroup *memcg, +int nid) +{ +enum lru_list l; +u64 total =0 ; + +for_each_lru (l) + total +=mem_cgroup_get_zonestat_node (memcg, nid, l); + +return total; +} + +static unsigned long mem_cgroup_nr_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_lru_pages (memcg, nid); + +return total; +} +#endif /* CONFIG_NUMA */ +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat (struct mem_cgroup *memcg,struct zone *zone) {@@ -4048,6 +4135,51 @@ mem_cgroup_get_total_stat(struct mem_cgroup *mem, struct mcs_total_stat *s)mem_cgroup_get_local_stat (iter, s); } +#ifdef CONFIG_NUMA +static int mem_control_numa_stat_show (struct seq_file *m,void *arg) +{ +int nid; +unsigned long total_nr, file_nr, anon_nr, unevictable_nr; +unsigned long node_nr; +struct cgroup *cont = m->private; +struct mem_cgroup *mem_cont =mem_cgroup_from_cont (cont); + + total_nr =mem_cgroup_nr_lru_pages (mem_cont); +seq_printf (m,"total=%lu" , total_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + file_nr =mem_cgroup_nr_file_lru_pages (mem_cont); +seq_printf (m,"file=%lu" , file_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_file_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + anon_nr =mem_cgroup_nr_anon_lru_pages (mem_cont); +seq_printf (m,"anon=%lu" , anon_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_anon_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + unevictable_nr =mem_cgroup_nr_unevictable_lru_pages (mem_cont); +seq_printf (m,"unevictable=%lu" , unevictable_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_unevictable_lru_pages (mem_cont, + nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); +return 0 ; +} +#endif /* CONFIG_NUMA */ +static int mem_control_stat_show (struct cgroup *cont,struct cftype *cft,struct cgroup_map_cb *cb) {@@ -4058,6 +4190,7 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,memset (&mystat,0 ,sizeof (mystat));mem_cgroup_get_local_stat (mem_cont, &mystat); +for (i =0 ; i <NR_MCS_STAT ; i++) {if (i ==MCS_SWAP && !do_swap_account)continue ;
mm/memcontrol.c static int mem_cgroup_oom_control_write(struct cgroup *cgrp, · line 4623
Quoted 10 lines
mm/memcontrol.c +7
-0@@ -4481,6 +4614,22 @@ static int mem_cgroup_oom_control_write(struct cgroup *cgrp,return 0 ; } +#ifdef CONFIG_NUMA +static const struct file_operations mem_control_numa_stat_file_operations = { + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +
Do we need this?
Quoted 13 lines
mm/memcontrol.c +9
-0+static int mem_control_numa_stat_open (struct inode *unused,struct file *file) +{ +struct cgroup *cont = file->f_dentry->d_parent->d_fsdata; + + file->f_op = &mem_control_numa_stat_file_operations; +return single_open (file, mem_control_numa_stat_show, cont); +} +#endif /* CONFIG_NUMA */ +static struct cftype mem_cgroup_files[] = { { .name ="usage_in_bytes" ,
mm/memcontrol.c static struct cftype mem_cgroup_files[] = { · line 4701
Quoted 9 lines
mm/memcontrol.c +6
-0@@ -4544,6 +4693,12 @@ static struct cftype mem_cgroup_files[] = { .unregister_event = mem_cgroup_oom_unregister_event, .private = MEMFILE_PRIVATE(_OOM_TYPE, OOM_CONTROL), }, +#ifdef CONFIG_NUMA + { + .name = "numa_stat", + .open = mem_control_numa_stat_open, + }, +#endif
Can't we do this the way we do the stats file? Please see mem_control_stat_show().
Quoted 6 lines
mm/memcontrol.c +0
-0};#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP Signature · 1 line
1.7.3.1
Signature · 9 lines
Three Cheers, Balbir -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 262 lines · Balbir Singh
Quoted 5 lines · Ying Han
The new API exports
numa_mapsper-memcg basis. This is a piece of useful information where it exports per-memcg page distribution across real numa nodes.One of the usecase is evaluating application performance by combining
this
Quoted 3 lines
information w/ the cpu allocation to the application.
The output of the memory.numastat tries to follow w/ simiar format of
numa_mapsQuoted 21 lines
like:
total=<total pages> N0=<node 0 pages> N1=<node 1 pages> ... file=<total file pages> N0=<node 0 pages> N1=<node 1 pages> ... anon=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ... unevictable=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ...
And we have per-node:
total = file + anon + unevictable$ cat /dev/cgroup/memory/memory.numa_stat total=250020 N0=87620 N1=52367 N2=45298 N3=64735 file=225232 N0=83402 N1=46160 N2=40522 N3=55148 anon=21053 N0=3424 N1=6207 N2=4776 N3=6646 unevictable=3735 N0=794 N1=0 N2=0 N3=2941This patch is based on mmotm-2011-05-06-16-39
change v5..v4:
1. disable the API non-NUMA kernel.Quoted 6 lines
change v4..v3:
1. add per-node "unevictable" value.
2. change the functions to be static.change v3..v2:
1. calculate the "total" based on the per-memcg lru size instead ofrss+cache.
Quoted 1 line
this makes the "total" value to be consistant w/ the per-node values
follows
Quoted 10 lines
after.
change v2..v1:
1. add also the file and anon pages on per-node distribution.Signed-off-by Ying Han <[email protected]>--- mm/memcontrol.c | 155+++++++++++++++++++++++++++++++++++++++++++++++++++++++
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct
Quoted 7 lines
1 files changed, 155 insertions(+), 0 deletions(-)mm/memcontrol.c +0
-0@@ -1162,6 +1162,93 @@ unsigned long mem_cgroup_zone_nr_lru_pages(struct
mem_cgroup*memcg,mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 5 lines
mm/memcontrol.c +2
-0return MEM_CGROUP_ZSTAT (mz, lru); } +#ifdef CONFIG_NUMA +static unsigned long mem_cgroup_node_nr_file_lru_pages(struct mem_cgroup*memcg,
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 11 lines
mm/memcontrol.c +11
-0+ int nid) +{ +unsigned long ret; + + ret =mem_cgroup_get_zonestat_node (memcg, nid,LRU_INACTIVE_FILE ) + +mem_cgroup_get_zonestat_node (memcg, nid,LRU_ACTIVE_FILE ); + +return ret; +} + +static unsigned long mem_cgroup_nr_file_lru_pages(struct mem_cgroup*memcg)
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 11 lines
mm/memcontrol.c +11
-0+{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_file_lru_pages (memcg, nid); + +return total; +} + +static unsigned long mem_cgroup_node_nr_anon_lru_pages(struct mem_cgroup*memcg,
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 11 lines
mm/memcontrol.c +11
-0+ int nid) +{ +unsigned long ret; + + ret =mem_cgroup_get_zonestat_node (memcg, nid,LRU_INACTIVE_ANON ) + +mem_cgroup_get_zonestat_node (memcg, nid,LRU_ACTIVE_ANON ); + +return ret; +} + +static unsigned long mem_cgroup_nr_anon_lru_pages(struct mem_cgroup*memcg)
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 12 lines
mm/memcontrol.c +12
-0+{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_anon_lru_pages (memcg, nid); + +return total; +} + +static unsigned long +mem_cgroup_node_nr_unevictable_lru_pages(struct mem_cgroup *memcg, intnid)
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 12 lines
mm/memcontrol.c +12
-0+{ +return mem_cgroup_get_zonestat_node (memcg, nid,LRU_UNEVICTABLE ); +} + +static unsigned long +mem_cgroup_nr_unevictable_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total += mem_cgroup_node_nr_unevictable_lru_pages(memcg,nid);
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 5 lines
mm/memcontrol.c +5
-0+ +return total; +} + +static unsigned long mem_cgroup_node_nr_lru_pages(struct mem_cgroup*memcg,
Quoted 14 lines
mm/memcontrol.c +14
-0+ int nid) +{ +enum lru_list l; +u64 total =0 ; + +for_each_lru (l) + total +=mem_cgroup_get_zonestat_node (memcg, nid, l); + +return total; +} + +static unsigned long mem_cgroup_nr_lru_pages (struct mem_cgroup *memcg) +{ +u64 total =0 ;mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 10 lines
mm/memcontrol.c +9
-0+int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_lru_pages (memcg, nid); + +return total; +} +#endif /* CONFIG_NUMA */ + struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup*memcg,
mm/memcontrol.c mem_cgroup_get_total_stat(struct mem_cgroup *mem,
Quoted 3 lines
mm/memcontrol.c +0
-0struct zone *zone) {@@ -4048,6 +4135,51 @@ mem_cgroup_get_total_stat(struct mem_cgroup *mem,struct
mcs_total_stat*s)Quoted 30 lines
mm/memcontrol.c +27
-0mem_cgroup_get_local_stat (iter, s); } +#ifdef CONFIG_NUMA +static int mem_control_numa_stat_show (struct seq_file *m,void *arg) +{ +int nid; +unsigned long total_nr, file_nr, anon_nr, unevictable_nr; +unsigned long node_nr; +struct cgroup *cont = m->private; +struct mem_cgroup *mem_cont =mem_cgroup_from_cont (cont); + + total_nr =mem_cgroup_nr_lru_pages (mem_cont); +seq_printf (m,"total=%lu" , total_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + file_nr =mem_cgroup_nr_file_lru_pages (mem_cont); +seq_printf (m,"file=%lu" , file_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_file_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + anon_nr =mem_cgroup_nr_anon_lru_pages (mem_cont); +seq_printf (m,"anon=%lu" , anon_nr);mm/memcontrol.c mem_cgroup_get_total_stat(struct mem_cgroup *mem, struct mcs_total_stat *s)
Quoted 10 lines
mm/memcontrol.c +10
-0+for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_anon_lru_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + unevictable_nr =mem_cgroup_nr_unevictable_lru_pages (mem_cont); +seq_printf (m,"unevictable=%lu" , unevictable_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_unevictable_lru_pages(mem_cont,
mm/memcontrol.c mem_cgroup_get_total_stat(struct mem_cgroup *mem, · line 4175
Quoted 1 line
mm/memcontrol.c +1
-0+nid);
mm/memcontrol.c mem_cgroup_get_total_stat(struct mem_cgroup *mem, struct mcs_total_stat *s)
Quoted 8 lines
mm/memcontrol.c +7
-0+ seq_printf(m, " N%d=%lu", nid, node_nr); + } +seq_putc (m,'\n' ); +return 0 ; +} +#endif /* CONFIG_NUMA */ + static int mem_control_stat_show(struct cgroup *cont, struct cftype*cft,
mm/memcontrol.c static int mem_control_stat_show(struct cgroup
Quoted 3 lines
mm/memcontrol.c +0
-0struct cgroup_map_cb *cb) {@@ -4058,6 +4190,7 @@ static int mem_control_stat_show(struct cgroup*cont, struct cftype *cft,
mm/memcontrol.c static int mem_cgroup_oom_control_write(struct
Quoted 8 lines
mm/memcontrol.c +1
-0memset (&mystat,0 ,sizeof (mystat));mem_cgroup_get_local_stat (mem_cont, &mystat); +for (i =0 ; i <NR_MCS_STAT ; i++) {if (i ==MCS_SWAP && !do_swap_account)continue ;@@ -4481,6 +4614,22 @@ static int mem_cgroup_oom_control_write(structcgroup *cgrp,
mm/memcontrol.c static int mem_cgroup_oom_control_write(struct cgroup *cgrp,
Quoted 5 lines
mm/memcontrol.c +2
-0return 0 ; } +#ifdef CONFIG_NUMA +static const struct file_operations
mem_control_numa_stat_file_operations= {mm/memcontrol.c static int mem_cgroup_oom_control_write(struct cgroup *cgrp, · line 4623
Quoted 5 lines
mm/memcontrol.c +5
-0+ .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +Do we need this?
mm/memcontrol.c static int mem_cgroup_oom_control_write(struct · line 4624
Quoted 1 line
mm/memcontrol.c +1
-0+static int mem_control_numa_stat_open(struct inode *unused, struct file*file)
Quoted 16 lines
mm/memcontrol.c +9
-0+{ +struct cgroup *cont = file->f_dentry->d_parent->d_fsdata; + + file->f_op = &mem_control_numa_stat_file_operations; +return single_open (file, mem_control_numa_stat_show, cont); +} +#endif /* CONFIG_NUMA */ +static struct cftype mem_cgroup_files[] = { { .name ="usage_in_bytes" ,@@ -4544,6 +4693,12 @@ static struct cftype mem_cgroup_files[] = { .unregister_event = mem_cgroup_oom_unregister_event, .private = MEMFILE_PRIVATE(_OOM_TYPE, OOM_CONTROL), }, +#ifdef CONFIG_NUMA
Quoted 9 lines
mm/memcontrol.c static struct cftype mem_cgroup_files[] = { · line 4701
Quoted 5 lines
mm/memcontrol.c +5
-0+ { + .name = "numa_stat", + .open = mem_control_numa_stat_open, + }, +#endif Can't we do this the way we do the stats file? Please see
mem_control_stat_show().
I looked that earlier but can not get the formating working as well as the seq_*. Is there a particular reason we prefer one than the other?
Thanks
--Ying
Quoted 20 lines
Quoted 7 lines
mm/memcontrol.c +0
-1};#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP --1.7.3.1
--
Three Cheers,
Balbir--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign
http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Balbir Singh
Acked-byQuoted 18 lines · Ying Han
Quoted 8 lines
Quoted 8 lines
static struct cftype mem_cgroup_files[] = { { .name = "usage_in_bytes",mm/memcontrol.c +1
-0@@ -4544,6 +4693,12 @@ static struct cftype mem_cgroup_files[] = { .unregister_event = mem_cgroup_oom_unregister_event, .private = MEMFILE_PRIVATE(_OOM_TYPE, OOM_CONTROL), }, +#ifdef CONFIG_NUMA Quoted 9 lines
mm/memcontrol.c static struct cftype mem_cgroup_files[] = { · line 4701
Quoted 5 lines
mm/memcontrol.c +5
-0+ { + .name = "numa_stat", + .open = mem_control_numa_stat_open, + }, +#endif Can't we do this the way we do the stats file? Please see
mem_control_stat_show().
Quoted 3 lines
I looked that earlier but can not get the formating working as well as the seq_*. Is there a particular reason we prefer one than the other?
Fair enough, I wanted to avoid repeating what kernel/cgroup.c already does in terms of formatting output.
Signature · 9 lines
Three Cheers, Balbir -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>