[RFC PATCH 2/8] mm: vmscan: add validation before spliting shmem large folio

From: Baolin Wang
Date: Tue May 21 2024 - 07:03:50 EST


Add swap available space validation before spliting shmem large folio to
avoid redundant split, since we can not write shmem folio to the swap device
in this case.

Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
---
mm/vmscan.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6981a71c8ef0..bf11c0cbf12e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1252,6 +1252,14 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
}
} else if (folio_test_swapbacked(folio) &&
folio_test_large(folio)) {
+
+ /*
+ * Do not split shmem folio if no swap memory
+ * available.
+ */
+ if (!total_swap_pages)
+ goto activate_locked;
+
/* Split shmem folio */
if (split_folio_to_list(folio, folio_list))
goto keep_locked;
--
2.39.3