[PATCH v2 4/4] mm, swap: drop the swap cache guard and reclaim in swap_free_hibernation_slot()

From: Youngjun Park

Date: Sun Aug 09 2026 - 10:47:16 EST


Both are there for a folio that readahead might have put on the slot. A
hibernation entry is not a shadow and has no swap count, so the swap cache
turns it away and no such folio can exist.

Signed-off-by: Youngjun Park <youngjun.park@xxxxxxx>
---
mm/swapfile.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index a337387f7431..4fba1770ce61 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2203,18 +2203,8 @@ void swap_free_hibernation_slot(swp_entry_t entry)
pgoff_t offset = swp_offset(entry);

ci = swap_cluster_lock(si, offset);
- /*
- * A slot with a folio in the swap cache is freed when the folio
- * leaves the cache, the same rule swap_put_entries_cluster() follows.
- * Readahead can put a folio here, and freeing the slot now would
- * leave that folio with no entry behind it.
- */
- if (!swp_tb_is_folio(__swap_table_get(ci, offset % SWAPFILE_CLUSTER)))
- __swap_cluster_free_entries(si, ci, offset % SWAPFILE_CLUSTER, 1);
+ __swap_cluster_free_entries(si, ci, offset % SWAPFILE_CLUSTER, 1);
swap_cluster_unlock(ci);
-
- /* In theory readahead might add it to the swap cache by accident */
- __try_to_reclaim_swap(si, offset, TTRS_ANYWAY);
}

static int __find_hibernation_swap_type(dev_t device, sector_t offset)
--
2.48.1