summaryrefslogtreecommitdiffstats
path: root/mm/workingset.c
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2016-12-12 19:43:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-12 21:55:08 -0500
commitb936887e8739d3fa83f87d899f68d136735d9816 (patch)
treedd9b6fb15e44c89711ec526ff7eb2d0476a73f5d /mm/workingset.c
parent59749e6ce53735d8b696763742225f126e94603f (diff)
mm: workingset: turn shadow node shrinker bugs into warnings
When the shadow page shrinker tries to reclaim a radix tree node but finds it in an unexpected state - it should contain no pages, and non-zero shadow entries - there is no need to kill the executing task or even the entire system. Warn about the invalid state, then leave that tree node be. Simply don't put it back on the shadow LRU for future reclaim and move on. Link: http://lkml.kernel.org/r/20161117191138.22769-4-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Jan Kara <jack@suse.cz> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Hugh Dickins <hughd@google.com> Cc: Matthew Wilcox <mawilcox@linuxonhyperv.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/workingset.c')
-rw-r--r--mm/workingset.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/mm/workingset.c b/mm/workingset.c
index fb1f9183d89a..98f830897b1b 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -418,23 +418,27 @@ static enum lru_status shadow_lru_isolate(struct list_head *item,
418 * no pages, so we expect to be able to remove them all and 418 * no pages, so we expect to be able to remove them all and
419 * delete and free the empty node afterwards. 419 * delete and free the empty node afterwards.
420 */ 420 */
421 BUG_ON(!workingset_node_shadows(node)); 421 if (WARN_ON_ONCE(!workingset_node_shadows(node)))
422 BUG_ON(workingset_node_pages(node)); 422 goto out_invalid;
423 423 if (WARN_ON_ONCE(workingset_node_pages(node)))
424 goto out_invalid;
424 for (i = 0; i < RADIX_TREE_MAP_SIZE; i++) { 425 for (i = 0; i < RADIX_TREE_MAP_SIZE; i++) {
425 if (node->slots[i]) { 426 if (node->slots[i]) {
426 BUG_ON(!radix_tree_exceptional_entry(node->slots[i])); 427 if (WARN_ON_ONCE(!radix_tree_exceptional_entry(node->slots[i])))
428 goto out_invalid;
429 if (WARN_ON_ONCE(!mapping->nrexceptional))
430 goto out_invalid;
427 node->slots[i] = NULL; 431 node->slots[i] = NULL;
428 workingset_node_shadows_dec(node); 432 workingset_node_shadows_dec(node);
429 BUG_ON(!mapping->nrexceptional);
430 mapping->nrexceptional--; 433 mapping->nrexceptional--;
431 } 434 }
432 } 435 }
433 BUG_ON(workingset_node_shadows(node)); 436 if (WARN_ON_ONCE(workingset_node_shadows(node)))
437 goto out_invalid;
434 inc_node_state(page_pgdat(virt_to_page(node)), WORKINGSET_NODERECLAIM); 438 inc_node_state(page_pgdat(virt_to_page(node)), WORKINGSET_NODERECLAIM);
435 if (!__radix_tree_delete_node(&mapping->page_tree, node)) 439 __radix_tree_delete_node(&mapping->page_tree, node);
436 BUG();
437 440
441out_invalid:
438 spin_unlock(&mapping->tree_lock); 442 spin_unlock(&mapping->tree_lock);
439 ret = LRU_REMOVED_RETRY; 443 ret = LRU_REMOVED_RETRY;
440out: 444out: