This is a note to let you know that I've just added the patch titled Revert "swap: fix do_swap_page() race with swapoff" to the 5.13-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: revert-swap-fix-do_swap_page-race-with-swapoff.patch and it can be found in the queue-5.13 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 4b8817e8e7b08c494784eb7116e5aa1beb492a5f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Date: Thu, 22 Jul 2021 15:43:47 +0200 Subject: Revert "swap: fix do_swap_page() race with swapoff" From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> This reverts commit c3b39134bbd088b7dce5e5f342ccd6bb9142fd18 which is commit 2799e77529c2a25492a4395db93996e3dacd762d upstream. It should not have been added to the stable trees, sorry about that. Link: https://lore.kernel.org/r/YPVgaY6uw59Fqg5x@xxxxxxxxxxxxxxxxxxxx Reported-by: From: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Miaohe Lin <linmiaohe@xxxxxxxxxx> Cc: Ying Huang <ying.huang@xxxxxxxxx> Cc: Alex Shi <alexs@xxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Dennis Zhou <dennis@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx> Cc: Wei Yang <richard.weiyang@xxxxxxxxx> Cc: Yang Shi <shy828301@xxxxxxxxx> Cc: Yu Zhao <yuzhao@xxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Cc: Sasha Levin <sashal@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- include/linux/swap.h | 9 --------- mm/memory.c | 11 ++--------- 2 files changed, 2 insertions(+), 18 deletions(-) --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -526,15 +526,6 @@ static inline struct swap_info_struct *s return NULL; } -static inline struct swap_info_struct *get_swap_device(swp_entry_t entry) -{ - return NULL; -} - -static inline void put_swap_device(struct swap_info_struct *si) -{ -} - #define swap_address_space(entry) (NULL) #define get_nr_swap_pages() 0L #define total_swap_pages 0L --- a/mm/memory.c +++ b/mm/memory.c @@ -3353,7 +3353,6 @@ vm_fault_t do_swap_page(struct vm_fault { struct vm_area_struct *vma = vmf->vma; struct page *page = NULL, *swapcache; - struct swap_info_struct *si = NULL; swp_entry_t entry; pte_t pte; int locked; @@ -3381,16 +3380,14 @@ vm_fault_t do_swap_page(struct vm_fault goto out; } - /* Prevent swapoff from happening to us. */ - si = get_swap_device(entry); - if (unlikely(!si)) - goto out; delayacct_set_flag(current, DELAYACCT_PF_SWAPIN); page = lookup_swap_cache(entry, vma, vmf->address); swapcache = page; if (!page) { + struct swap_info_struct *si = swp_swap_info(entry); + if (data_race(si->flags & SWP_SYNCHRONOUS_IO) && __swap_count(entry) == 1) { /* skip swapcache */ @@ -3559,8 +3556,6 @@ vm_fault_t do_swap_page(struct vm_fault unlock: pte_unmap_unlock(vmf->pte, vmf->ptl); out: - if (si) - put_swap_device(si); return ret; out_nomap: pte_unmap_unlock(vmf->pte, vmf->ptl); @@ -3572,8 +3567,6 @@ out_release: unlock_page(swapcache); put_page(swapcache); } - if (si) - put_swap_device(si); return ret; } Patches currently in stable-queue which might be from gregkh@xxxxxxxxxxxxxxxxxxx are queue-5.13/revert-swap-fix-do_swap_page-race-with-swapoff.patch queue-5.13/revert-mm-shmem-fix-shmem_swapin-race-with-swapoff.patch