Commit 0ee29e60 authored by Andrew Morton's avatar Andrew Morton Committed by Oleg Drokin

[PATCH] Fix a BUG in try_to_unmap()

try_to_unmap() dies if the to-be-unmapped page has a non-NULL ->mapping.

But the preceding logic in shrink_cache() forgot about the
rarely-occurring pages which have buffers and no ->mapping.
parent 891975a1
......@@ -132,13 +132,15 @@ shrink_list(struct list_head *page_list, int nr_pages, zone_t *classzone,
goto activate_locked;
}
mapping = page->mapping;
/*
* Anonymous process memory without backing store. Try to
* allocate it some swap space here.
*
* XXX: implement swap clustering ?
*/
if (page->pte.chain && !page->mapping && !PagePrivate(page)) {
if (page->pte.chain && !mapping && !PagePrivate(page)) {
pte_chain_unlock(page);
if (!add_to_swap(page))
goto activate_locked;
......@@ -149,7 +151,7 @@ shrink_list(struct list_head *page_list, int nr_pages, zone_t *classzone,
* The page is mapped into the page tables of one or more
* processes. Try to unmap it here.
*/
if (page->pte.chain) {
if (page->pte.chain && mapping) {
switch (try_to_unmap(page)) {
case SWAP_ERROR:
case SWAP_FAIL:
......@@ -163,7 +165,6 @@ shrink_list(struct list_head *page_list, int nr_pages, zone_t *classzone,
}
}
pte_chain_unlock(page);
mapping = page->mapping;
/*
* FIXME: this is CPU-inefficient for shared mappings.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment