memcg: rename mem_cgroup_zone_nr_pages() to mem_cgroup_zone_nr_lru_pages()
Subsystems (4)
PATCH v2 2/2 memcg: add memory.numastat api for numa statistics
In reply to Ying HanThe 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> ...
$ cat /dev/cgroup/memory/memory.numa_stat total=317674 N0=101850 N1=72552 N2=30120 N3=113142 file=288219 N0=98046 N1=59220 N2=23578 N3=107375 anon=25699 N0=3804 N1=10124 N2=6540 N3=5231
Note: I noticed <total pages> is not equal to the sum of the rest of counters. I might need to change the way get that counter, comments are welcomed.
change v2..v1:
1. add also the file and anon pages on per-node distribution.
--- mm/memcontrol.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 109 insertions(+), 0 deletions(-)
mm/memcontrol.c +109 -0
@@ -1162,6 +1162,62 @@ unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,return MEM_CGROUP_ZSTAT (mz, lru); } +unsigned long mem_cgroup_node_nr_file_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; +} + +unsigned long mem_cgroup_node_nr_anon_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; +} + +unsigned long mem_cgroup_node_nr_lru_pages (struct mem_cgroup *memcg, +int nid,bool file) +{ +if (file) +return mem_cgroup_node_nr_file_pages (memcg, nid); +else +return mem_cgroup_node_nr_anon_pages (memcg, nid); +} + +unsigned long mem_cgroup_nr_lru_pages (struct mem_cgroup *memcg,bool file) +{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_lru_pages (memcg, nid, file); + +return total; +} + +unsigned long mem_cgroup_node_nr_pages (struct mem_cgroup *memcg,int nid) +{ +int zid; +struct mem_cgroup_per_zone *mz; +enum lru_list l; +u64 total =0 ; + +for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { + mz =mem_cgroup_zoneinfo (memcg, nid, zid); +for_each_lru (l) + total +=MEM_CGROUP_ZSTAT (mz, l); + } + +return total; +} +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat (struct mem_cgroup *memcg,struct zone *zone) {
@@ -4048,6 +4104,41 @@ mem_cgroup_get_total_stat(struct mem_cgroup *mem, struct mcs_total_stat *s)mem_cgroup_get_local_stat (iter, s); } +static int mem_control_numa_stat_show (struct seq_file *m,void *arg) +{ +int nid; +unsigned long total_nr, file_nr, anon_nr; +unsigned long node_nr; +struct cgroup *cont = m->private; +struct mem_cgroup *mem_cont =mem_cgroup_from_cont (cont); + + total_nr =mem_cgroup_local_usage (mem_cont); +seq_printf (m,"total=%lu" , total_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + file_nr =mem_cgroup_nr_lru_pages (mem_cont,1 ); +seq_printf (m,"file=%lu" , file_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid,1 ); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + anon_nr =mem_cgroup_nr_lru_pages (mem_cont,0 ); +seq_printf (m,"anon=%lu" , anon_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid,0 ); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + +return 0 ; +} +static int mem_control_stat_show (struct cgroup *cont,struct cftype *cft,struct cgroup_map_cb *cb) {
@@ -4481,6 +4572,20 @@ static int mem_cgroup_oom_control_write(struct cgroup *cgrp,return 0 ; } +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); +} +static struct cftype mem_cgroup_files[] = { { .name ="usage_in_bytes" ,
@@ -4544,6 +4649,10 @@ static struct cftype mem_cgroup_files[] = { .unregister_event = mem_cgroup_oom_unregister_event, .private = MEMFILE_PRIVATE(_OOM_TYPE, OOM_CONTROL), }, + { + .name = "numa_stat", + .open = mem_control_numa_stat_open, + }, };#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>
PATCH v2 1/2 memcg: rename mem_cgroup_zone_nr_pages() to mem_cgroup_zone_nr_lru_pages()
The caller of the function has been renamed to zone_nr_lru_pages(), and this is just fixing up in the memcg code. The current name is easily to be mis-read as zone's total number of pages.
This patch is based on mmotm-2011-05-06-16-39
no change on this patch from v1.
--- include/linux/memcontrol.h | 10 +++++----- mm/memcontrol.c | 6 +++--- mm/vmscan.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-)
include/linux/memcontrol.h +5 -5
@@ -109,9 +109,9 @@ extern void mem_cgroup_end_migration(struct mem_cgroup *mem,int mem_cgroup_inactive_anon_is_low (struct mem_cgroup *memcg);int mem_cgroup_inactive_file_is_low (struct mem_cgroup *memcg);int mem_cgroup_select_victim_node (struct mem_cgroup *memcg); -unsigned long mem_cgroup_zone_nr_pages (struct mem_cgroup *memcg, -struct zone *zone, -enum lru_list lru); +unsigned long mem_cgroup_zone_nr_lru_pages (struct mem_cgroup *memcg, +struct zone *zone, +enum lru_list lru);struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat (struct mem_cgroup *memcg,struct zone *zone); struct zone_reclaim_stat*
@@ -306,8 +306,8 @@ mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg) }static inline unsigned long -mem_cgroup_zone_nr_pages (struct mem_cgroup *memcg,struct zone *zone, -enum lru_list lru) +mem_cgroup_zone_nr_lru_pages (struct mem_cgroup *memcg,struct zone *zone, +enum lru_list lru) {return 0 ; }
mm/memcontrol.c +3 -3
@@ -1151,9 +1151,9 @@ int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg)return (active > inactive); } -unsigned long mem_cgroup_zone_nr_pages (struct mem_cgroup *memcg, -struct zone *zone, -enum lru_list lru) +unsigned long mem_cgroup_zone_nr_lru_pages (struct mem_cgroup *memcg, +struct zone *zone, +enum lru_list lru) {int nid =zone_to_nid (zone);int zid =zone_idx (zone);
mm/vmscan.c +1 -1
@@ -172,7 +172,7 @@ static unsigned long zone_nr_lru_pages(struct zone *zone, struct scan_control *sc, enum lru_list lru) {if (!scanning_global_lru (sc)) -return mem_cgroup_zone_nr_pages (sc->mem_cgroup, zone, lru); +return mem_cgroup_zone_nr_lru_pages (sc->mem_cgroup, zone, lru);return zone_page_state (zone,NR_LRU_BASE + lru); }
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>
PATCH 1/1 memcg: fix a routine for counting pages in node (Re: [PATCH V2 2/2] memcg: add memory.numastat api for numa statistics
In reply to Ying HanOn Wed, 18 May 2011 17:55:11 -0700
Ying Han <[email protected]> wrote:
$ cat /dev/cgroup/memory/memory.numa_stat
Quoted 7 lines
total=317674 N0=101850 N1=72552 N2=30120 N3=113142 file=288219 N0=98046 N1=59220 N2=23578 N3=107375 anon=25699 N0=3804 N1=10124 N2=6540 N3=5231
Note: I noticed <total pages> is not equal to the sum of the rest of counters. I might need to change the way get that counter, comments are welcomed.
Please debug when you feel strange ;)
Here is a fix. Could you test ?
==
The value for counter base should be initialized. If not, this returns wrong value.
--- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
@@ -710,7 +710,7 @@ static unsigned long mem_cgroup_get_zonestat_node(struct mem_cgroup *mem, int nid, enum lru_list idx) { struct mem_cgroup_per_zone *mz; -u64 total; +u64 total =0 ;int zid;for (zid =0 ; zid <MAX_NR_ZONES ; zid++) {
--
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>
Re: [PATCH][BUGFIX] memcg: fix a routine for counting pages in node (Re: [PATCH V2 2/2] memcg: add memory.numastat api for numa statistics
Quoted 7 lines · KAMEZAWA Hiroyuki
On Wed, 18 May 2011 17:55:11 -0700
Ying Han <[email protected]> wrote:$ cat /dev/cgroup/memory/memory.numa_statQuoted 4 lines
total=317674 N0=101850 N1=72552 N2=30120 N3=113142 file=288219 N0=98046 N1=59220 N2=23578 N3=107375 anon=25699 N0=3804 N1=10124 N2=6540 N3=5231
Quoted 9 lines
Quoted 1 line
Note: I noticed <total pages> is not equal to the sum of the rest of
counters.
Quoted 2 lines
I might need to change the way get that counter, comments are welcomed.
Please debug when you feel strange ;)
Here is a fix. Could you test ?
Thanks for the patch. I will test it and post it again.
--Ying
Quoted 26 lines
==
The value for counter base should be initialized. If not, this returns wrong value.Signed-off-by KAMEZAWA Hiroyuki <[email protected]>--- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
mmotm-May11/mm/memcontrol.c
===================================================================mm/memcontrol.c +1
-1@@ -710,7 +710,7 @@ static unsigned long mem_cgroup_get_zonestat_node(struct mem_cgroup *mem, int nid, enum lru_list idx) { struct mem_cgroup_per_zone *mz; -u64 total; +u64 total =0 ;int zid;for (zid = 0; zid < MAX_NR_ZONES; zid++) {
Re: [PATCH][BUGFIX] memcg: fix a routine for counting pages in node (Re: [PATCH V2 2/2] memcg: add memory.numastat api for numa statistics
Quoted 17 lines · Ying Han
Quoted 12 lines · KAMEZAWA Hiroyuki
On Wed, 18 May 2011 17:55:11 -0700
Ying Han <[email protected]> wrote:$ cat /dev/cgroup/memory/memory.numa_statQuoted 5 lines
total=317674 N0=101850 N1=72552 N2=30120 N3=113142 file=288219 N0=98046 N1=59220 N2=23578 N3=107375 anon=25699 N0=3804 N1=10124 N2=6540 N3=5231
Note: I noticed <total pages> is not equal to the sum of the rest of
counters.
Quoted 2 lines
I might need to change the way get that counter, comments are welcomed.
Quoted 7 lines
Quoted 4 lines
Please debug when you feel strange ;)
Here is a fix. Could you test ?
Thanks for the patch. I will test it and post it again.
I tested and it doesn't fix the problem. Anyway, I will dig into that from now.
thanks
--Ying
Quoted 30 lines
--Ying
Quoted 26 lines
==
The value for counter base should be initialized. If not, this returns wrong value.Signed-off-by KAMEZAWA Hiroyuki <[email protected]>--- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
mmotm-May11/mm/memcontrol.c
===================================================================mm/memcontrol.c +1
-1@@ -710,7 +710,7 @@ static unsigned long mem_cgroup_get_zonestat_node(struct mem_cgroup *mem, int nid, enum lru_list idx) { struct mem_cgroup_per_zone *mz; -u64 total; +u64 total =0 ;int zid;for (zid = 0; zid < MAX_NR_ZONES; zid++) {
Re: [PATCH V2 2/2] memcg: add memory.numastat api for numa statistics
In reply to Ying HanQuoted 14 lines · On Wed, 18 May 2011 17:55:11 -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: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> ...
Quoted 8 lines
$ cat /dev/cgroup/memory/memory.numa_stat total=317674 N0=101850 N1=72552 N2=30120 N3=113142 file=288219 N0=98046 N1=59220 N2=23578 N3=107375 anon=25699 N0=3804 N1=10124 N2=6540 N3=5231Note: I noticed <total pages> is not equal to the sum of the rest of counters. I might need to change the way get that counter, comments are welcomed.
Isn't it just because <total pages>(mem_cgroup_local_usage()) includes pages which are not on any LRU, while other counters doesn't ?
Quoted 46 lines
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 | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 109 insertions(+), 0 deletions(-)mm/memcontrol.c +30
-0@@ -1162,6 +1162,62 @@ unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,return MEM_CGROUP_ZSTAT (mz, lru); } +unsigned long mem_cgroup_node_nr_file_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; +} + +unsigned long mem_cgroup_node_nr_anon_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; +} + +unsigned long mem_cgroup_node_nr_lru_pages (struct mem_cgroup *memcg, +int nid,bool file) +{ +if (file) +return mem_cgroup_node_nr_file_pages (memcg, nid); +else +return mem_cgroup_node_nr_anon_pages (memcg, nid); +} + +unsigned long mem_cgroup_nr_lru_pages (struct mem_cgroup *memcg,bool file)
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, · line 1204
Quoted 10 lines
mm/memcontrol.c +10
-0+{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_lru_pages (memcg, nid, file); + +return total; +} +
Can these functions defined as "static" ?
Quoted 6 lines
mm/memcontrol.c +6
-0+unsigned long mem_cgroup_node_nr_pages (struct mem_cgroup *memcg,int nid) +{ +int zid; +struct mem_cgroup_per_zone *mz; +enum lru_list l; +u64 total =0 ;
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, · line 1220
Quoted 10 lines
mm/memcontrol.c +10
-0+ +for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { + mz =mem_cgroup_zoneinfo (memcg, nid, zid); +for_each_lru (l) + total +=MEM_CGROUP_ZSTAT (mz, l); + } + +return total; +} +
ditto.
And I think this function can be implemented by using mem_cgroup_get_zonestat_node().
for_each_lru(l) total += mem_cgroup_get_zonestat_node(memcg, nid, l);
As KAMEZAWA-san posted a fix already, mem_cgroup_get_zonestat_node() must be fixed first.
Thanks,
Daisuke Nishimura.
Quoted 80 lines
mm/memcontrol.c +53
-0struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat (struct mem_cgroup *memcg,struct zone *zone) {@@ -4048,6 +4104,41 @@ mem_cgroup_get_total_stat(struct mem_cgroup *mem, struct mcs_total_stat *s)mem_cgroup_get_local_stat (iter, s); } +static int mem_control_numa_stat_show (struct seq_file *m,void *arg) +{ +int nid; +unsigned long total_nr, file_nr, anon_nr; +unsigned long node_nr; +struct cgroup *cont = m->private; +struct mem_cgroup *mem_cont =mem_cgroup_from_cont (cont); + + total_nr =mem_cgroup_local_usage (mem_cont); +seq_printf (m,"total=%lu" , total_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + file_nr =mem_cgroup_nr_lru_pages (mem_cont,1 ); +seq_printf (m,"file=%lu" , file_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid,1 ); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + anon_nr =mem_cgroup_nr_lru_pages (mem_cont,0 ); +seq_printf (m,"anon=%lu" , anon_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid,0 ); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + +return 0 ; +} +static int mem_control_stat_show (struct cgroup *cont,struct cftype *cft,struct cgroup_map_cb *cb) {@@ -4481,6 +4572,20 @@ static int mem_cgroup_oom_control_write(struct cgroup *cgrp,return 0 ; } +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); +} +static struct cftype mem_cgroup_files[] = { { .name ="usage_in_bytes" ,@@ -4544,6 +4649,10 @@ static struct cftype mem_cgroup_files[] = { .unregister_event = mem_cgroup_oom_unregister_event, .private = MEMFILE_PRIVATE(_OOM_TYPE, OOM_CONTROL), }, + { + .name = "numa_stat", + .open = mem_control_numa_stat_open, + }, };#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP Signature · 1 line
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>
Re: [PATCH V2 2/2] memcg: add memory.numastat api for numa statistics
In reply to Ying HanQuoted 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 7 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> ...
That seems like a good idea, so +1 for we need to do this.
Quoted 8 lines
$ cat /dev/cgroup/memory/memory.numa_stat total=317674 N0=101850 N1=72552 N2=30120 N3=113142 file=288219 N0=98046 N1=59220 N2=23578 N3=107375 anon=25699 N0=3804 N1=10124 N2=6540 N3=5231Note: I noticed <total pages> is not equal to the sum of the rest of counters. I might need to change the way get that counter, comments are welcomed.
Can you see if the total is greater or lesser than the actual value? Do you have any pages mlocked?
Quoted 8 lines
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 | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 109 insertions(+), 0 deletions(-)
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 9 lines · Ying Han
The caller of the function has been renamed to
zone_nr_lru_pages(), and this is just fixing up in the memcg code. The current name is easily to be mis-read as zone's total number of pages.This patch is based on mmotm-2011-05-06-16-39
no change on this patch from v1.
Signed-off-by Ying Han <[email protected]>
--
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>
Re: [PATCH V2 2/2] memcg: add memory.numastat api for numa statistics
In reply to Balbir SinghQuoted 12 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_maps
Quoted 9 lines
Quoted 6 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> ...
That seems like a good idea, so +1 for we need to do this.
Thanks for the +1 :)
Quoted 6 lines
Quoted 6 lines
$ cat /dev/cgroup/memory/memory.numa_stat total=317674 N0=101850 N1=72552 N2=30120 N3=113142 file=288219 N0=98046 N1=59220 N2=23578 N3=107375 anon=25699 N0=3804 N1=10124 N2=6540 N3=5231
Quoted 8 lines
Quoted 1 line
Note: I noticed <total pages> is not equal to the sum of the rest of
counters.
Quoted 2 lines
I might need to change the way get that counter, comments are welcomed.
Can you see if the total is greater or lesser than the actual value? Do you have any pages mlocked?
As i replied Daisuke, i think the problem is some pages charged to the memcg might not on the LRU.
--Ying
Quoted 14 lines
Quoted 7 lines
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 | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 2 lines
1 files changed, 109 insertions(+), 0 deletions(-)--
Three Cheers,
Balbir
Re: [PATCH V2 2/2] memcg: add memory.numastat api for numa statistics
In reply to Daisuke NishimuraQuoted 24 lines · Daisuke Nishimura
Quoted 5 lines · On Wed, 18 May 2011 17:55:11 -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
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 11 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> ...
$ cat /dev/cgroup/memory/memory.numa_stat total=317674 N0=101850 N1=72552 N2=30120 N3=113142 file=288219 N0=98046 N1=59220 N2=23578 N3=107375 anon=25699 N0=3804 N1=10124 N2=6540 N3=5231
Quoted 8 lines
Quoted 1 line
Note: I noticed <total pages> is not equal to the sum of the rest of
counters.
Quoted 2 lines
I might need to change the way get that counter, comments are welcomed.
Isn't it just because <total pages>(mem_cgroup_local_usage()) includes pages
which are not on any LRU, while other counters doesn't ?
Yes, i noticed that also and I am preparing for the next post :)
Quoted 89 lines
Quoted 7 lines
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 | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct
Quoted 7 lines
1 files changed, 109 insertions(+), 0 deletions(-)mm/memcontrol.c +0
-0@@ -1162,6 +1162,62 @@ 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 4 lines
mm/memcontrol.c +1
-0return MEM_CGROUP_ZSTAT (mz, lru); } +unsigned long mem_cgroup_node_nr_file_pages(struct mem_cgroup *memcg,int nid)
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 10 lines
mm/memcontrol.c +10
-0+{ +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; +} + +unsigned long mem_cgroup_node_nr_anon_pages(struct mem_cgroup *memcg,int nid)
Quoted 9 lines
mm/memcontrol.c +9
-0+{ +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; +} +mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
Quoted 10 lines
mm/memcontrol.c +10
-0+unsigned long mem_cgroup_node_nr_lru_pages (struct mem_cgroup *memcg, +int nid,bool file) +{ +if (file) +return mem_cgroup_node_nr_file_pages (memcg, nid); +else +return mem_cgroup_node_nr_anon_pages (memcg, nid); +} + +unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg, boolfile)
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, · line 1204
Quoted 10 lines
mm/memcontrol.c +10
-0+{ +u64 total =0 ; +int nid; + +for_each_node_state (nid,N_HIGH_MEMORY ) + total +=mem_cgroup_node_nr_lru_pages (memcg, nid, file); + +return total; +} +Can these functions defined as "static" ?
mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct · line 1205
Quoted 1 line
mm/memcontrol.c +1
-0+unsigned long mem_cgroup_node_nr_pages(struct mem_cgroup *memcg, intnid)
Quoted 5 lines
mm/memcontrol.c +5
-0+{ +int zid; +struct mem_cgroup_per_zone *mz; +enum lru_list l; +u64 total =0 ;mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, · line 1220
Quoted 10 lines
mm/memcontrol.c +10
-0+ +for (zid =0 ; zid <MAX_NR_ZONES ; zid++) { + mz =mem_cgroup_zoneinfo (memcg, nid, zid); +for_each_lru (l) + total +=MEM_CGROUP_ZSTAT (mz, l); + } + +return total; +} +ditto.
And I think this function can be implemented by usingmem_cgroup_get_zonestat_node().
Quoted 8 lines
for_each_lru(l) total += mem_cgroup_get_zonestat_node(memcg, nid, l);As KAMEZAWA-san posted a fix already,
mem_cgroup_get_zonestat_node()must be fixed first.Yes, I can include that in the patchset.
Thanks
--Ying
Quoted 98 lines
Thanks,
Daisuke Nishimura.mm/memcontrol.c unsigned long mem_cgroup_zone_nr_lru_pages(struct · line 1221
Quoted 1 line
mm/memcontrol.c +0
-0struct 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 +4104,41 @@ mem_cgroup_get_total_stat(struct mem_cgroup *mem,struct
mcs_total_stat*s)Quoted 29 lines
mm/memcontrol.c +26
-0mem_cgroup_get_local_stat (iter, s); } +static int mem_control_numa_stat_show (struct seq_file *m,void *arg) +{ +int nid; +unsigned long total_nr, file_nr, anon_nr; +unsigned long node_nr; +struct cgroup *cont = m->private; +struct mem_cgroup *mem_cont =mem_cgroup_from_cont (cont); + + total_nr =mem_cgroup_local_usage (mem_cont); +seq_printf (m,"total=%lu" , total_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_pages (mem_cont, nid); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + file_nr =mem_cgroup_nr_lru_pages (mem_cont,1 ); +seq_printf (m,"file=%lu" , file_nr); +for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid,1 ); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + + anon_nr =mem_cgroup_nr_lru_pages (mem_cont,0 ); +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 +9
-0+for_each_node_state (nid,N_HIGH_MEMORY ) { + node_nr =mem_cgroup_node_nr_lru_pages (mem_cont, nid,0 ); +seq_printf (m," N%d=%lu" , nid, node_nr); + } +seq_putc (m,'\n' ); + +return 0 ; +} + static int mem_control_stat_show(struct cgroup *cont, struct cftype*cft,
mm/memcontrol.c static int mem_cgroup_oom_control_write(struct
Quoted 3 lines
mm/memcontrol.c +0
-0struct cgroup_map_cb *cb) {@@ -4481,6 +4572,20 @@ static int mem_cgroup_oom_control_write(structcgroup *cgrp,
mm/memcontrol.c static int mem_cgroup_oom_control_write(struct cgroup *cgrp,
Quoted 4 lines
mm/memcontrol.c +1
-0return 0 ; } +static const struct file_operations
mem_control_numa_stat_file_operations= {mm/memcontrol.c static int mem_cgroup_oom_control_write(struct cgroup *cgrp,
Quoted 6 lines
mm/memcontrol.c +6
-0+ .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int mem_control_numa_stat_open(struct inode *unused, struct file*file)
Quoted 22 lines
mm/memcontrol.c +11
-1+{ +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); +} +static struct cftype mem_cgroup_files[] = { { .name ="usage_in_bytes" ,@@ -4544,6 +4649,10 @@ static struct cftype mem_cgroup_files[] = { .unregister_event = mem_cgroup_oom_unregister_event, .private = MEMFILE_PRIVATE(_OOM_TYPE, OOM_CONTROL), }, + { + .name = "numa_stat", + .open = mem_control_numa_stat_open, + }, };#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP --Quoted 2 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>