memcg softlimit reclaim rework
Subsystems (5)
cover memcg softlimit reclaim rework
The "soft_limit" was introduced in memcg to support over-committing the memory resource on the host. Each cgroup configures its "hard_limit" where it will be throttled or OOM killed by going over the limit. However, the cgroup can go above the "soft_limit" as long as there is no system-wide memory contention. So, the "soft_limit" is the kernel mechanism for re-distributng system spare memory among cgroups.
This patch reworks the softlimit reclaim by hooking it into the new global reclaim scheme. So the global reclaim path including direct reclaim and background reclaim will respect the memcg softlimit. At the same time, per-memcg reclaim will by default scanning all the memcgs under the hierarchy.
On a 64G host, creates 12 * 256M (limit_in_bytes) memcgs where each reads from a 512M ramdisk. At the same time, sets the softlimit to last 6 memcgs. Under global memory pressure, only the ones (first 6 memcgs) above softlimit got scanned and reclaimed.
$ for ((i=0; i<12; i++)); do cat /path/$i/memory.limit_in_bytes; done 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912
$ for ((i=0; i<12; i++)); do cat /path/$i/memory.soft_limit_in_bytes; done 0 0 0 0 0 0 536870912 536870912 536870912 536870912 536870912 536870912
$ for ((i=0; i<12; i++)); do cat /path/$i/memory.vmscan_stat; done total_scanned_file_pages_by_system_under_hierarchy 1992169 total_scanned_file_pages_by_system_under_hierarchy 2065410 total_scanned_file_pages_by_system_under_hierarchy 2056609 total_scanned_file_pages_by_system_under_hierarchy 1974422 total_scanned_file_pages_by_system_under_hierarchy 1835338 total_scanned_file_pages_by_system_under_hierarchy 1729919 total_scanned_file_pages_by_system_under_hierarchy 0 total_scanned_file_pages_by_system_under_hierarchy 0 total_scanned_file_pages_by_system_under_hierarchy 0 total_scanned_file_pages_by_system_under_hierarchy 0 total_scanned_file_pages_by_system_under_hierarchy 0 total_scanned_file_pages_by_system_under_hierarchy 0
Note:
1.The vmscan_stat API was reverted upstream, and I am not asking for inclusion here. The only reason to have it here is to demonstrate the result of the softlimit reclaim patchset.
2.The patch is based on next-20111201
Ying Han (3):
memcg: rework softlimit reclaim
memcg: revert current soft limit reclaim implementation
memcg: track reclaim stats in memory.vmscan_stat
include/linux/memcontrol.h | 36 ++- include/linux/swap.h | 4 - kernel/res_counter.c | 1 - mm/memcontrol.c | 541 +++++++++++++------------------------------- mm/vmscan.c | 116 ++++------ 5 files changed, 233 insertions(+), 465 deletions(-)
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/3 memcg: rework softlimit reclaim
Under the shrink_zone, we examine whether or not to reclaim from a memcg based on its softlimit. We skip scanning the memcg for the first 3 priority. This is to balance between isolation and efficiency. we don't want to halt the system by skipping memcgs with low-hanging fruits forever.
Another change is to set soft_limit_in_bytes to 0 by default. This is needed for both functional and performance:
1. If soft_limit are all set to MAX, it wastes first three periority iterations without scanning anything.
2. By default every memcg is eligibal for softlimit reclaim, and we can also set the value to MAX for special memcg which is immune to soft limit reclaim.
--- include/linux/memcontrol.h | 7 ++++ kernel/res_counter.c | 1 - mm/memcontrol.c | 8 +++++ mm/vmscan.c | 67 ++++++++++++++++++++++++++----------------- 4 files changed, 55 insertions(+), 28 deletions(-)
include/linux/memcontrol.h +7 -0
@@ -107,6 +107,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *, struct mem_cgroup_reclaim_cookie *);void mem_cgroup_iter_break (struct mem_cgroup *,struct mem_cgroup *); +bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *); +/* * For memory reclaim. */
@@ -293,6 +295,11 @@ static inline void mem_cgroup_iter_break(struct mem_cgroup *root, { } +static inline bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *mem) +{ +return true; +} +static inline int mem_cgroup_get_reclaim_priority (struct mem_cgroup *memcg) {return 0 ;
kernel/res_counter.c +0 -1
@@ -18,7 +18,6 @@ void res_counter_init(struct res_counter *counter, struct res_counter *parent) {spin_lock_init (&counter->lock); counter->limit =RESOURCE_MAX ; - counter->soft_limit =RESOURCE_MAX ; counter->parent = parent; }
mm/memcontrol.c +8 -0
@@ -926,6 +926,14 @@ out: }EXPORT_SYMBOL (mem_cgroup_count_vm_event); +bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *mem) +{ +if (mem_cgroup_disabled () ||mem_cgroup_is_root (mem)) +return true; + +return res_counter_soft_limit_excess (&mem->res) >0 ; +} +/** * mem_cgroup_zone_lruvec - get the lru list vector for a zone and memcg * @zone: zone of the wanted lruvec
mm/vmscan.c +40 -27
103 lines not on this page · raw message
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 1/3] memcg: rework softlimit reclaim
Quoted 5 lines · On Tue, 6 Dec 2011 15:59:57 -0800 Ying Han <[email protected]> wrote:
Under the
shrink_zone, we examine whether or not to reclaim from a memcg based on its softlimit. We skip scanning the memcg for the first 3 priority. This is to balance between isolation and efficiency. we don't want to halt the system by skipping memcgs with low-hanging fruits forever.
Quoted 9 lines
Another change is to set
soft_limit_in_bytesto 0 by default. This is needed for both functional and performance:1. If
soft_limitare all set to MAX, it wastes first three periority iterations without scanning anything.2. By default every memcg is eligibal for softlimit reclaim, and we can also set the value to MAX for special memcg which is immune to soft limit reclaim.
Could you update softlimit doc ?
Quoted 73 lines
Signed-off-by Ying Han <[email protected]>--- include/linux/memcontrol.h | 7 ++++ kernel/res_counter.c | 1 - mm/memcontrol.c | 8 +++++ mm/vmscan.c | 67 ++++++++++++++++++++++++++----------------- 4 files changed, 55 insertions(+), 28 deletions(-)include/linux/memcontrol.h +7
-0@@ -107,6 +107,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *, struct mem_cgroup_reclaim_cookie *);void mem_cgroup_iter_break (struct mem_cgroup *,struct mem_cgroup *); +bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *); +/* * For memory reclaim. */ @@ -293,6 +295,11 @@ static inline void mem_cgroup_iter_break(struct mem_cgroup *root, { } +static inline bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *mem) +{ +return true; +} +static inline int mem_cgroup_get_reclaim_priority (struct mem_cgroup *memcg) {return 0 ;kernel/res_counter.c +0
-1@@ -18,7 +18,6 @@ void res_counter_init(struct res_counter *counter, struct res_counter *parent) {spin_lock_init (&counter->lock); counter->limit =RESOURCE_MAX ; - counter->soft_limit =RESOURCE_MAX ; counter->parent = parent; }mm/memcontrol.c +8
-0@@ -926,6 +926,14 @@ out: }EXPORT_SYMBOL (mem_cgroup_count_vm_event); +bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *mem) +{ +if (mem_cgroup_disabled () ||mem_cgroup_is_root (mem)) +return true; + +return res_counter_soft_limit_excess (&mem->res) >0 ; +} +/** * mem_cgroup_zone_lruvec - get the lru list vector for a zone and memcg * @zone: zone of the wanted lruvec mm/vmscan.c +1
-0@@ -2091,6 +2091,17 @@ restart:throttle_vm_writeout (sc->gfp_mask); } +static bool should_reclaim_mem_cgroup(struct scan_control *sc,
mm/vmscan.c restart: · line 2104
Quoted 10 lines
mm/vmscan.c +10
-0+ struct mem_cgroup *mem, + int priority) +{ +if (!global_reclaim (sc) || priority <=DEF_PRIORITY -3 || +mem_cgroup_soft_limit_exceeded (mem)) +return true; + +return false; +} +
Why "priority <= DEF_PRIORTY - 3" is selected ?
It seems there is no reason. Could you justify this check ?
Thinking briefly, can't we caluculate the ratio as
number of pages in reclaimable memcg / number of reclaimable pages
And use 'priorty' ? If
total_reclaimable_pages >> priority > number of pages in reclaimabe memcg
memcg under softlimit should be scanned..then, we can avoid scanning pages twice.
Hmm, please give reason of the magic value here, anyway.
Quoted 15 lines
mm/vmscan.c +3
-1static void shrink_zone (int priority,struct zone *zone,struct scan_control *sc) {@@ -2108,7 +2119,9 @@ static void shrink_zone(int priority, struct zone *zone, .zone = zone, }; -shrink_mem_cgroup_zone (priority, &mz, sc); +if (should_reclaim_mem_cgroup (sc, memcg, priority)) +shrink_mem_cgroup_zone (priority, &mz, sc); +/* * Limit reclaim has historically picked one memcg and * scanned it with decreasing priority levels until
mm/vmscan.c static bool shrink_zones(int priority, struct zonelist *zonelist, · line 2169
Quoted 7 lines
mm/vmscan.c +2
-2@@ -2152,8 +2165,8 @@ static bool shrink_zones(int priority, struct zonelist *zonelist, {struct zoneref *z;struct zone *zone; -unsigned long nr_soft_reclaimed; -unsigned long nr_soft_scanned; +// unsigned long nr_soft_reclaimed; +// unsigned long nr_soft_scanned;
Why do you leave these things ?
Hmm, but the whole logic seems clean to me except for magic number.
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>
Re: [PATCH 1/3] memcg: rework softlimit reclaim
Quoted 11 lines · KAMEZAWA Hiroyuki
Quoted 8 lines · On Tue, 6 Dec 2011 15:59:57 -0800 Ying Han <[email protected]> wrote:
Under the
shrink_zone, we examine whether or not to reclaim from a memcg based on its softlimit. We skip scanning the memcg for the first 3 priority. This is to balance between isolation and efficiency. we don't want to halt the system by skipping memcgs with low-hanging fruits forever.Another change is to set
soft_limit_in_bytesto 0 by default. This is needed for both functional and performance:
Quoted 8 lines
Quoted 6 lines
1. If
soft_limitare all set to MAX, it wastes first three periority iterations without scanning anything.2. By default every memcg is eligibal for softlimit reclaim, and we can also set the value to MAX for special memcg which is immune to soft limit reclaim.
Could you update softlimit doc ?
Will do .
Quoted 75 lines
Quoted 75 lines
Signed-off-by Ying Han <[email protected]>---
include/linux/memcontrol.h | 7 ++++
kernel/res_counter.c | 1 -
mm/memcontrol.c | 8 +++++
mm/vmscan.c | 67 ++++++++++++++++++++++++++-----------------4 files changed, 55 insertions(+), 28 deletions(-)include/linux/memcontrol.h +7
-0@@ -107,6 +107,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *, struct mem_cgroup_reclaim_cookie *); void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *); +bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *); + /** For memory reclaim. */ @@ -293,6 +295,11 @@ static inline void mem_cgroup_iter_break(struct mem_cgroup *root, { } +static inline bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *mem) +{ + return true; +} + static inline int mem_cgroup_get_reclaim_priority(struct mem_cgroup *memcg) { return 0;kernel/res_counter.c +0
-1@@ -18,7 +18,6 @@ void res_counter_init(struct res_counter *counter, struct res_counter *parent) { spin_lock_init(&counter->lock); counter->limit = RESOURCE_MAX; - counter->soft_limit = RESOURCE_MAX; counter->parent = parent; }mm/memcontrol.c +8
-0@@ -926,6 +926,14 @@ out: } EXPORT_SYMBOL(mem_cgroup_count_vm_event); +bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *mem) +{ + if (mem_cgroup_disabled() || mem_cgroup_is_root(mem)) + return true; + + return res_counter_soft_limit_excess(&mem->res) > 0; +} + /*** mem_cgroup_zone_lruvec - get the lru list vector for a zone and memcg * @zone: zone of the wanted lruvec mm/vmscan.c +0
-0@@ -2091,6 +2091,17 @@ restart: throttle_vm_writeout(sc->gfp_mask); }
Quoted 14 lines
mm/vmscan.c restart: · line 2104
Quoted 11 lines
mm/vmscan.c +11
-0+static bool should_reclaim_mem_cgroup (struct scan_control *sc, + struct mem_cgroup *mem, + int priority) +{ + if (!global_reclaim(sc) || priority <= DEF_PRIORITY - 3 || + mem_cgroup_soft_limit_exceeded(mem)) + return true; + + return false; +} +Why "priority <=
DEF_PRIORTY- 3" is selected ?
It seems there is no reason. Could you justify this check ?
There is no particular reason for this magic "3". And the plan is to open for further tuning later after seeing real problems.
The idea here is to balance out the performance vs isolation. We don't want to keep trying on "over softlimit memcgs" with hard to reclaim memory while leaving the "under softlimit memcg" with low-hanging fruit behind. This hurts the system performance as a whole.
Quoted 11 lines
Thinking briefly, can't we caluculate the ratio as
number of pages in reclaimable memcg / number of reclaimable pages
And use 'priorty' ? If
total_reclaimable_pages>> priority > number of pages in reclaimabe memcgmemcg under softlimit should be scanned..then, we can avoid scanning pages twice.
Another thing we were talking about during summit is to reclaim the pages proportionally based on how much each memcg exceeds its softlimit, and the calculation above seems to be related to that.
I am pretty sure that we will tune the way to select memcg to reclaim and how much to relciam while start running into problems, and there are different ways to tune it. This patch is the very first step to get started and the main purpose is to get rid of the big giant old softlimit reclaim implementation.
Quoted 18 lines
Hmm, please give reason of the magic value here, anyway.
Quoted 16 lines
mm/vmscan.c +3
-1static void shrink_zone(int priority, struct zone *zone, struct scan_control *sc) {@@ -2108,7 +2119,9 @@ static void shrink_zone(int priority, struct zone *zone, .zone = zone, }; - shrink_mem_cgroup_zone(priority, &mz, sc); + if (should_reclaim_mem_cgroup(sc, memcg, priority)) + shrink_mem_cgroup_zone(priority, &mz, sc); + /** Limit reclaim has historically picked one memcg and * scanned it with decreasing priority levels until @@ -2152,8 +2165,8 @@ static bool shrink_zones(int priority, struct zonelist *zonelist, {
Quoted 8 lines
mm/vmscan.c static bool shrink_zones(int priority, struct zonelist *zonelist, · line 2169
Quoted 6 lines
mm/vmscan.c +2
-2struct zoneref *z; struct zone *zone; - unsigned long nr_soft_reclaimed; - unsigned long nr_soft_scanned; +// unsigned long nr_soft_reclaimed; +// unsigned long nr_soft_scanned; Why do you leave these things ?
I steal this idea from Johannes's last posted softlimit rework patch. My understanding is to make
the bisect easier later, maybe I am wrong.
Quoted 1 line
Hmm, but the whole logic seems clean to me except for magic number.
Thanks.
--Ying
Quoted 4 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>
PATCH 2/3 memcg: revert current soft limit reclaim implementation
In reply to Ying HanThis patch reverts all the existing softlimit reclaim implementations, and should be merged together with previous patch.
--- include/linux/memcontrol.h | 11 -- include/linux/swap.h | 4 - mm/memcontrol.c | 380 +------------------------------------------- mm/vmscan.c | 68 -------- 4 files changed, 2 insertions(+), 461 deletions(-)
include/linux/memcontrol.h +0 -11
@@ -153,9 +153,6 @@ static inline void mem_cgroup_dec_page_stat(struct page *page,mem_cgroup_update_page_stat (page, idx,-1 ); } -unsigned long mem_cgroup_soft_limit_reclaim (struct zone *zone,int order, -gfp_t gfp_mask, -unsigned long *total_scanned);u64 mem_cgroup_get_limit (struct mem_cgroup *memcg);void mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx);
@@ -368,14 +365,6 @@ 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, -unsigned long *total_scanned) -{ -return 0 ; -} - -static inline u64 mem_cgroup_get_limit (struct mem_cgroup *memcg) {return 0 ;
include/linux/swap.h +0 -4
@@ -256,10 +256,6 @@ extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,extern int __isolate_lru_page (struct page *page,isolate_mode_t mode,int file);extern unsigned long try_to_free_mem_cgroup_pages (struct mem_cgroup *mem,gfp_t gfp_mask,bool noswap); -extern unsigned long mem_cgroup_shrink_node_zone (struct mem_cgroup *mem, -gfp_t gfp_mask,bool noswap, -struct zone *zone, -unsigned long *nr_scanned);extern unsigned long shrink_all_memory (unsigned long nr_pages);extern int vm_swappiness;extern int remove_mapping (struct address_space *mapping,struct page *page);
mm/memcontrol.c +2 -378
488 lines not on this page · raw message
mm/vmscan.c +0 -68
98 lines not on this page · raw message
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 2/3] memcg: revert current soft limit reclaim implementation
Quoted 4 lines · On Tue, 6 Dec 2011 15:59:58 -0800 Ying Han <[email protected]> wrote:
This patch reverts all the existing softlimit reclaim implementations, and should be merged together with previous patch.
Signed-off-by Ying Han <[email protected]>
I'm ok with this. Because of changes in vmscan.c, it's not valuable to keep per-zone softlimit statistics. All memcg under tree will be visited anyway.
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>
PATCH 3/3 memcg: track reclaim stats in memory.vmscan_stat
In reply to Ying HanNot asking for inclusion, only for testing purpose.
The API tracks the number of scanned and freed pages during page reclaim as well as the total time taken to shrink_zone(). Counts are broken down by context (system vs. limit, under hierarchy) and by type.
"_by_limit": per-memcg reclaim and memcg is the target "_by_system": global reclaim and memcg is the target
"_by_limit_under_hierarchy": per-memcg reclaim and memcg is under the hierarchy "_by_system_under_hierarchy": global reclaim and memcg is under the hierarchy
Sample output:
$ cat /.../memory.vmscan_stat ... scanned_pages_by_limit 3954818 scanned_anon_pages_by_limit 0 scanned_file_pages_by_limit 3954818 freed_pages_by_limit 3929770 freed_anon_pages_by_limit 0 freed_file_pages_by_limit 3929770 elapsed_ns_by_limit 3386358102 ...
--- include/linux/memcontrol.h | 18 +++++ mm/memcontrol.c | 153 +++++++++++++++++++++++++++++++++++++++++++- mm/vmscan.c | 35 ++++++++++- 3 files changed, 203 insertions(+), 3 deletions(-)
include/linux/memcontrol.h +18 -0
@@ -38,6 +38,12 @@ struct mem_cgroup_reclaim_cookie {unsigned int generation; }; +struct memcg_scan_record { +unsigned long nr_scanned[2 ];/* the number of scanned pages */ +unsigned long nr_freed[2 ];/* the number of freed pages */ +unsigned long elapsed;/* nsec of time elapsed while scanning */ +}; +#ifdef CONFIG_CGROUP_MEM_RES_CTLR /* * All "charge" functions with gfp_mask should use GFP_KERNEL or
@@ -126,6 +132,10 @@ 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_record_scanstat (struct mem_cgroup *mem, +struct memcg_scan_record *rec, +bool global,bool hierarchy); +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP extern int do_swap_account;#endif
@@ -378,6 +388,14 @@ static inlinevoid mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx) { } + +static inline void +mem_cgroup_record_scanstat (struct mem_cgroup *mem, +struct memcg_scan_record *rec, +bool global,bool hierarchy) +{ +} +#endif /* CONFIG_CGROUP_MEM_CONT */ #if !defined(CONFIG_CGROUP_MEM_RES_CTLR ) || !defined(CONFIG_DEBUG_VM )
mm/memcontrol.c +151 -2
189 lines not on this page · raw message
mm/vmscan.c +34 -1
@@ -110,6 +110,11 @@ struct scan_control {struct mem_cgroup *target_mem_cgroup;/* +* Stats tracked during page reclaim. +*/ +struct memcg_scan_record *memcg_record; + +/* * Nodemask of nodes allowed by the caller. If NULL, all nodes * are scanned. */
@@ -1522,6 +1527,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct mem_cgroup_zone *mz, nr_taken =isolate_pages (nr_to_scan, mz, &page_list, &nr_scanned, sc->order, reclaim_mode,0 , file); + + sc->memcg_record->nr_scanned[file] += nr_scanned; +if (global_reclaim (sc)) { zone->pages_scanned += nr_scanned;if (current_is_kswapd ())
@@ -1551,6 +1559,8 @@ shrink_inactive_list(unsigned long nr_to_scan, struct mem_cgroup_zone *mz, priority, &nr_dirty, &nr_writeback); } + sc->memcg_record->nr_freed[file] += nr_reclaimed; +local_irq_disable ();if (current_is_kswapd ())__count_vm_events (KSWAPD_STEAL , nr_reclaimed);
@@ -1675,6 +1685,9 @@ static void shrink_active_list(unsigned long nr_pages, &pgscanned, sc->order, reclaim_mode, 1, file); +if (sc->memcg_record) + sc->memcg_record->nr_scanned[file] += pgscanned; +if (global_reclaim (sc)) zone->pages_scanned += pgscanned;
@@ -2111,6 +2124,9 @@ static void shrink_zone(int priority, struct zone *zone, .priority = priority, };struct mem_cgroup *memcg; +struct memcg_scan_record rec; + + sc->memcg_record = &rec; memcg =mem_cgroup_iter (root,NULL , &reclaim); do {
@@ -2119,9 +2135,21 @@ static void shrink_zone(int priority, struct zone *zone, .zone = zone, }; -if (should_reclaim_mem_cgroup (sc, memcg, priority)) +if (should_reclaim_mem_cgroup (sc, memcg, priority)) { +unsigned long start, end; + +memset (&rec,0 ,sizeof (rec)); + start =sched_clock (); +shrink_mem_cgroup_zone (priority, &mz, sc); + end =sched_clock (); + rec.elapsed = end - start; +mem_cgroup_record_scanstat (memcg, &rec, +global_reclaim (sc), + root != memcg); + } +/* * Limit reclaim has historically picked one memcg and * scanned it with decreasing priority levels until
@@ -2355,6 +2383,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .order = order, .target_mem_cgroup = NULL, .nodemask = nodemask, + .memcg_record = NULL, };struct shrink_control shrink = { .gfp_mask = sc.gfp_mask,
@@ -2390,6 +2419,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont, .nodemask = NULL, /* we don't care the placement */ .gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK), + .memcg_record = NULL, };struct shrink_control shrink = { .gfp_mask = sc.gfp_mask,
@@ -2558,6 +2588,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, .nr_to_reclaim = ULONG_MAX, .order = order, .target_mem_cgroup = NULL, + .memcg_record = NULL, };struct shrink_control shrink = { .gfp_mask = sc.gfp_mask,
@@ -3029,6 +3060,7 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim) .nr_to_reclaim = nr_to_reclaim, .hibernation_mode = 1, .order = 0, + .memcg_record = NULL, };struct shrink_control shrink = { .gfp_mask = sc.gfp_mask,
@@ -3215,6 +3247,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) SWAP_CLUSTER_MAX), .gfp_mask = gfp_mask, .order = order, + .memcg_record = NULL, };struct shrink_control shrink = { .gfp_mask = sc.gfp_mask,
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>