Skip to content

Commit 098fe65

Browse files
Ashwin ChauguleLinus Torvalds
authored andcommitted
[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 <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Peter Zijlstra <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent cd54e7e commit 098fe65

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

mm/filemap.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,6 @@ struct page *filemap_nopage(struct vm_area_struct *area,
14451445
* effect.
14461446
*/
14471447
error = page_cache_read(file, pgoff);
1448-
grab_swap_token();
14491448

14501449
/*
14511450
* The page we want has now been added to the page cache.

mm/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
19911991
delayacct_set_flag(DELAYACCT_PF_SWAPIN);
19921992
page = lookup_swap_cache(entry);
19931993
if (!page) {
1994+
grab_swap_token(); /* Contend for token _before_ read-in */
19941995
swapin_readahead(entry, address, vma);
19951996
page = read_swap_cache_async(entry, vma, address);
19961997
if (!page) {
@@ -2008,7 +2009,6 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
20082009
/* Had to read the page from swap area: Major fault */
20092010
ret = VM_FAULT_MAJOR;
20102011
count_vm_event(PGMAJFAULT);
2011-
grab_swap_token();
20122012
}
20132013

20142014
delayacct_clear_flag(DELAYACCT_PF_SWAPIN);

0 commit comments

Comments
 (0)