Skip to content

Commit

Permalink
MM: reclaim mustn't enter FS for swap-over-NFS
Browse files Browse the repository at this point in the history
If swap-out is using filesystem operations (SWP_FS_OPS), then it is not
safe to enter the FS for reclaim.
So only down-grade the requirement for swap pages to __GFP_IO after
checking that SWP_FS_OPS are not being used.

Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
neilbrown authored and intel-lab-lkp committed Nov 16, 2021
1 parent dbadec8 commit b2f1d12
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mm/vmscan.c
Expand Up @@ -1513,8 +1513,14 @@ static unsigned int shrink_page_list(struct list_head *page_list,
if (!sc->may_unmap && page_mapped(page))
goto keep_locked;

/* ->flags can be updated non-atomicially (scan_swap_map_slots),
* but that will never affect SWP_FS_OPS, so the data_race
* is safe.
*/
may_enter_fs = (sc->gfp_mask & __GFP_FS) ||
(PageSwapCache(page) && (sc->gfp_mask & __GFP_IO));
(PageSwapCache(page) &&
!data_race(page_swap_info(page)->flags & SWP_FS_OPS) &&
(sc->gfp_mask & __GFP_IO));

/*
* The number of dirty pages determines if a node is marked
Expand Down Expand Up @@ -1682,7 +1688,9 @@ static unsigned int shrink_page_list(struct list_head *page_list,
goto activate_locked_split;
}

may_enter_fs = true;
if ((sc->gfp_mask & __GFP_FS) ||
!data_race(page_swap_info(page)->flags & SWP_FS_OPS))
may_enter_fs = true;

/* Adding to swap updated mapping */
mapping = page_mapping(page);
Expand Down

0 comments on commit b2f1d12

Please sign in to comment.