[merged mm-stable] mm-swap-clarify-unreachable-cond_resched-in-swap_reclaim_full_clusters.patch removed from -mm tree
Andrew Morton <[email protected]>
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The quilt patch titled
Subject: mm/swap: clarify unreachable cond_resched() in swap_reclaim_full_clusters
has been removed from the -mm tree. Its filename was
mm-swap-clarify-unreachable-cond_resched-in-swap_reclaim_full_clusters.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: Youngjun Park <[email protected]>
Subject: mm/swap: clarify unreachable cond_resched() in swap_reclaim_full_clusters
Date: Mon, 13 Jul 2026 13:50:14 +0900
Commit 66366d291f66 ("mm/swap: add cond_resched() in
swap_reclaim_full_clusters to prevent softlockup") added cond_resched() to
prevent soft lockups during heavy swap reclaim.
Currently, there are two call sites for this function:
1. swap_reclaim_work(): called with force=true in a workqueue context.
2. cluster_alloc_swap_entry(): called with force=false, holding a
local_lock and potentially a global cluster spinlock (atomic context).
In the second case, calling cond_resched() would normally cause a
"scheduling while atomic" bug. However, it is currently safe because when
force=false, 'to_scan' is initialized to 1. The loop decrements it to 0
and breaks before ever reaching cond_resched().
This implicit dependency is hard to notice and recently triggered a false
positive in AI Sashiko review.
Add a comment to explicitly clarify that cond_resched() is unreachable in
atomic contexts. This improves readability and prevents future misuse if
the loop logic or 'to_scan' initialization is modified.
Link: https://sashiko.dev/#/patchset/[email protected]?part=4
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Youngjun Park <[email protected]>
Cc: Baoquan He <[email protected]>
Cc: Barry Song <[email protected]>
Cc: Chris Li <[email protected]>
Cc: Kairui Song <[email protected]>
Cc: Kemeng Shi <[email protected]>
Cc: Nhat Pham <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
mm/swapfile.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/mm/swapfile.c~mm-swap-clarify-unreachable-cond_resched-in-swap_reclaim_full_clusters
+++ a/mm/swapfile.c
@@ -1072,6 +1072,12 @@ static void swap_reclaim_full_clusters(s
swap_cluster_unlock(ci);
if (to_scan <= 0)
break;
+
+ /*
+ * When 'force' is false, 'to_scan' is initialized to 1.
+ * The loop breaks above, making this cond_resched() unreachable
+ * in atomic contexts.
+ */
cond_resched();
}
}
_
Patches currently in -mm which might be from [email protected] are