Skip to content

Commit 498c48c

Browse files
ryncsnakpm00
authored andcommitted
mm, swap: fix reclaim offset calculation error during allocation
There is a code error that will cause the swap entry allocator to reclaim and check the whole cluster with an unexpected tail offset instead of the part that needs to be reclaimed. This may cause corruption of the swap map, so fix it. Link: https://lkml.kernel.org/r/20250130115131.37777-1-ryncsn@gmail.com Fixes: 3b64477 ("mm, swap: reduce contention on device lock") Signed-off-by: Kairui Song <kasong@tencent.com> Cc: Chris Li <chrisl@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1ccae30 commit 498c48c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/swapfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ static unsigned int alloc_swap_scan_cluster(struct swap_info_struct *si,
794794
if (!cluster_scan_range(si, ci, offset, nr_pages, &need_reclaim))
795795
continue;
796796
if (need_reclaim) {
797-
ret = cluster_reclaim_range(si, ci, start, end);
797+
ret = cluster_reclaim_range(si, ci, offset, offset + nr_pages);
798798
/*
799799
* Reclaim drops ci->lock and cluster could be used
800800
* by another order. Not checking flag as off-list

0 commit comments

Comments
 (0)