Skip to content

Commit 9a976f0

Browse files
mcgrofakpm00
authored andcommitted
shmem: skip page split if we're not reclaiming
In theory when info->flags & VM_LOCKED we should not be getting shem_writepage() called so we should be verifying this with a WARN_ON_ONCE(). Since we should not be swapping then best to ensure we also don't do the folio split earlier too. So just move the check early to avoid folio splits in case its a dubious call. We also have a similar early bail when !total_swap_pages so just move that earlier to avoid the possible folio split in the same situation. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Luis Chamberlain <[email protected]> Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Reviewed-by: Yosry Ahmed <[email protected]> Tested-by: Xin Hao <[email protected]> Reviewed-by: Davidlohr Bueso <[email protected]> Cc: Adam Manzanares <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Kees Cook <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Pankaj Raghav <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent cf7992b commit 9a976f0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mm/shmem.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,12 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
13471347
if (WARN_ON_ONCE(!wbc->for_reclaim))
13481348
goto redirty;
13491349

1350+
if (WARN_ON_ONCE(info->flags & VM_LOCKED))
1351+
goto redirty;
1352+
1353+
if (!total_swap_pages)
1354+
goto redirty;
1355+
13501356
/*
13511357
* If /sys/kernel/mm/transparent_hugepage/shmem_enabled is "always" or
13521358
* "force", drivers/gpu/drm/i915/gem/i915_gem_shmem.c gets huge pages,
@@ -1362,10 +1368,6 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
13621368
}
13631369

13641370
index = folio->index;
1365-
if (info->flags & VM_LOCKED)
1366-
goto redirty;
1367-
if (!total_swap_pages)
1368-
goto redirty;
13691371

13701372
/*
13711373
* This is somewhat ridiculous, but without plumbing a SWAP_MAP_FALLOC

0 commit comments

Comments
 (0)