[PATCH] grab swap token reordered

Make sure the contention for the token happens _before_ any read-in and
kicks the swap-token algo only when the VM is under pressure.

Signed-off-by: Ashwin Chaugule <ashwin.chaugule@celunite.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Ashwin Chaugule 2006-12-06 20:31:54 -08:00 committed by Linus Torvalds
parent cd54e7e543
commit 098fe651f7
2 changed files with 1 additions and 2 deletions

View File

@ -1445,7 +1445,6 @@ no_cached_page:
* effect. * effect.
*/ */
error = page_cache_read(file, pgoff); error = page_cache_read(file, pgoff);
grab_swap_token();
/* /*
* The page we want has now been added to the page cache. * The page we want has now been added to the page cache.

View File

@ -1991,6 +1991,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
delayacct_set_flag(DELAYACCT_PF_SWAPIN); delayacct_set_flag(DELAYACCT_PF_SWAPIN);
page = lookup_swap_cache(entry); page = lookup_swap_cache(entry);
if (!page) { if (!page) {
grab_swap_token(); /* Contend for token _before_ read-in */
swapin_readahead(entry, address, vma); swapin_readahead(entry, address, vma);
page = read_swap_cache_async(entry, vma, address); page = read_swap_cache_async(entry, vma, address);
if (!page) { if (!page) {
@ -2008,7 +2009,6 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
/* Had to read the page from swap area: Major fault */ /* Had to read the page from swap area: Major fault */
ret = VM_FAULT_MAJOR; ret = VM_FAULT_MAJOR;
count_vm_event(PGMAJFAULT); count_vm_event(PGMAJFAULT);
grab_swap_token();
} }
delayacct_clear_flag(DELAYACCT_PF_SWAPIN); delayacct_clear_flag(DELAYACCT_PF_SWAPIN);