]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mm: workingset: turn shadow node shrinker bugs into warnings
authorJohannes Weiner <hannes@cmpxchg.org>
Tue, 13 Dec 2016 00:43:38 +0000 (16:43 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 13 Dec 2016 02:55:08 +0000 (18:55 -0800)
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>
mm/workingset.c

index fb1f9183d89a360d7b7851a9083e098ff5696b8c..98f830897b1ba66356dc05ba7f6e7fa89c4b2f5a 100644 (file)
@@ -418,23 +418,27 @@ static enum lru_status shadow_lru_isolate(struct list_head *item,
         * no pages, so we expect to be able to remove them all and
         * delete and free the empty node afterwards.
         */
-       BUG_ON(!workingset_node_shadows(node));
-       BUG_ON(workingset_node_pages(node));
-
+       if (WARN_ON_ONCE(!workingset_node_shadows(node)))
+               goto out_invalid;
+       if (WARN_ON_ONCE(workingset_node_pages(node)))
+               goto out_invalid;
        for (i = 0; i < RADIX_TREE_MAP_SIZE; i++) {
                if (node->slots[i]) {
-                       BUG_ON(!radix_tree_exceptional_entry(node->slots[i]));
+                       if (WARN_ON_ONCE(!radix_tree_exceptional_entry(node->slots[i])))
+                               goto out_invalid;
+                       if (WARN_ON_ONCE(!mapping->nrexceptional))
+                               goto out_invalid;
                        node->slots[i] = NULL;
                        workingset_node_shadows_dec(node);
-                       BUG_ON(!mapping->nrexceptional);
                        mapping->nrexceptional--;
                }
        }
-       BUG_ON(workingset_node_shadows(node));
+       if (WARN_ON_ONCE(workingset_node_shadows(node)))
+               goto out_invalid;
        inc_node_state(page_pgdat(virt_to_page(node)), WORKINGSET_NODERECLAIM);
-       if (!__radix_tree_delete_node(&mapping->page_tree, node))
-               BUG();
+       __radix_tree_delete_node(&mapping->page_tree, node);
 
+out_invalid:
        spin_unlock(&mapping->tree_lock);
        ret = LRU_REMOVED_RETRY;
 out: