Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16844
b: refs/heads/master
c: d0d9632
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Jan 9, 2006
1 parent 61f9bf6 commit ac2e7ac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d498471133ff1f9586a06820beaeebc575fe2814
refs/heads/master: d0d963281ccb22e6f339bfdd75c6b2e31351929f
56 changes: 34 additions & 22 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,6 @@ int putback_lru_pages(struct list_head *l)
/*
* swapout a single page
* page is locked upon entry, unlocked on exit
*
* return codes:
* 0 = complete
* 1 = retry
*/
static int swap_page(struct page *page)
{
Expand Down Expand Up @@ -650,7 +646,7 @@ static int swap_page(struct page *page)
unlock_page(page);

retry:
return 1;
return -EAGAIN;
}
/*
* migrate_pages
Expand All @@ -669,6 +665,8 @@ static int swap_page(struct page *page)
* is only swapping out pages and never touches the second
* list. The direct migration patchset
* extends this function to avoid the use of swap.
*
* Return: Number of pages not migrated when "to" ran empty.
*/
int migrate_pages(struct list_head *from, struct list_head *to,
struct list_head *moved, struct list_head *failed)
Expand All @@ -679,6 +677,7 @@ int migrate_pages(struct list_head *from, struct list_head *to,
struct page *page;
struct page *page2;
int swapwrite = current->flags & PF_SWAPWRITE;
int rc;

if (!swapwrite)
current->flags |= PF_SWAPWRITE;
Expand All @@ -689,22 +688,23 @@ int migrate_pages(struct list_head *from, struct list_head *to,
list_for_each_entry_safe(page, page2, from, lru) {
cond_resched();

if (page_count(page) == 1) {
rc = 0;
if (page_count(page) == 1)
/* page was freed from under us. So we are done. */
list_move(&page->lru, moved);
continue;
}
goto next;

/*
* Skip locked pages during the first two passes to give the
* functions holding the lock time to release the page. Later we
* use lock_page() to have a higher chance of acquiring the
* lock.
*/
rc = -EAGAIN;
if (pass > 2)
lock_page(page);
else
if (TestSetPageLocked(page))
goto retry_later;
goto next;

/*
* Only wait on writeback if we have already done a pass where
Expand All @@ -713,31 +713,43 @@ int migrate_pages(struct list_head *from, struct list_head *to,
if (pass > 0) {
wait_on_page_writeback(page);
} else {
if (PageWriteback(page)) {
unlock_page(page);
goto retry_later;
}
if (PageWriteback(page))
goto unlock_page;
}

/*
* Anonymous pages must have swap cache references otherwise
* the information contained in the page maps cannot be
* preserved.
*/
if (PageAnon(page) && !PageSwapCache(page)) {
if (!add_to_swap(page, GFP_KERNEL)) {
unlock_page(page);
list_move(&page->lru, failed);
nr_failed++;
continue;
rc = -ENOMEM;
goto unlock_page;
}
}

/*
* Page is properly locked and writeback is complete.
* Try to migrate the page.
*/
if (!swap_page(page)) {
rc = swap_page(page);
goto next;

unlock_page:
unlock_page(page);

next:
if (rc == -EAGAIN) {
retry++;
} else if (rc) {
/* Permanent failure */
list_move(&page->lru, failed);
nr_failed++;
} else {
/* Success */
list_move(&page->lru, moved);
continue;
}
retry_later:
retry++;
}
if (retry && pass++ < 10)
goto redo;
Expand Down

0 comments on commit ac2e7ac

Please sign in to comment.