Commit 9b7187ff authored by Rik van Riel's avatar Rik van Riel Committed by Linus Torvalds

[PATCH] rmap bugfix, try_to_unmap

The following patch corrects a bug where rmap would continue trying to
swap out a page even after it failed on one pte, which could result in
leaked pte chains and a bug when exiting applications which use mlock().

The bug was tracked down by Christian Ehrhardt, the reason it wasn't
found earlier was a subtlety in the code, so I've taken the liberty of
changing Christian's patch into something more explicit, we shouldn't
let this one happen again ;)
parent e9ea9aac
...@@ -328,7 +328,7 @@ int try_to_unmap(struct page * page) ...@@ -328,7 +328,7 @@ int try_to_unmap(struct page * page)
case SWAP_SUCCESS: case SWAP_SUCCESS:
/* Free the pte_chain struct. */ /* Free the pte_chain struct. */
pte_chain_free(pc, prev_pc, page); pte_chain_free(pc, prev_pc, page);
break; continue;
case SWAP_AGAIN: case SWAP_AGAIN:
/* Skip this pte, remembering status. */ /* Skip this pte, remembering status. */
prev_pc = pc; prev_pc = pc;
...@@ -336,12 +336,13 @@ int try_to_unmap(struct page * page) ...@@ -336,12 +336,13 @@ int try_to_unmap(struct page * page)
continue; continue;
case SWAP_FAIL: case SWAP_FAIL:
ret = SWAP_FAIL; ret = SWAP_FAIL;
break; goto give_up;
case SWAP_ERROR: case SWAP_ERROR:
ret = SWAP_ERROR; ret = SWAP_ERROR;
break; goto give_up;
} }
} }
give_up:
/* Check whether we can convert to direct pte pointer */ /* Check whether we can convert to direct pte pointer */
pc = page->pte.chain; pc = page->pte.chain;
if (pc && !pc->next) { if (pc && !pc->next) {
......
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