From: Andrea Arcangeli Date: Fri, 6 Nov 2015 02:49:07 +0000 (-0800) Subject: ksm: add cond_resched() to the rmap_walks X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=ad12695f177c3403a64348b42718faf9727fe358;p=openwrt%2Fstaging%2Fblogic.git ksm: add cond_resched() to the rmap_walks While at it add it to the file and anon walks too. Signed-off-by: Andrea Arcangeli Acked-by: Hugh Dickins Cc: Petr Holasek Acked-by: Davidlohr Bueso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/ksm.c b/mm/ksm.c index 7ee101eaacdf..e87dec7ba950 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1914,9 +1914,11 @@ again: struct anon_vma_chain *vmac; struct vm_area_struct *vma; + cond_resched(); anon_vma_lock_read(anon_vma); anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root, 0, ULONG_MAX) { + cond_resched(); vma = vmac->vma; if (rmap_item->address < vma->vm_start || rmap_item->address >= vma->vm_end) diff --git a/mm/rmap.c b/mm/rmap.c index d40e7aefb888..78a692827a63 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1609,6 +1609,8 @@ static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc) struct vm_area_struct *vma = avc->vma; unsigned long address = vma_address(page, vma); + cond_resched(); + if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg)) continue; @@ -1658,6 +1660,8 @@ static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc) vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) { unsigned long address = vma_address(page, vma); + cond_resched(); + if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg)) continue;