memcg: rename mem_cgroup_zone_nr_pages() to mem_cgroup_zone_nr_lru_pages()
Subsystems (4)
PATCH v4 1/3 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
--- 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 v4 2/3 memcg: fix a routine for counting pages in node
The value for counter base should be initialized. If not, this returns wrong value.
This is a bugfix for memcg-reclaim-memory-from-nodes-in-round-robin-order.patch in mmotm tree.
--- mm/memcontrol.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
mm/memcontrol.c +1 -1
@@ -679,7 +679,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++) {
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 v4 3/3 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> ... 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
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 | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 147 insertions(+), 0 deletions(-)
mm/memcontrol.c +147 -0
@@ -1162,6 +1162,91 @@ unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,return MEM_CGROUP_ZSTAT (mz, lru); } +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; +} +struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat (struct mem_cgroup *memcg,struct zone *zone) {
@@ -4048,6 +4133,49 @@ 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, 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 ; +} +static int mem_control_stat_show (struct cgroup *cont,struct cftype *cft,struct cgroup_map_cb *cb) {
@@ -4058,6 +4186,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 +4610,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 +4687,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>
Re: [PATCH V4 3/3] memcg: add memory.numastat api for numa statistics
Quoted 33 lines · On Thu, 19 May 2011 20:24:51 -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> ... 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=2941change 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.
Quoted 4 lines
change v2..v1:
1. add also the file and anon pages on per-node distribution.Signed-off-by Ying Han <[email protected]>
Seems fine. Thank you for patient work.
--
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 V4 3/3] memcg: add memory.numastat api for numa statistics
Quoted 40 lines · KAMEZAWA Hiroyuki
Quoted 5 lines · On Thu, 19 May 2011 20:24:51 -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 16 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=2941Quoted 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 2 lines
after.
Quoted 9 lines
Quoted 4 lines
change v2..v1:
1. add also the file and anon pages on per-node distribution.Signed-off-by Ying Han <[email protected]>Seems fine. Thank you for patient work.
Sure. thank you for reviewing it.
Thanks
--Ying
Re: [PATCH V4 3/3] memcg: add memory.numastat api for numa statistics
In reply to Ying HanQuoted 33 lines · On Thu, 19 May 2011 20:24:51 -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> ... 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=2941change 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.
Quoted 4 lines
change v2..v1:
1. add also the file and anon pages on per-node distribution.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>
Andrew Morton
maintainerRe: [PATCH V4 3/3] memcg: add memory.numastat api for numa statistics
In reply to Ying HanQuoted 15 lines · On Thu, 19 May 2011 20:24:51 -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> ... unevictable=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ...
Quoted 8 lines
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
Does it make sense to add all this code for non-NUMA kernels?
The patch adds a kilobyte of pretty useless text to uniprocessor kernels.
--
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 V4 3/3] memcg: add memory.numastat api for numa statistics
Quoted 29 lines · Andrew Morton
Quoted 5 lines · On Thu, 19 May 2011 20:24:51 -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 7 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> ...
Quoted 8 lines
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
Quoted 4 lines
Does it make sense to add all this code for non-NUMA kernels?
The patch adds a kilobyte of pretty useless text to uniprocessor kernels.
Thanks Andrew. I will upload another patch adding "#ifdef CONFIG_NUMA" on the API
Thanks
--Ying