Skip to contentSkip to conversation

mm-shmem-dont-release-a-swapin-error-marker-as-a-swap-entry.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Oct 13 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/shmem: don't release a swapin-error marker as a swap entry
has been removed from the -mm tree. Its filename was
mm-shmem-dont-release-a-swapin-error-marker-as-a-swap-entry.patch

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

------------------------------------------------------
From: David Carlier <[email protected]>
Subject: mm/shmem: don't release a swapin-error marker as a swap entry
Date: Sun, 20 Sep 2026 16:50:02 +0100

A failed shmem swapin (eg, EIO) frees the swap slot and leaves a PTE_MARKER_POISONED entry in the page cache. On truncate or eviction shmem_free_swap() passes that marker to swap_put_entries_direct(), which warns because it is not a swap entry. There is nothing left to release either way.

Skip the release for non-swap entries, as every other caller already does.

Fixes ac2d3268284b ("mm/swapfile.c: remove the unneeded checking")
Reported-by [email protected]
Cc Baoquan he <[email protected]>
Cc Barry Song <[email protected]>
Cc Chis Li <[email protected]> (Google)
Cc Hugh Dickens <[email protected]>
Cc Kairui Song <[email protected]>
Cc Kemeng Shi <[email protected]>
Cc Nhat Pham <[email protected]>

---

 mm/shmem.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
mm/shmem.c renamed from mm/shmem.c~mm-shmem-dont-release-a-swapin-error-marker-as-a-swap-entry +4 -2
@@ -1184,6 +1184,7 @@ static long shmem_free_swap(struct addre
 			    pgoff_t index, pgoff_t end, void *radswap)
 {
 	XA_STATE(xas, &mapping->i_pages, index);
+	const softleaf_t swp = radix_to_swp_entry(radswap);
 	unsigned int nr_pages = 0;
 	pgoff_t base;
 	void *entry;
@@ -1200,8 +1201,9 @@ static long shmem_free_swap(struct addre
 	}
 	xas_unlock_irq(&xas);
 
-	if (nr_pages)
-		swap_put_entries_direct(radix_to_swp_entry(radswap), nr_pages);
+	/* A swapin-error marker holds no swap slot, so just drop it. */
+	if (nr_pages && softleaf_is_swap(swp))
+		swap_put_entries_direct(swp, nr_pages);
 
 	return nr_pages;
 }

_

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

mm-swap-pm-hibernate-atomically-replace-hibernation-pin.patch