]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm: swap: add back full cluster when no entry is reclaimed
authorKemeng Shi <shikemeng@huaweicloud.com>
Mon, 24 Feb 2025 11:39:10 +0000 (19:39 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 6 Mar 2025 05:36:15 +0000 (21:36 -0800)
If no swap cache is reclaimed, cluster taken off from full_clusters list
will not be put in any list and we can't reclaime HAS_CACHE slots
efficiently.  Do relocate_cluster for such cluster to avoid inefficiency.

Link: https://lkml.kernel.org/r/20250224113910.522439-1-shikemeng@huaweicloud.com
Fixes: 3b644773eefd ("mm, swap: reduce contention on device lock")
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Kairui Song <kasong@tencent.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/swapfile.c

index fab99d67026aa3f0d804f75ab9eb1f6071dfd21a..a6c41c7ffb0370f6a54b7d92e7166811ca937762 100644 (file)
@@ -858,6 +858,10 @@ static void swap_reclaim_full_clusters(struct swap_info_struct *si, bool force)
                        offset++;
                }
 
+               /* in case no swap cache is reclaimed */
+               if (ci->flags == CLUSTER_FLAG_NONE)
+                       relocate_cluster(si, ci);
+
                unlock_cluster(ci);
                if (to_scan <= 0)
                        break;