[PATCH v2 0/2] mm/swap: enhance swap cluster allocation checks
From: Hui Zhu
Date: Mon Mar 09 2026 - 04:10:56 EST
From: Hui Zhu <zhuhui@xxxxxxxxxx>
This series enhances safety and debugging for swap cluster allocation
paths in mm/swapfile.c.
Patch 1 adds a VM_WARN_ON in isolate_lock_cluster() to verify that
full clusters (which should already have allocated tables) are not
processed by swap_cluster_alloc_table().
Patch 2 adds lockdep_assert_held for si->global_cluster_lock on non-SSD
devices and adjusts the assertion order to match the actual lock
acquisition sequence.
Changelog:
v2:
According to the comments of YoungJun Park, Kairui Song and Chris Li,
change acquire locks in swap_reclaim_work() to adds a VM_WARN_ON in
isolate_lock_cluster().
According to the comments of YoungJun Park, add code in patch 2 to Change
the order of lockdep_assert_held() to match the actual lock acquisition
order.
Hui Zhu (2):
mm/swap: Add VM_WARN_ON to isolate_lock_cluster()
mm/swap: Add lockdep for si->global_cluster_lock in
swap_cluster_alloc_table()
mm/swapfile.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--
2.43.0