diff mbox series

[1/7] mm: vmscan: add validation before spliting shmem large folio

Message ID 3516f4ff0242c48ad0fa000d50ac382817776be1.1717673614.git.baolin.wang@linux.alibaba.com (mailing list archive)
State New
Headers show
Series support large folio swap-out and swap-in for shmem | expand

Commit Message

Baolin Wang June 6, 2024, 11:58 a.m. UTC
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@linux.alibaba.com>
---
 mm/vmscan.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index c0429fd6c573..9146fd0dc61e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1255,6 +1255,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;