Hi all, When I was investigating the swap code, I found some possible race windows. This series aims to fix all these races. But using current get/put_swap_device() to guard against concurrent swapoff for swap_readpage() looks terrible because swap_readpage() may take really long time. And to reduce the performance overhead on the hot-path as much as possible, it appears we can use the percpu_ref to close this race window(as suggested by Huang, Ying). The patch 1 adds percpu_ref support for swap and the rest of the patches use this to close various race windows. More details can be found in the respective changelogs. Thanks! Miaohe Lin (5): mm/swapfile: add percpu_ref support for swap swap: fix do_swap_page() race with swapoff mm/swap_state: fix get_shadow_from_swap_cache() race with swapoff mm/swap_state: fix potential faulted in race in swap_ra_info() mm/swap_state: fix swap_cluster_readahead() race with swapoff include/linux/swap.h | 4 +++- mm/memory.c | 10 +++++++++ mm/swap_state.c | 33 +++++++++++++++++++++-------- mm/swapfile.c | 50 +++++++++++++++++++++++++++----------------- 4 files changed, 68 insertions(+), 29 deletions(-) -- 2.19.1