Commit f8020772 authored by Minchan Kim's avatar Minchan Kim Committed by Linus Torvalds
Browse files

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 0bcac06f ("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

This patch fixes it.

Debugged by James Bottomley.


Signed-off-by: default avatarMinchan Kim <>
Reported-by: default avatarJames Bottomley <>
Acked-by: default avatarHugh Dickins <>
Cc: Sergey Senozhatsky <>
Cc: Huang Ying <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent dda3e152
......@@ -2857,8 +2857,11 @@ int do_swap_page(struct vm_fault *vmf)
int ret = 0;
bool vma_readahead = swap_use_vma_readahead();
if (vma_readahead)
if (vma_readahead) {
page = swap_readahead_detect(vmf, &swap_ra);
swapcache = page;
if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) {
if (page)
......@@ -2889,9 +2892,12 @@ int do_swap_page(struct vm_fault *vmf)
if (!page)
if (!page) {
page = lookup_swap_cache(entry, vma_readahead ? vma : NULL,
swapcache = page;
if (!page) {
struct swap_info_struct *si = swp_swap_info(entry);
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