softlimit reclaim and zone->lru_lock rework
Subsystems (9)
cover softlimit reclaim and zone->lru_lock rework
The patchset is based on mmotm-2011-05-12-15-52 plus the following patches.
[BUGFIX][PATCH 5/5] memcg: fix percpu cached charge draining frequency [patch 1/8] memcg: remove unused retry signal from reclaim
[patch 2/8] mm: memcg-aware global reclaim
[patch 3/8] memcg: reclaim statistics
[patch 6/8] vmscan: change zone_nr_lru_pages to take memcg instead of scan control [patch 7/8] vmscan: memcg-aware unevictable page rescue scanner [patch 8/8] mm: make per-memcg lru lists exclusive
This patchset comes only after Johannes "memcg naturalization" effort. I don't expect this to be merged soon. The reason for me to post it here for syncing up with ppl with the current status of the effort. And also comments and code reviews are welcomed.
This patchset includes:
1. rework softlimit reclaim on priority based. this depends on the "memcg-aware global reclaim" patch.
2. break the zone->lru_lock for memcg reclaim. this depends on the "per-memcg lru lists exclusive" patch.
I would definitely make them as two seperate patches later. For now, this is only to sync-up with folks on the status of the effort.
Ying Han (5):
Revert soft_limit reclaim changes under global pressure. Revert soft limit reclaim implementation in memcg. rework softlimit reclaim.
memcg: break the zone->lru_lock in memcg-aware reclaim Move the lru_lock into the lruvec struct.
include/linux/memcontrol.h | 35 ++- include/linux/mm_types.h | 2 +- include/linux/mmzone.h | 8 +- include/linux/swap.h | 5 - mm/compaction.c | 41 +++-- mm/huge_memory.c | 5 +- mm/memcontrol.c | 502 ++++++-------------------------------------- mm/page_alloc.c | 2 +- mm/rmap.c | 2 +- mm/swap.c | 71 ++++--- mm/vmscan.c | 186 ++++++++--------- 11 files changed, 246 insertions(+), 613 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>
RFC PATCH 5/5 Move the lru_lock into the lruvec struct.
The lruvec structure is introduced as part of Johannes patchset. It exists for both global zone and per-memcg-per-zone struct. All the lru operations are done in generic code after this addition.
It is straight-forward to move the lru_lock within the struct.
--- include/linux/memcontrol.h | 4 ++-- include/linux/mm_types.h | 2 +- include/linux/mmzone.h | 8 ++++---- mm/memcontrol.c | 23 +++++++++++------------ mm/page_alloc.c | 2 +- mm/rmap.c | 2 +- mm/swap.c | 2 +- mm/vmscan.c | 8 ++++---- 8 files changed, 25 insertions(+), 26 deletions(-)
include/linux/memcontrol.h +2 -2
@@ -387,13 +387,13 @@ static inline spinlock_t *page_lru_lock(struct page *page)struct zone *zone; zone =page_zone (page); - return &zone->lru_lock; + return &zone->lruvec.lru_lock; }static inline spinlock_t *mem_cgroup_lru_lock (struct mem_cgroup *mem,struct zone *zone) { -return &zone->lru_lock; +return &zone->lruvec.lru_lock; }#endif /* CONFIG_CGROUP_MEM_CONT */
include/linux/mm_types.h +1 -1
@@ -73,7 +73,7 @@ struct page {void *freelist;/* SLUB: freelist req. slab lock */ };struct list_head lru;/* Pageout list, eg. active_list -* protected by zone->lru_lock ! +* protected by lruvec.lru_lock ! */ /* * On machines where all RAM is mapped into kernel address space,
include/linux/mmzone.h +4 -4
@@ -62,10 +62,10 @@ struct free_area {struct pglist_data ;/* -* zone->lock and zone->lru_lock are two of the hottest locks in the kernel. +* zone->lock and lruvec.lru_lock are two of the hottest locks in the kernel. * So add a wild amount of padding here to ensure that they fall into separate -* cachelines. There are very few zone structures in the machine, so space -* consumption is not a concern here. +* cachelines. There are very few zone structures in the machine, so +* space consumption is not a concern here. */ #if defined(CONFIG_SMP ) struct zone_padding {
@@ -160,6 +160,7 @@ static inline int is_unevictable_lru(enum lru_list l)struct lruvec {struct list_head lists[NR_LRU_LISTS ]; +spinlock_t lru_lock; };enum zone_watermarks {
@@ -343,7 +344,6 @@ struct zone {ZONE_PADDING (_pad1_)/* Fields commonly accessed by the page reclaim scanner */ - spinlock_t lru_lock; struct lruvec lruvec;struct zone_reclaim_stat reclaim_stat;
mm/memcontrol.c +11 -12
@@ -144,7 +144,6 @@ struct mem_cgroup_stat_cpu {* per-zone information in memory controller. */ struct mem_cgroup_per_zone { -spinlock_t lru_lock;struct lruvec lruvec;unsigned long count[NR_LRU_LISTS ];
@@ -737,7 +736,7 @@ spinlock_t *page_lru_lock(struct page *page) zone =page_zone (page);if (mem_cgroup_disabled ()) -return &zone->lru_lock; +return &zone->lruvec.lru_lock; pc =lookup_page_cgroup (page);
@@ -751,7 +750,7 @@ spinlock_t *page_lru_lock(struct page *page) mz =page_cgroup_zoneinfo (mem, page); -return &mz->lru_lock; +return &mz->lruvec.lru_lock; }spinlock_t *mem_cgroup_lru_lock (struct mem_cgroup *mem,struct zone *zone)
@@ -760,12 +759,12 @@ spinlock_t *mem_cgroup_lru_lock(struct mem_cgroup *mem, struct zone *zone)int nid, zid;if (mem_cgroup_disabled ()) -return &zone->lru_lock; +return &zone->lruvec.lru_lock; nid =zone_to_nid (zone); zid =zone_idx (zone); mz =mem_cgroup_zoneinfo (mem, nid, zid); -return &mz->lru_lock; +return &mz->lruvec.lru_lock; }/**
@@ -920,7 +919,7 @@ struct lruvec *mem_cgroup_lru_move_lists(struct zone *zone,* At handling SwapCache and other FUSE stuff, pc->mem_cgroup may be changed * while it's linked to lru because the page may be reused after it's fully * uncharged. To handle that, unlink page_cgroup from LRU when charge it again. -* It's done under lock_page and expected that zone->lru_lock isnever held. +* It's done under lock_page and expected that lruvec.lru_lock is never held. */ static void mem_cgroup_lru_del_before_commit (struct page *page) {
@@ -2202,7 +2201,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *mem, (1 << PCG_ACCT_LRU) | (1 << PCG_MIGRATION))/* * Because tail pages are not marked as "used", set it. We're under -* zone->lru_lock, 'splitting on pmd' and compund_lock. +* lruvec.lru_lock, 'splitting on pmd' and compund_lock. */ void mem_cgroup_split_huge_fixup (struct page *head,struct page *tail) {
@@ -3297,19 +3296,19 @@ static int mem_cgroup_force_empty_list(struct mem_cgroup *mem,struct page *page; ret =0 ; -spin_lock_irqsave (&mz->lru_lock, flags); +spin_lock_irqsave (&mz->lruvec.lru_lock, flags);if (list_empty (list)) { -spin_unlock_irqrestore (&mz->lru_lock, flags); +spin_unlock_irqrestore (&mz->lruvec.lru_lock, flags);break ; } page = list_entry(list->prev, struct page, lru);if (busy == page) {list_move (&page->lru, list); busy =NULL ; -spin_unlock_irqrestore (&mz->lru_lock, flags); +spin_unlock_irqrestore (&mz->lruvec.lru_lock, flags);continue ; } -spin_unlock_irqrestore (&mz->lru_lock, flags); +spin_unlock_irqrestore (&mz->lruvec.lru_lock, flags); pc =lookup_page_cgroup (page);
@@ -4362,7 +4361,7 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *mem, int node) mem->info.nodeinfo[node] = pn;for (zone =0 ; zone <MAX_NR_ZONES ; zone++) { mz = &pn->zoneinfo[zone]; -spin_lock_init (&mz->lru_lock); +spin_lock_init (&mz->lruvec.lru_lock);for_each_lru (l)INIT_LIST_HEAD (&mz->lruvec.lists[l]); }
mm/page_alloc.c +1 -1
@@ -4316,7 +4316,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,#endif zone->name = zone_names[j];spin_lock_init (&zone->lock); -spin_lock_init (&zone->lru_lock); +spin_lock_init (&zone->lruvec.lru_lock);zone_seqlock_init (zone); zone->zone_pgdat = pgdat;
mm/rmap.c +1 -1
@@ -27,7 +27,7 @@* mapping->i_mmap_mutex * anon_vma->mutex * mm->page_table_lock or pte_lock -* zone->lru_lock (in mark_page_accessed, isolate_lru_page) +* lruvec.lru_lock (in mark_page_accessed, isolate_lru_page) * swap_lock (in swap_duplicate, swap_info_get) * mmlist_lock (in mmput, drain_mmlist and others) * mapping->private_lock (in __set_page_dirty_buffers)
mm/swap.c +1 -1
@@ -560,7 +560,7 @@ int lru_add_drain_all(void)* passed pages. If it fell to zero then remove the page from the LRU and * free it. * -* Avoid taking zone->lru_lock if possible, but if it is taken, retain it +* Avoid taking lruvec.lru_lock if possible, but if it is taken, retain it * for the remainder of the operation. * * The locking in this function is against shrink_inactive_list(): we recheck
mm/vmscan.c +4 -4
@@ -1050,7 +1050,7 @@ int __isolate_lru_page(struct page *page, int mode, int file) }/* -* zone->lru_lock is heavily contended. Some of the functions that +* lruvec.lru_lock is heavily contended. Some of the functions that * shrink the lists perform better by taking out a batch of pages * and working on them outside the LRU lock. *
@@ -1520,9 +1520,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct zone *zone,* processes, from rmap. * * If the pages are mostly unmapped, the processing is fast and it is -* appropriate to hold zone->lru_lock across the whole operation. But if +* appropriate to hold lruvec.lru_lock across the whole operation. But if * the pages are mapped, the processing is slow (page_referenced()) so we -* should drop zone->lru_lock around each page. It's impossible to balance +* should drop lruvec.lru_lock around each page. It's impossible to balance * this, so instead we remove the pages from the LRU while processing them. * It is safe to rely on PG_active against the non-LRU pages in here because * nobody will play with that bit on a non-LRU page.
@@ -3214,7 +3214,7 @@ int page_evictable(struct page *page, struct vm_area_struct *vma)* Checks a page for evictability and moves the page to the appropriate * zone lru list. * -* Restrictions: zone->lru_lock must be held, page must be on LRU and must +* Restrictions: lruvec.lru_lock must be held, page must be on LRU and must * have PageUnevictable set. */ static void check_move_unevictable_page (struct page *page,struct zone *zone)
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>
RFC PATCH 4/5 memcg: break the zone->lru_lock in memcg-aware reclaim
In reply to Ying HanThis patch removes the places where we hold the zone->lru_lock and replaces it with per-memcg mz->lru lock. Two supporting functions are added to return the right lock for a page or a mem_cgroup.
Two flags are used to identify the right memcg LRU lock, AcctLRU bit and Used bit. When we delete page from LRU, the AcctLRU bit is used since we first uncharge the page and remove it from lru. When we add page into LRU, the Used bit is used since we first charge the page and then add into the LRU list.
--- include/linux/memcontrol.h | 17 +++++++ mm/compaction.c | 41 +++++++++++------ mm/huge_memory.c | 5 +- mm/memcontrol.c | 63 +++++++++++++++++++++++--- mm/swap.c | 69 ++++++++++++++++------------ mm/vmscan.c | 106 ++++++++++++++++++++++++++++++------------- 6 files changed, 215 insertions(+), 86 deletions(-)
include/linux/memcontrol.h +17 -0
@@ -80,6 +80,9 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);extern struct mem_cgroup *try_get_mem_cgroup_from_page (struct page *page);extern struct mem_cgroup *mem_cgroup_from_task (struct task_struct *p); +spinlock_t *page_lru_lock (struct page *page); +spinlock_t *mem_cgroup_lru_lock (struct mem_cgroup *mem,struct zone *zone); +static inline int mm_match_cgroup (const struct mm_struct *mm,const struct mem_cgroup *cgroup) {
@@ -378,6 +381,20 @@ static inlinevoid mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx) { } + +static inline spinlock_t *page_lru_lock (struct page *page) +{ +struct zone *zone; + + zone =page_zone (page); +return &zone->lru_lock; +} + +static inline spinlock_t * +mem_cgroup_lru_lock (struct mem_cgroup *mem,struct zone *zone) +{ +return &zone->lru_lock; +}#endif /* CONFIG_CGROUP_MEM_CONT */ #if !defined(CONFIG_CGROUP_MEM_RES_CTLR ) || !defined(CONFIG_DEBUG_VM )
mm/compaction.c +26 -15
74 lines not on this page · raw message
mm/huge_memory.c +3 -2
@@ -1156,9 +1156,10 @@ static void __split_huge_page_refcount(struct page *page)unsigned long head_index = page->index;struct zone *zone =page_zone (page);int zonestat; +spinlock_t *lru_lock =page_lru_lock (page);/* prevent PageLRU to go away from under us, and freeze lru stats */ -spin_lock_irq (&zone->lru_lock); +spin_lock_irq (lru_lock);compound_lock (page);for (i =1 ; i <HPAGE_PMD_NR ; i++) {
@@ -1238,7 +1239,7 @@ static void __split_huge_page_refcount(struct page *page)ClearPageCompound (page);compound_unlock (page); -spin_unlock_irq (&zone->lru_lock); +spin_unlock_irq (lru_lock);for (i =1 ; i <HPAGE_PMD_NR ; i++) {struct page *page_tail = page + i;
mm/memcontrol.c +55 -8
127 lines not on this page · raw message
mm/swap.c +40 -29
159 lines not on this page · raw message
mm/vmscan.c +74 -32
339 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>
RFC PATCH 1/5 Revert soft_limit reclaim changes under global pressure.
In reply to Ying HanTwo commits are reverted in this patch.
memcg: count the soft_limit reclaim in global background reclaim
memcg: add the soft_limit reclaim in global direct reclaim.
The two patches are the changes on top of existing global soft_limit reclaim which will also be reverted in the following patch.
--- include/linux/memcontrol.h | 6 ++---- include/linux/swap.h | 3 +-- mm/memcontrol.c | 16 ++++------------ mm/vmscan.c | 31 +++++-------------------------- 4 files changed, 12 insertions(+), 44 deletions(-)
include/linux/memcontrol.h +2 -4
@@ -147,8 +147,7 @@ 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, -unsigned long *total_scanned); +gfp_t gfp_mask);u64 mem_cgroup_get_limit (struct mem_cgroup *mem);void mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx);
@@ -361,8 +360,7 @@ 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) +gfp_t gfp_mask); {return 0 ; }
include/linux/swap.h +1 -2
@@ -257,8 +257,7 @@ 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, -unsigned long *nr_scanned); +struct zone *zone);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;
mm/memcontrol.c +4 -12
@@ -1664,8 +1664,7 @@ int mem_cgroup_select_victim_node(struct mem_cgroup *mem)static int mem_cgroup_soft_reclaim (struct mem_cgroup *root_mem,struct zone *zone, -gfp_t gfp_mask, -unsigned long *total_scanned) +gfp_t gfp_mask) {struct mem_cgroup *victim;int ret, total =0 ;
@@ -1673,7 +1672,6 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_mem,bool noswap = false;bool is_kswapd = false;unsigned long excess; -unsigned long nr_scanned; excess =res_counter_soft_limit_excess (&root_mem->res) >>PAGE_SHIFT ;
@@ -1720,8 +1718,7 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup *root_mem, }/* we use swappiness of local cgroup */ ret =mem_cgroup_shrink_node_zone (victim, gfp_mask, noswap, -get_swappiness (victim), zone, - &nr_scanned); +get_swappiness (victim), zone);css_put (&victim->css); total += ret;if (!res_counter_soft_limit_excess (&root_mem->res))
@@ -3527,8 +3524,7 @@ 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, -unsigned long *total_scanned) +gfp_t gfp_mask) {unsigned long nr_reclaimed =0 ;struct mem_cgroup_per_zone *mz, *next_mz =NULL ;
@@ -3536,7 +3532,6 @@ 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 ;
@@ -3555,11 +3550,8 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,if (!mz)break ; - nr_scanned =0 ; - reclaimed =mem_cgroup_soft_reclaim (mz->mem, zone, gfp_mask, - &nr_scanned); + reclaimed =mem_cgroup_soft_reclaim (mz->mem, zone, gfp_mask); nr_reclaimed += reclaimed; - *total_scanned += nr_scanned;spin_lock (&mctz->lock);
mm/vmscan.c +5 -26
@@ -2026,14 +2026,11 @@ static void shrink_zone(int priority, struct zone *zone,* If a zone is deemed to be full of pinned pages then just give it a light * scan then give up on it. */ -static unsigned long shrink_zones (int priority,struct zonelist *zonelist, +static void shrink_zones (int priority,struct zonelist *zonelist,struct scan_control *sc) {struct zoneref *z;struct zone *zone; -unsigned long nr_soft_reclaimed; -unsigned long nr_soft_scanned; -unsigned long total_scanned =0 ;for_each_zone_zonelist_nodemask (zone, z, zonelist,gfp_zone (sc->gfp_mask), sc->nodemask) {
@@ -2050,17 +2047,8 @@ static unsigned long shrink_zones(int priority, struct zonelist *zonelist,continue ;/* Let kswapd poll it */ } - nr_soft_scanned =0 ; - nr_soft_reclaimed =mem_cgroup_soft_limit_reclaim (zone, - sc->order, sc->gfp_mask, - &nr_soft_scanned); - sc->nr_reclaimed += nr_soft_reclaimed; - total_scanned += nr_soft_scanned; -shrink_zone (priority, zone, sc); } - -return total_scanned; }static bool zone_reclaimable (struct zone *zone)
@@ -2125,7 +2113,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, sc->nr_scanned =0 ;if (!priority)disable_swap_token (); - total_scanned +=shrink_zones (priority, zonelist, sc); +shrink_zones (priority, zonelist, sc);/* * Don't shrink slabs when reclaiming memory from * over limit cgroups
@@ -2233,11 +2221,9 @@ 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, -unsigned long *nr_scanned) +struct zone *zone) {struct scan_control sc = { - .nr_scanned =0 , .nr_to_reclaim =SWAP_CLUSTER_MAX , .may_writepage = !laptop_mode, .may_unmap =1 ,
@@ -2266,7 +2252,6 @@ 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; }
@@ -2422,8 +2407,6 @@ 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 ,
@@ -2516,15 +2499,11 @@ loop_again: sc.nr_scanned =0 ; - nr_soft_scanned =0 ;/* * Call soft limit reclaim before calling shrink_zone. */ - 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; +mem_cgroup_soft_limit_reclaim (zone, order, + sc.gfp_mask);/* * We put equal pressure on every zone, unless
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>
RFC PATCH 3/5 rework softlimit reclaim.
In reply to Ying HanThe "soft_limit was introduced in memcg to support over-committing the memory resource on the host. Each cgroup can be configured with "hard_limit", where it will be throttled or OOM killed by going over the limit. However, the allocation can go above the "soft_limit" as long as there is no memory contention.
The current implementation of softlimit reclaim has its disadvantages:
1. It is triggered under global reclaim, and acts as best-effort before the global LRU scanning.
2. It is based on per-zone RB tree where only the cgroup exceeds the soft_limit the most being selected for reclaim. In another word, there is no fairness.
3. It takes no consideration of how many pages actually allocated on the zone from this cgroup.
4. The target of the softlimit reclaim is to bring one cgroup's usage under its soft_limit, where the global reclaim has different target.
After the "memcg-aware global reclaim" work from Johannes, we have the ability to have the softlimit reclaim better integrated to the rest of reclaim logics.
Here is how it works now:
1. The soft_limit is integrated into shrink_zone() which is being call from both targetting and global reclaim. However, we only check soft_limit under global reclaim.
2. The mem_cgroup_hierarchy_walk() now is integrated inside shrink_zone(). And the soft_limit works as a filter of which memcgs to reclaim from based on the reclaim priority.
3. Don't reclaim from a memcg (under its soft_limit) unless the page reclaim is under trouble. Now we picked DEFAULT_PRIORITY-3 (as mhocko suggested) which causes scanning on zones(unbalanced) and memcgs(above soft_limit) 3 times before start looking into other memcgs (under soft_limit).
TODO:
1. The concern is we might end up burning cpu w/o getting much depends how much low-hanging fruits for the first 3 interation. this is a trade-off of providing the user expectation of "soft_limit". Runing through more workload and evaluate the result would be needed.
--- include/linux/memcontrol.h | 7 +++++++ mm/memcontrol.c | 5 +++++ mm/vmscan.c | 4 ++++ 3 files changed, 16 insertions(+), 0 deletions(-)
include/linux/memcontrol.h +7 -0
@@ -101,6 +101,7 @@ extern void mem_cgroup_end_migration(struct mem_cgroup *mem,struct mem_cgroup *mem_cgroup_hierarchy_walk (struct mem_cgroup *,struct mem_cgroup *);void mem_cgroup_stop_hierarchy_walk (struct mem_cgroup *,struct mem_cgroup *); +bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *);/* * For memory reclaim.
@@ -341,6 +342,12 @@ static inline void mem_cgroup_stop_hierarchy_walk(struct mem_cgroup *r, { } +static inline bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *root, +struct mem_cgroup *mem) +{ +return false; +} +static inline void mem_cgroup_print_oom_info (struct mem_cgroup *memcg,struct task_struct *p) {
mm/memcontrol.c +5 -0
@@ -1317,6 +1317,11 @@ void mem_cgroup_stop_hierarchy_walk(struct mem_cgroup *root,css_put (&mem->css); } +bool mem_cgroup_soft_limit_exceeded (struct mem_cgroup *mem) +{ +return res_counter_soft_limit_excess (&mem->res); +} +static unsigned long mem_cgroup_reclaim (struct mem_cgroup *mem,gfp_t gfp_mask,unsigned long flags)
mm/vmscan.c +4 -0
@@ -1992,6 +1992,10 @@ static void shrink_zone(int priority, struct zone *zone,unsigned long scanned = sc->nr_scanned;unsigned long nr_reclaimed; +if (global_reclaim (sc) && priority >DEF_PRIORITY -3 && + !mem_cgroup_soft_limit_exceeded (mem)) +continue ; + sc->mem_cgroup = mem;do_shrink_zone (priority, zone, sc); mem_cgroup_count_reclaim(mem, current_is_kswapd(),
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>
RFC PATCH 2/5 Revert soft limit reclaim implementation in memcg.
In reply to Ying HanThis reverts the soft limit reclaim implementation (RB-tree based) merged in 2.6.32 kernel.
--- include/linux/memcontrol.h | 9 - include/linux/swap.h | 4 - mm/memcontrol.c | 423 -------------------------------------------- mm/vmscan.c | 43 ----- 4 files changed, 0 insertions(+), 479 deletions(-)
include/linux/memcontrol.h +0 -9
@@ -146,8 +146,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);u64 mem_cgroup_get_limit (struct mem_cgroup *mem);void mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx);
@@ -359,13 +357,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); -{ -return 0 ; -} - -static inline u64 mem_cgroup_get_limit (struct mem_cgroup *mem) {return 0 ;
include/linux/swap.h +0 -4
@@ -254,10 +254,6 @@ extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,extern unsigned long try_to_free_mem_cgroup_pages (struct mem_cgroup *mem,gfp_t gfp_mask,bool noswap,unsigned int swappiness); -extern unsigned long mem_cgroup_shrink_node_zone (struct mem_cgroup *mem, -gfp_t gfp_mask,bool noswap, -unsigned int swappiness, -struct zone *zone);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;
mm/memcontrol.c +0 -423
514 lines not on this page · raw message
mm/vmscan.c +0 -43
55 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: [RFC PATCH 1/5] Revert soft_limit reclaim changes under global pressure.
In reply to Ying HanQuoted 8 lines · Ying Han
Two commits are reverted in this patch.
memcg: count the
soft_limitreclaim in global background reclaim
memcg: add thesoft_limitreclaim in global direct reclaim.The two patches are the changes on top of existing global
soft_limitreclaim which will also be reverted in the following patch.
Why are we doing this? To make the patch series better to read or for ease of code development? IOW, your changelog is not very clear on the benefits
Balbir Singh
--
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>
update Balbir's email in the cc list.
--Ying
Quoted 56 lines · Ying Han
The patchset is based on mmotm-2011-05-12-15-52 plus the following patches.
[BUGFIX][PATCH 5/5] memcg: fix percpu cached charge draining frequency [patch 1/8] memcg: remove unused retry signal from reclaim [patch 2/8] mm: memcg-aware global reclaim
[patch 3/8] memcg: reclaim statistics
[patch 6/8] vmscan: changezone_nr_lru_pagesto take memcg instead of scan control
[patch 7/8] vmscan: memcg-aware unevictable page rescue scanner [patch 8/8] mm: make per-memcg lru lists exclusiveThis patchset comes only after Johannes "memcg naturalization" effort. I don't
expect this to be merged soon. The reason for me to post it here for syncing up
with ppl with the current status of the effort. And also comments and code reviews
are welcomed.This patchset includes:
1. rework softlimit reclaim on priority based. this depends on the "memcg-aware
global reclaim" patch.
2. break thezone->lru_lockfor memcg reclaim. this depends on the "per-memcg
lru lists exclusive" patch.I would definitely make them as two seperate patches later. For now, this is
only to sync-up with folks on the status of the effort.Ying Han (5):
Revertsoft_limitreclaim changes under global pressure. Revert soft limit reclaim implementation in memcg. rework softlimit reclaim.
memcg: break thezone->lru_lockin memcg-aware reclaim Move thelru_lockinto the lruvec struct.include/linux/memcontrol.h | 35 ++- include/linux/mm_types.h | 2 +- include/linux/mmzone.h | 8 +- include/linux/swap.h | 5 - mm/compaction.c | 41 +++-- mm/huge_memory.c | 5 +- mm/memcontrol.c | 502 ++++++-------------------------------------- mm/page_alloc.c | 2 +- mm/rmap.c | 2 +- mm/swap.c | 71 ++++--- mm/vmscan.c | 186 ++++++++--------- 11 files changed, 246 insertions(+), 613 deletions(-)--
1.7.3.1