• Hugh Dickins's avatar
    [PATCH] swapoff mmap_sem deadlock · b7ae29f5
    Hugh Dickins authored
    Updating the mm lock ordering documentation drew attention to the fact that
    we were wrong to blithely add down_read(&mm->mmap_sem) to swapoff's
    unuse_process, while it holds swapcache page lock: not very likely, but it
    could deadlock against, say, mlock faulting a page back in from swap.
    
    But it looks like these days it's safe to drop and reacquire page lock if
    down_read_trylock fails: the page lock is held to stop try_to_unmap
    unmapping the page's ptes as fast as try_to_unuse is mapping them back in;
    but the recent fix for get_user_pages works to prevent that too.
    Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    b7ae29f5
rmap.c 20.3 KB