Skip to content

Commit f802077

Browse files
minchanktorvalds
authored andcommitted
mm/memory.c: release locked page in do_swap_page()
James reported a bug in swap paging-in from his testing. It is that do_swap_page doesn't release locked page so system hang-up happens due to a deadlock on PG_locked. It was introduced by 0bcac06 ("mm, swap: skip swapcache for swapin of synchronous device") because I missed swap cache hit places to update swapcache variable to work well with other logics against swapcache in do_swap_page. This patch fixes it. Debugged by James Bottomley. Link: http://lkml.kernel.org/r/<[email protected]> Link: http://lkml.kernel.org/r/20180102235606.GA19438@bbox Signed-off-by: Minchan Kim <[email protected]> Reported-by: James Bottomley <[email protected]> Acked-by: Hugh Dickins <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Huang Ying <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent dda3e15 commit f802077

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mm/memory.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,8 +2857,11 @@ int do_swap_page(struct vm_fault *vmf)
28572857
int ret = 0;
28582858
bool vma_readahead = swap_use_vma_readahead();
28592859

2860-
if (vma_readahead)
2860+
if (vma_readahead) {
28612861
page = swap_readahead_detect(vmf, &swap_ra);
2862+
swapcache = page;
2863+
}
2864+
28622865
if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) {
28632866
if (page)
28642867
put_page(page);
@@ -2889,9 +2892,12 @@ int do_swap_page(struct vm_fault *vmf)
28892892

28902893

28912894
delayacct_set_flag(DELAYACCT_PF_SWAPIN);
2892-
if (!page)
2895+
if (!page) {
28932896
page = lookup_swap_cache(entry, vma_readahead ? vma : NULL,
28942897
vmf->address);
2898+
swapcache = page;
2899+
}
2900+
28952901
if (!page) {
28962902
struct swap_info_struct *si = swp_swap_info(entry);
28972903

0 commit comments

Comments
 (0)