Skip to contentSkip to conversation

mm-swap-fix-false-warning-for-large-allocation-with-thp_swap.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message May 8, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm, swap: fix false warning for large allocation with !THP_SWAP
has been removed from the -mm tree. Its filename was
mm-swap-fix-false-warning-for-large-allocation-with-thp_swap.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Kairui Song <[email protected]>
Subject: mm, swap: fix false warning for large allocation with !THP_SWAP
Date: Tue, 29 Apr 2025 17:48:03 +0800

The !CONFIG_THP_SWAP check existed before just fine because slot cache would reject high order allocation and let the caller split all folios and try again.

But slot cache is gone, so large allocation will directly go to the allocator, and the allocator should just fail silently to inform caller to do the folio split, this is totally fine and expected.

Remove this meaningless warning.

---

 mm/swapfile.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
mm/swapfile.c renamed from mm/swapfile.c~mm-swap-fix-false-warning-for-large-allocation-with-thp_swap +16 -7
@@ -1272,13 +1272,22 @@ int folio_alloc_swap(struct folio *folio
 	VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
 	VM_BUG_ON_FOLIO(!folio_test_uptodate(folio), folio);
 
-	/*
-	 * Should not even be attempting large allocations when huge
-	 * page swap is disabled. Warn and fail the allocation.
-	 */
-	if (order && (!IS_ENABLED(CONFIG_THP_SWAP) || size > SWAPFILE_CLUSTER)) {
-		VM_WARN_ON_ONCE(1);
-		return -EINVAL;
+	if (order) {
+		/*
+		 * Reject large allocation when THP_SWAP is disabled,
+		 * the caller should split the folio and try again.
+		 */
+		if (!IS_ENABLED(CONFIG_THP_SWAP))
+			return -EAGAIN;
+
+		/*
+		 * Allocation size should never exceed cluster size
+		 * (HPAGE_PMD_SIZE).
+		 */
+		if (size > SWAPFILE_CLUSTER) {
+			VM_WARN_ON_ONCE(1);
+			return -EINVAL;
+		}
 	}
 
 	local_lock(&percpu_swap_cluster.lock);

_

Patches currently in -mm which might be from [email protected] are

mm-memory-fix-mapcount-refcount-sanity-check-for-mthp-reuse.patch fuse-drop-usage-of-folio_index.patch btrfs-drop-usage-of-folio_index.patch f2fs-drop-usage-of-folio_index.patch filemap-do-not-use-folio_contains-for-swap-cache-folios.patch mm-move-folio_index-to-mm-swaph-and-remove-no-longer-needed-helper.patch mm-swap-remove-no-longer-used-swap-mapping-helper.patch