* [PATCH V2 0/2] Reduce reclaim from per-zone LRU in global kswapd @ 2011-03-28 23:51 Ying Han 2011-03-28 23:51 ` [PATCH V2 1/2] count the soft_limit reclaim in global background reclaim Ying Han 2011-03-28 23:51 ` [PATCH V2 2/2] add stats to monitor soft_limit reclaim Ying Han 0 siblings, 2 replies; 9+ messages in thread From: Ying Han @ 2011-03-28 23:51 UTC (permalink / raw) To: KOSAKI Motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel, Minchan Kim, Daisuke Nishimura, Andrew Morton Cc: linux-mm The global kswapd scans per-zone LRU and reclaims pages regardless of the cgroup. It breaks memory isolation since one cgroup can end up reclaiming pages from another cgroup. Instead we should rely on memcg-aware target reclaim including per-memcg kswapd and soft_limit hierarchical reclaim under memory pressure. In the global background reclaim, we do soft reclaim before scanning the per-zone LRU. However, the return value is ignored. This patch is the first step to skip shrink_zone() if soft_limit reclaim does enough work. This is part of the effort which tries to reduce reclaiming pages in global LRU in memcg. The per-memcg background reclaim patchset further enhances the per-cgroup targetting reclaim, which I should have V4 posted shortly. Try running multiple memory intensive workloads within seperate memcgs. Watch the counters of soft_steal in memory.stat. $ egrep 'steal|scan' /dev/cgroup/1/memory.stat soft_steal 259200 total_soft_steal 259200 Ying Han (2): count the soft_limit reclaim in global background reclaim add stats to monitor soft_limit reclaim Documentation/cgroups/memory.txt | 2 + include/linux/memcontrol.h | 11 ++++++++- include/linux/swap.h | 3 +- mm/memcontrol.c | 43 ++++++++++++++++++++++++++++++-------- mm/vmscan.c | 16 +++++++++++-- 5 files changed, 60 insertions(+), 15 deletions(-) -- 1.7.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V2 1/2] count the soft_limit reclaim in global background reclaim 2011-03-28 23:51 [PATCH V2 0/2] Reduce reclaim from per-zone LRU in global kswapd Ying Han @ 2011-03-28 23:51 ` Ying Han 2011-03-29 1:00 ` KAMEZAWA Hiroyuki 2011-03-29 1:29 ` KOSAKI Motohiro 2011-03-28 23:51 ` [PATCH V2 2/2] add stats to monitor soft_limit reclaim Ying Han 1 sibling, 2 replies; 9+ messages in thread From: Ying Han @ 2011-03-28 23:51 UTC (permalink / raw) To: KOSAKI Motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel, Minchan Kim, Daisuke Nishimura, Andrew Morton Cc: linux-mm In the global background reclaim, we do soft reclaim before scanning the per-zone LRU. However, the return value is ignored. We would like to skip shrink_zone() if soft_limit reclaim does enough work. Also, we need to make the memory pressure balanced across per-memcg zones, like the logic vm-core. This patch is the first step where we start with counting the nr_scanned and nr_reclaimed from soft_limit reclaim into the global scan_control. Change log v2...v1: 1. Not skipping the shrink_zone() but instead count the nr_scanned and nr_reclaimed in the global scan_control. 2. Removed the stats into the next patch. Signed-off-by: Ying Han <yinghan@google.com> --- include/linux/memcontrol.h | 6 ++++-- include/linux/swap.h | 3 ++- mm/memcontrol.c | 29 ++++++++++++++++++++--------- mm/vmscan.c | 16 +++++++++++++--- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 5a5ce70..01281ac 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -144,7 +144,8 @@ static inline void mem_cgroup_dec_page_stat(struct page *page, } unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, - gfp_t gfp_mask); + gfp_t gfp_mask, + unsigned long *total_scanned); u64 mem_cgroup_get_limit(struct mem_cgroup *mem); #ifdef CONFIG_TRANSPARENT_HUGEPAGE @@ -338,7 +339,8 @@ static inline void mem_cgroup_dec_page_stat(struct page *page, static inline unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, - gfp_t gfp_mask) + gfp_t gfp_mask, + unsigned long *total_scanned) { return 0; } diff --git a/include/linux/swap.h b/include/linux/swap.h index ed6ebe6..3c6a9cd 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -257,7 +257,8 @@ extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, gfp_t gfp_mask, bool noswap, unsigned int swappiness, - struct zone *zone); + struct zone *zone, + unsigned long *nr_scanned); extern int __isolate_lru_page(struct page *page, int mode, int file); extern unsigned long shrink_all_memory(unsigned long nr_pages); extern int vm_swappiness; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4407dd0..67fff28 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1433,7 +1433,8 @@ mem_cgroup_select_victim(struct mem_cgroup *root_mem) static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, struct zone *zone, gfp_t gfp_mask, - unsigned long reclaim_options) + unsigned long reclaim_options, + unsigned long *total_scanned) { struct mem_cgroup *victim; int ret, total = 0; @@ -1442,6 +1443,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, bool shrink = reclaim_options & MEM_CGROUP_RECLAIM_SHRINK; bool check_soft = reclaim_options & MEM_CGROUP_RECLAIM_SOFT; unsigned long excess; + unsigned long nr_scanned; excess = res_counter_soft_limit_excess(&root_mem->res) >> PAGE_SHIFT; @@ -1484,10 +1486,12 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, continue; } /* we use swappiness of local cgroup */ - if (check_soft) + if (check_soft) { ret = mem_cgroup_shrink_node_zone(victim, gfp_mask, - noswap, get_swappiness(victim), zone); - else + noswap, get_swappiness(victim), zone, + &nr_scanned); + *total_scanned += nr_scanned; + } else ret = try_to_free_mem_cgroup_pages(victim, gfp_mask, noswap, get_swappiness(victim)); css_put(&victim->css); @@ -1928,7 +1932,7 @@ static int mem_cgroup_do_charge(struct mem_cgroup *mem, gfp_t gfp_mask, return CHARGE_WOULDBLOCK; ret = mem_cgroup_hierarchical_reclaim(mem_over_limit, NULL, - gfp_mask, flags); + gfp_mask, flags, NULL); if (mem_cgroup_margin(mem_over_limit) >= nr_pages) return CHARGE_RETRY; /* @@ -3211,7 +3215,8 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg, break; mem_cgroup_hierarchical_reclaim(memcg, NULL, GFP_KERNEL, - MEM_CGROUP_RECLAIM_SHRINK); + MEM_CGROUP_RECLAIM_SHRINK, + NULL); curusage = res_counter_read_u64(&memcg->res, RES_USAGE); /* Usage is reduced ? */ if (curusage >= oldusage) @@ -3271,7 +3276,8 @@ static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg, mem_cgroup_hierarchical_reclaim(memcg, NULL, GFP_KERNEL, MEM_CGROUP_RECLAIM_NOSWAP | - MEM_CGROUP_RECLAIM_SHRINK); + MEM_CGROUP_RECLAIM_SHRINK, + NULL); curusage = res_counter_read_u64(&memcg->memsw, RES_USAGE); /* Usage is reduced ? */ if (curusage >= oldusage) @@ -3285,7 +3291,8 @@ static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg, } unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, - gfp_t gfp_mask) + gfp_t gfp_mask, + unsigned long *total_scanned) { unsigned long nr_reclaimed = 0; struct mem_cgroup_per_zone *mz, *next_mz = NULL; @@ -3293,6 +3300,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, int loop = 0; struct mem_cgroup_tree_per_zone *mctz; unsigned long long excess; + unsigned long nr_scanned; if (order > 0) return 0; @@ -3311,10 +3319,13 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, if (!mz) break; + nr_scanned = 0; reclaimed = mem_cgroup_hierarchical_reclaim(mz->mem, zone, gfp_mask, - MEM_CGROUP_RECLAIM_SOFT); + MEM_CGROUP_RECLAIM_SOFT, + &nr_scanned); nr_reclaimed += reclaimed; + *total_scanned += nr_scanned; spin_lock(&mctz->lock); /* diff --git a/mm/vmscan.c b/mm/vmscan.c index 060e4c1..3755ad5 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2147,9 +2147,11 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, gfp_t gfp_mask, bool noswap, unsigned int swappiness, - struct zone *zone) + struct zone *zone, + unsigned long *nr_scanned) { struct scan_control sc = { + .nr_scanned = 0, .nr_to_reclaim = SWAP_CLUSTER_MAX, .may_writepage = !laptop_mode, .may_unmap = 1, @@ -2158,6 +2160,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, .order = 0, .mem_cgroup = mem, }; + sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK); @@ -2176,6 +2179,7 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed); + *nr_scanned = sc.nr_scanned; return sc.nr_reclaimed; } @@ -2320,6 +2324,8 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */ unsigned long total_scanned; struct reclaim_state *reclaim_state = current->reclaim_state; + unsigned long nr_soft_reclaimed; + unsigned long nr_soft_scanned; struct scan_control sc = { .gfp_mask = GFP_KERNEL, .may_unmap = 1, @@ -2409,11 +2415,15 @@ loop_again: sc.nr_scanned = 0; + nr_soft_scanned = 0; /* * Call soft limit reclaim before calling shrink_zone. - * For now we ignore the return value */ - mem_cgroup_soft_limit_reclaim(zone, order, sc.gfp_mask); + nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone, + order, sc.gfp_mask, + &nr_soft_scanned); + sc.nr_reclaimed += nr_soft_reclaimed; + total_scanned += nr_soft_scanned; /* * We put equal pressure on every zone, unless -- 1.7.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH V2 1/2] count the soft_limit reclaim in global background reclaim 2011-03-28 23:51 ` [PATCH V2 1/2] count the soft_limit reclaim in global background reclaim Ying Han @ 2011-03-29 1:00 ` KAMEZAWA Hiroyuki 2011-03-29 1:29 ` KOSAKI Motohiro 1 sibling, 0 replies; 9+ messages in thread From: KAMEZAWA Hiroyuki @ 2011-03-29 1:00 UTC (permalink / raw) To: Ying Han Cc: KOSAKI Motohiro, Mel Gorman, Rik van Riel, Minchan Kim, Daisuke Nishimura, Andrew Morton, linux-mm On Mon, 28 Mar 2011 16:51:09 -0700 Ying Han <yinghan@google.com> wrote: > In the global background reclaim, we do soft reclaim before scanning the > per-zone LRU. However, the return value is ignored. > > We would like to skip shrink_zone() if soft_limit reclaim does enough work. > Also, we need to make the memory pressure balanced across per-memcg zones, > like the logic vm-core. This patch is the first step where we start with > counting the nr_scanned and nr_reclaimed from soft_limit reclaim into the > global scan_control. > > Change log v2...v1: > 1. Not skipping the shrink_zone() but instead count the nr_scanned and > nr_reclaimed in the global scan_control. > 2. Removed the stats into the next patch. > > Signed-off-by: Ying Han <yinghan@google.com> seems better. Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujtisu.com> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH V2 1/2] count the soft_limit reclaim in global background reclaim 2011-03-28 23:51 ` [PATCH V2 1/2] count the soft_limit reclaim in global background reclaim Ying Han 2011-03-29 1:00 ` KAMEZAWA Hiroyuki @ 2011-03-29 1:29 ` KOSAKI Motohiro 1 sibling, 0 replies; 9+ messages in thread From: KOSAKI Motohiro @ 2011-03-29 1:29 UTC (permalink / raw) To: Ying Han Cc: kosaki.motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel, Minchan Kim, Daisuke Nishimura, Andrew Morton, linux-mm > @@ -2320,6 +2324,8 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, > int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */ > unsigned long total_scanned; > struct reclaim_state *reclaim_state = current->reclaim_state; > + unsigned long nr_soft_reclaimed; > + unsigned long nr_soft_scanned; > struct scan_control sc = { > .gfp_mask = GFP_KERNEL, > .may_unmap = 1, > @@ -2409,11 +2415,15 @@ loop_again: > > sc.nr_scanned = 0; > > + nr_soft_scanned = 0; > /* > * Call soft limit reclaim before calling shrink_zone. > - * For now we ignore the return value > */ > - mem_cgroup_soft_limit_reclaim(zone, order, sc.gfp_mask); > + nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone, > + order, sc.gfp_mask, > + &nr_soft_scanned); > + sc.nr_reclaimed += nr_soft_reclaimed; > + total_scanned += nr_soft_scanned; > > /* > * We put equal pressure on every zone, unless Thank you. Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V2 2/2] add stats to monitor soft_limit reclaim 2011-03-28 23:51 [PATCH V2 0/2] Reduce reclaim from per-zone LRU in global kswapd Ying Han 2011-03-28 23:51 ` [PATCH V2 1/2] count the soft_limit reclaim in global background reclaim Ying Han @ 2011-03-28 23:51 ` Ying Han 2011-03-29 1:22 ` KAMEZAWA Hiroyuki 2011-03-29 2:32 ` Daisuke Nishimura 1 sibling, 2 replies; 9+ messages in thread From: Ying Han @ 2011-03-28 23:51 UTC (permalink / raw) To: KOSAKI Motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel, Minchan Kim, Daisuke Nishimura, Andrew Morton Cc: linux-mm The stat is added: /dev/cgroup/*/memory.stat soft_steal: - # of pages reclaimed from soft_limit hierarchical reclaim total_soft_steal: - # sum of all children's "soft_steal" Change log v2...v1 1. removed the counting on number of skips on shrink_zone. This is due to the change on the previous patch. Signed-off-by: Ying Han <yinghan@google.com> --- Documentation/cgroups/memory.txt | 2 ++ include/linux/memcontrol.h | 5 +++++ mm/memcontrol.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index b6ed61c..dcda6c5 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt @@ -385,6 +385,7 @@ mapped_file - # of bytes of mapped file (includes tmpfs/shmem) pgpgin - # of pages paged in (equivalent to # of charging events). pgpgout - # of pages paged out (equivalent to # of uncharging events). swap - # of bytes of swap usage +soft_steal - # of pages reclaimed from global hierarchical reclaim inactive_anon - # of bytes of anonymous memory and swap cache memory on LRU list. active_anon - # of bytes of anonymous and swap cache memory on active @@ -406,6 +407,7 @@ total_mapped_file - sum of all children's "cache" total_pgpgin - sum of all children's "pgpgin" total_pgpgout - sum of all children's "pgpgout" total_swap - sum of all children's "swap" +total_soft_steal - sum of all children's "soft_steal" total_inactive_anon - sum of all children's "inactive_anon" total_active_anon - sum of all children's "active_anon" total_inactive_file - sum of all children's "inactive_file" diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 01281ac..151ab40 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -115,6 +115,7 @@ struct zone_reclaim_stat* mem_cgroup_get_reclaim_stat_from_page(struct page *page); extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p); +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val); #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP extern int do_swap_account; @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head, { } +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg, + int val) +{ +} #endif /* CONFIG_CGROUP_MEM_CONT */ #if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 67fff28..5e4aa41 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -94,6 +94,8 @@ enum mem_cgroup_events_index { MEM_CGROUP_EVENTS_PGPGIN, /* # of pages paged in */ MEM_CGROUP_EVENTS_PGPGOUT, /* # of pages paged out */ MEM_CGROUP_EVENTS_COUNT, /* # of pages paged in/out */ + MEM_CGROUP_EVENTS_SOFT_STEAL, /* # of pages reclaimed from */ + /* oft reclaim */ MEM_CGROUP_EVENTS_NSTATS, }; /* @@ -624,6 +626,11 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, preempt_enable(); } +void mem_cgroup_soft_steal(struct mem_cgroup *mem, int val) +{ + this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_STEAL], val); +} + static unsigned long mem_cgroup_get_local_zonestat(struct mem_cgroup *mem, enum lru_list idx) { @@ -3326,6 +3333,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, &nr_scanned); nr_reclaimed += reclaimed; *total_scanned += nr_scanned; + + mem_cgroup_soft_steal(mz->mem, reclaimed); + spin_lock(&mctz->lock); /* @@ -3783,6 +3793,7 @@ enum { MCS_PGPGIN, MCS_PGPGOUT, MCS_SWAP, + MCS_SOFT_STEAL, MCS_INACTIVE_ANON, MCS_ACTIVE_ANON, MCS_INACTIVE_FILE, @@ -3805,6 +3816,7 @@ struct { {"pgpgin", "total_pgpgin"}, {"pgpgout", "total_pgpgout"}, {"swap", "total_swap"}, + {"soft_steal", "total_soft_steal"}, {"inactive_anon", "total_inactive_anon"}, {"active_anon", "total_active_anon"}, {"inactive_file", "total_inactive_file"}, @@ -3833,6 +3845,8 @@ mem_cgroup_get_local_stat(struct mem_cgroup *mem, struct mcs_total_stat *s) val = mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_SWAPOUT); s->stat[MCS_SWAP] += val * PAGE_SIZE; } + val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_STEAL); + s->stat[MCS_SOFT_STEAL] += val; /* per zone stat */ val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON); -- 1.7.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH V2 2/2] add stats to monitor soft_limit reclaim 2011-03-28 23:51 ` [PATCH V2 2/2] add stats to monitor soft_limit reclaim Ying Han @ 2011-03-29 1:22 ` KAMEZAWA Hiroyuki 2011-03-29 4:38 ` Ying Han 2011-03-29 2:32 ` Daisuke Nishimura 1 sibling, 1 reply; 9+ messages in thread From: KAMEZAWA Hiroyuki @ 2011-03-29 1:22 UTC (permalink / raw) To: Ying Han Cc: KOSAKI Motohiro, Mel Gorman, Rik van Riel, Minchan Kim, Daisuke Nishimura, Andrew Morton, linux-mm On Mon, 28 Mar 2011 16:51:10 -0700 Ying Han <yinghan@google.com> wrote: > The stat is added: > > /dev/cgroup/*/memory.stat > soft_steal: - # of pages reclaimed from soft_limit hierarchical reclaim > total_soft_steal: - # sum of all children's "soft_steal" > > Change log v2...v1 > 1. removed the counting on number of skips on shrink_zone. This is due to the > change on the previous patch. > > Signed-off-by: Ying Han <yinghan@google.com> Hmm... > --- > Documentation/cgroups/memory.txt | 2 ++ > include/linux/memcontrol.h | 5 +++++ > mm/memcontrol.c | 14 ++++++++++++++ > 3 files changed, 21 insertions(+), 0 deletions(-) > > diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt > index b6ed61c..dcda6c5 100644 > --- a/Documentation/cgroups/memory.txt > +++ b/Documentation/cgroups/memory.txt > @@ -385,6 +385,7 @@ mapped_file - # of bytes of mapped file (includes tmpfs/shmem) > pgpgin - # of pages paged in (equivalent to # of charging events). > pgpgout - # of pages paged out (equivalent to # of uncharging events). > swap - # of bytes of swap usage > +soft_steal - # of pages reclaimed from global hierarchical reclaim > inactive_anon - # of bytes of anonymous memory and swap cache memory on > LRU list. > active_anon - # of bytes of anonymous and swap cache memory on active > @@ -406,6 +407,7 @@ total_mapped_file - sum of all children's "cache" > total_pgpgin - sum of all children's "pgpgin" > total_pgpgout - sum of all children's "pgpgout" > total_swap - sum of all children's "swap" > +total_soft_steal - sum of all children's "soft_steal" > total_inactive_anon - sum of all children's "inactive_anon" > total_active_anon - sum of all children's "active_anon" > total_inactive_file - sum of all children's "inactive_file" > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 01281ac..151ab40 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -115,6 +115,7 @@ struct zone_reclaim_stat* > mem_cgroup_get_reclaim_stat_from_page(struct page *page); > extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, > struct task_struct *p); > +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val); > > #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP > extern int do_swap_account; > @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head, > { > } > > +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg, > + int val) > +{ > +} > #endif /* CONFIG_CGROUP_MEM_CONT */ > > #if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM) > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 67fff28..5e4aa41 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -94,6 +94,8 @@ enum mem_cgroup_events_index { > MEM_CGROUP_EVENTS_PGPGIN, /* # of pages paged in */ > MEM_CGROUP_EVENTS_PGPGOUT, /* # of pages paged out */ > MEM_CGROUP_EVENTS_COUNT, /* # of pages paged in/out */ > + MEM_CGROUP_EVENTS_SOFT_STEAL, /* # of pages reclaimed from */ > + /* oft reclaim */ > MEM_CGROUP_EVENTS_NSTATS, > }; > /* > @@ -624,6 +626,11 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, > preempt_enable(); > } > > +void mem_cgroup_soft_steal(struct mem_cgroup *mem, int val) > +{ > + this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_STEAL], val); > +} > + > static unsigned long mem_cgroup_get_local_zonestat(struct mem_cgroup *mem, > enum lru_list idx) > { > @@ -3326,6 +3333,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, > &nr_scanned); > nr_reclaimed += reclaimed; > *total_scanned += nr_scanned; > + > + mem_cgroup_soft_steal(mz->mem, reclaimed); > + Here, you add "the number of reclaimed pages from the all descendants under me". Could you move this to mem_cgroup_hierarchical_reclaim() ? Then, you can report the correct stats even with hierarchy enabled. Even if the value is recorded into hierarchy, total_steal will show total. BTW, soft_scan and soft_total_scan aren't necessary ? Thanks, -Kame -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH V2 2/2] add stats to monitor soft_limit reclaim 2011-03-29 1:22 ` KAMEZAWA Hiroyuki @ 2011-03-29 4:38 ` Ying Han 0 siblings, 0 replies; 9+ messages in thread From: Ying Han @ 2011-03-29 4:38 UTC (permalink / raw) To: KAMEZAWA Hiroyuki Cc: KOSAKI Motohiro, Mel Gorman, Rik van Riel, Minchan Kim, Daisuke Nishimura, Andrew Morton, linux-mm On Mon, Mar 28, 2011 at 6:22 PM, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote: > On Mon, 28 Mar 2011 16:51:10 -0700 > Ying Han <yinghan@google.com> wrote: > >> The stat is added: >> >> /dev/cgroup/*/memory.stat >> soft_steal: - # of pages reclaimed from soft_limit hierarchical reclaim >> total_soft_steal: - # sum of all children's "soft_steal" >> >> Change log v2...v1 >> 1. removed the counting on number of skips on shrink_zone. This is due to the >> change on the previous patch. >> >> Signed-off-by: Ying Han <yinghan@google.com> > > Hmm... > > >> --- >> Documentation/cgroups/memory.txt | 2 ++ >> include/linux/memcontrol.h | 5 +++++ >> mm/memcontrol.c | 14 ++++++++++++++ >> 3 files changed, 21 insertions(+), 0 deletions(-) >> >> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt >> index b6ed61c..dcda6c5 100644 >> --- a/Documentation/cgroups/memory.txt >> +++ b/Documentation/cgroups/memory.txt >> @@ -385,6 +385,7 @@ mapped_file - # of bytes of mapped file (includes tmpfs/shmem) >> pgpgin - # of pages paged in (equivalent to # of charging events). >> pgpgout - # of pages paged out (equivalent to # of uncharging events). >> swap - # of bytes of swap usage >> +soft_steal - # of pages reclaimed from global hierarchical reclaim >> inactive_anon - # of bytes of anonymous memory and swap cache memory on >> LRU list. >> active_anon - # of bytes of anonymous and swap cache memory on active >> @@ -406,6 +407,7 @@ total_mapped_file - sum of all children's "cache" >> total_pgpgin - sum of all children's "pgpgin" >> total_pgpgout - sum of all children's "pgpgout" >> total_swap - sum of all children's "swap" >> +total_soft_steal - sum of all children's "soft_steal" >> total_inactive_anon - sum of all children's "inactive_anon" >> total_active_anon - sum of all children's "active_anon" >> total_inactive_file - sum of all children's "inactive_file" >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index 01281ac..151ab40 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -115,6 +115,7 @@ struct zone_reclaim_stat* >> mem_cgroup_get_reclaim_stat_from_page(struct page *page); >> extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, >> struct task_struct *p); >> +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val); >> >> #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP >> extern int do_swap_account; >> @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head, >> { >> } >> >> +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg, >> + int val) >> +{ >> +} >> #endif /* CONFIG_CGROUP_MEM_CONT */ >> >> #if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM) >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >> index 67fff28..5e4aa41 100644 >> --- a/mm/memcontrol.c >> +++ b/mm/memcontrol.c >> @@ -94,6 +94,8 @@ enum mem_cgroup_events_index { >> MEM_CGROUP_EVENTS_PGPGIN, /* # of pages paged in */ >> MEM_CGROUP_EVENTS_PGPGOUT, /* # of pages paged out */ >> MEM_CGROUP_EVENTS_COUNT, /* # of pages paged in/out */ >> + MEM_CGROUP_EVENTS_SOFT_STEAL, /* # of pages reclaimed from */ >> + /* oft reclaim */ >> MEM_CGROUP_EVENTS_NSTATS, >> }; >> /* >> @@ -624,6 +626,11 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, >> preempt_enable(); >> } >> >> +void mem_cgroup_soft_steal(struct mem_cgroup *mem, int val) >> +{ >> + this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_STEAL], val); >> +} >> + >> static unsigned long mem_cgroup_get_local_zonestat(struct mem_cgroup *mem, >> enum lru_list idx) >> { >> @@ -3326,6 +3333,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, >> &nr_scanned); >> nr_reclaimed += reclaimed; >> *total_scanned += nr_scanned; >> + >> + mem_cgroup_soft_steal(mz->mem, reclaimed); >> + > > Here, you add "the number of reclaimed pages from the all descendants under me". > Could you move this to mem_cgroup_hierarchical_reclaim() ? Then, you can report > the correct stats even with hierarchy enabled. > > Even if the value is recorded into hierarchy, total_steal will show total. good point. I will make that change. > > BTW, soft_scan and soft_total_scan aren't necessary ? Hmm, i can look into that. --Ying > > Thanks, > -Kame > > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH V2 2/2] add stats to monitor soft_limit reclaim 2011-03-28 23:51 ` [PATCH V2 2/2] add stats to monitor soft_limit reclaim Ying Han 2011-03-29 1:22 ` KAMEZAWA Hiroyuki @ 2011-03-29 2:32 ` Daisuke Nishimura 2011-03-29 4:55 ` Ying Han 1 sibling, 1 reply; 9+ messages in thread From: Daisuke Nishimura @ 2011-03-29 2:32 UTC (permalink / raw) To: Ying Han Cc: KOSAKI Motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel, Minchan Kim, Andrew Morton, linux-mm, Daisuke Nishimura On Mon, 28 Mar 2011 16:51:10 -0700 Ying Han <yinghan@google.com> wrote: > The stat is added: > > /dev/cgroup/*/memory.stat > soft_steal: - # of pages reclaimed from soft_limit hierarchical reclaim > total_soft_steal: - # sum of all children's "soft_steal" > > Change log v2...v1 > 1. removed the counting on number of skips on shrink_zone. This is due to the > change on the previous patch. > > Signed-off-by: Ying Han <yinghan@google.com> > --- > Documentation/cgroups/memory.txt | 2 ++ > include/linux/memcontrol.h | 5 +++++ > mm/memcontrol.c | 14 ++++++++++++++ > 3 files changed, 21 insertions(+), 0 deletions(-) > > diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt > index b6ed61c..dcda6c5 100644 > --- a/Documentation/cgroups/memory.txt > +++ b/Documentation/cgroups/memory.txt > @@ -385,6 +385,7 @@ mapped_file - # of bytes of mapped file (includes tmpfs/shmem) > pgpgin - # of pages paged in (equivalent to # of charging events). > pgpgout - # of pages paged out (equivalent to # of uncharging events). > swap - # of bytes of swap usage > +soft_steal - # of pages reclaimed from global hierarchical reclaim > inactive_anon - # of bytes of anonymous memory and swap cache memory on > LRU list. > active_anon - # of bytes of anonymous and swap cache memory on active > @@ -406,6 +407,7 @@ total_mapped_file - sum of all children's "cache" > total_pgpgin - sum of all children's "pgpgin" > total_pgpgout - sum of all children's "pgpgout" > total_swap - sum of all children's "swap" > +total_soft_steal - sum of all children's "soft_steal" > total_inactive_anon - sum of all children's "inactive_anon" > total_active_anon - sum of all children's "active_anon" > total_inactive_file - sum of all children's "inactive_file" > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 01281ac..151ab40 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -115,6 +115,7 @@ struct zone_reclaim_stat* > mem_cgroup_get_reclaim_stat_from_page(struct page *page); > extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, > struct task_struct *p); > +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val); > > #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP > extern int do_swap_account; > @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head, > { > } > > +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg, > + int val) > +{ > +} > #endif /* CONFIG_CGROUP_MEM_CONT */ > Do you use this function outside of memcontrol.c in future, right ? I'm asking just for clarification, and I'm sorry if I miss some past discussions. Thanks, Daisuke Nishimura. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH V2 2/2] add stats to monitor soft_limit reclaim 2011-03-29 2:32 ` Daisuke Nishimura @ 2011-03-29 4:55 ` Ying Han 0 siblings, 0 replies; 9+ messages in thread From: Ying Han @ 2011-03-29 4:55 UTC (permalink / raw) To: Daisuke Nishimura Cc: KOSAKI Motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel, Minchan Kim, Andrew Morton, linux-mm On Mon, Mar 28, 2011 at 7:32 PM, Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote: > On Mon, 28 Mar 2011 16:51:10 -0700 > Ying Han <yinghan@google.com> wrote: > >> The stat is added: >> >> /dev/cgroup/*/memory.stat >> soft_steal: - # of pages reclaimed from soft_limit hierarchical reclaim >> total_soft_steal: - # sum of all children's "soft_steal" >> >> Change log v2...v1 >> 1. removed the counting on number of skips on shrink_zone. This is due to the >> change on the previous patch. >> >> Signed-off-by: Ying Han <yinghan@google.com> >> --- >> Documentation/cgroups/memory.txt | 2 ++ >> include/linux/memcontrol.h | 5 +++++ >> mm/memcontrol.c | 14 ++++++++++++++ >> 3 files changed, 21 insertions(+), 0 deletions(-) >> >> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt >> index b6ed61c..dcda6c5 100644 >> --- a/Documentation/cgroups/memory.txt >> +++ b/Documentation/cgroups/memory.txt >> @@ -385,6 +385,7 @@ mapped_file - # of bytes of mapped file (includes tmpfs/shmem) >> pgpgin - # of pages paged in (equivalent to # of charging events). >> pgpgout - # of pages paged out (equivalent to # of uncharging events). >> swap - # of bytes of swap usage >> +soft_steal - # of pages reclaimed from global hierarchical reclaim >> inactive_anon - # of bytes of anonymous memory and swap cache memory on >> LRU list. >> active_anon - # of bytes of anonymous and swap cache memory on active >> @@ -406,6 +407,7 @@ total_mapped_file - sum of all children's "cache" >> total_pgpgin - sum of all children's "pgpgin" >> total_pgpgout - sum of all children's "pgpgout" >> total_swap - sum of all children's "swap" >> +total_soft_steal - sum of all children's "soft_steal" >> total_inactive_anon - sum of all children's "inactive_anon" >> total_active_anon - sum of all children's "active_anon" >> total_inactive_file - sum of all children's "inactive_file" >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index 01281ac..151ab40 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -115,6 +115,7 @@ struct zone_reclaim_stat* >> mem_cgroup_get_reclaim_stat_from_page(struct page *page); >> extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, >> struct task_struct *p); >> +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val); >> >> #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP >> extern int do_swap_account; >> @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head, >> { >> } >> >> +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg, >> + int val) >> +{ >> +} >> #endif /* CONFIG_CGROUP_MEM_CONT */ >> > Do you use this function outside of memcontrol.c in future, right ? > I'm asking just for clarification, and I'm sorry if I miss some past discussions. No, you didn't miss the discussion. That is a reasonable change. thanks --Ying > > Thanks, > Daisuke Nishimura. > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-03-29 4:55 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-03-28 23:51 [PATCH V2 0/2] Reduce reclaim from per-zone LRU in global kswapd Ying Han 2011-03-28 23:51 ` [PATCH V2 1/2] count the soft_limit reclaim in global background reclaim Ying Han 2011-03-29 1:00 ` KAMEZAWA Hiroyuki 2011-03-29 1:29 ` KOSAKI Motohiro 2011-03-28 23:51 ` [PATCH V2 2/2] add stats to monitor soft_limit reclaim Ying Han 2011-03-29 1:22 ` KAMEZAWA Hiroyuki 2011-03-29 4:38 ` Ying Han 2011-03-29 2:32 ` Daisuke Nishimura 2011-03-29 4:55 ` Ying Han
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).