summaryrefslogtreecommitdiff
path: root/mm/vmscan.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4fe7e3aa02e2..acb7611cd525 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1085,21 +1085,25 @@ static int isolate_lru_pages(int nr_to_scan, struct list_head *src,
page = lru_to_page(src);
prefetchw_prev_lru_page(page, src, flags);
- if (!TestClearPageLRU(page))
- BUG();
list_del(&page->lru);
- if (get_page_testone(page)) {
+ if (unlikely(get_page_testone(page))) {
/*
* It is being freed elsewhere
*/
__put_page(page);
- SetPageLRU(page);
list_add(&page->lru, src);
continue;
- } else {
- list_add(&page->lru, dst);
- nr_taken++;
}
+
+ /*
+ * Be careful not to clear PageLRU until after we're sure
+ * the page is not being freed elsewhere -- the page release
+ * code relies on it.
+ */
+ if (!TestClearPageLRU(page))
+ BUG();
+ list_add(&page->lru, dst);
+ nr_taken++;
}
*scanned = scan;