From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60B0C3D8127; Thu, 16 Jul 2026 14:06:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784210819; cv=none; b=pR3TmAlOgJpFzBYR56oAGgcrk1x6C3/G50jlKQyrf0qlFOvVhilW3gqAiNh+oabBBtojt5hUM3aPjKBTh7K1peemiVspq5MkneHPqGlkQ/UXtQiXgVY4UnArJNXjxmybypw/vsiWv9sLY3udGHiw+Q37gNn8yg3LjnT2LGvasZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784210819; c=relaxed/simple; bh=xRECUFdPOJrl1GjCcfitiXXE2gLRGA9sNuhDfVz23Vs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bhTQrK3MX5yXUfiNbuFX51badpdzVnAjZyrZnLZZWeTPtFQt2ckmiOIG5OaKgbRIqDbQjn4biBjN+jK0yZOZBI+2YXZvu0dN13Wg6b51mtoLvEqo5JRkmP35BNlebEv14y/8BHVCsEAvL4R3/Qg7llUQzpAhX+skIil4Tj9oix4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qRhLXJUd; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qRhLXJUd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86F1F1F000E9; Thu, 16 Jul 2026 14:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784210818; bh=3oRNChnFbC2AstULVyue07wcze6LpT60xdqwhuSmDBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qRhLXJUd3dimRPsv75hZyyfyCHJGzwwgrmbAZmWtWdpCjXiDECpNDDkF9ue6JwWsi xm3kdFBO7IFd5cZmAlBy56UkEn3hMqMh4A5FY8zc3n5rME8Ipnd1LwtvolQKuWeovP 0TDZt9Czh+PvQuIHBTgiYDEayNQ36LrfRUd8caJc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zijiang Huang , Kairui Song , Hao Peng , albinwyang , Baoquan He , Chris Li , Barry Song , Kemeng Shi , Nhat Pham , Youngjun Park , Andrew Morton Subject: [PATCH 6.18 193/480] mm/swap: add cond_resched() in swap_reclaim_full_clusters to prevent softlockup Date: Thu, 16 Jul 2026 15:29:00 +0200 Message-ID: <20260716133048.903222803@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133044.672218725@linuxfoundation.org> References: <20260716133044.672218725@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zijiang Huang commit 66366d291f666ddeda5f8c84f253e308de3e6b55 upstream. We hit a real softlockup in an internal stress test environment. The workload was LTP memory/swap stress on a large arm64 machine, with 320 CPUs, about 1TB memory and an 8.6GB swap device. The system was under heavy load and the swap device had a large number of full clusters. The softlockup was triggered during a stress test after about 3 days. So, add periodic cond_resched() calls during large full_clusters reclaim operations to prevent softlockup issues. Detailed call trace as follow: PID: 3817773 TASK: ffff0883bb28b780 CPU: 48 COMMAND: "kworker/48:7" #0 [ffff800080183d10] __crash_kexec at ffffa4c1361e5de4 #1 [ffff800080183d90] panic at ffffa4c1360d5e9c #2 [ffff800080183e20] watchdog_timer_fn at ffffa4c136231fa8 ... #16 [ffff8000c4ad3cb0] swap_cache_del_folio at ffffa4c1363e1614 #17 [ffff8000c4ad3ce0] __try_to_reclaim_swap at ffffa4c1363e4bfc #18 [ffff8000c4ad3d40] swap_reclaim_full_clusters at ffffa4c1363e5474 #19 [ffff8000c4ad3da0] swap_reclaim_work at ffffa4c1363e550c #20 [ffff8000c4ad3dc0] process_one_work at ffffa4c136102edc #21 [ffff8000c4ad3e10] worker_thread at ffffa4c136103398 #22 [ffff8000c4ad3e70] kthread at ffffa4c13610d95c Link: https://lore.kernel.org/20260506130919.2298807-1-kerayhuang@tencent.com Fixes: 5168a68eb78f ("mm, swap: avoid over reclaim of full clusters") Signed-off-by: Zijiang Huang Reviewed-by: Kairui Song Reviewed-by: Hao Peng Reviewed-by: albinwyang Reviewed-by: Baoquan He Acked-by: Chris Li Cc: Barry Song Cc: Kairui Song Cc: Kemeng Shi Cc: Nhat Pham Cc: Youngjun Park Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/swapfile.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1008,6 +1008,7 @@ static void swap_reclaim_full_clusters(s swap_cluster_unlock(ci); if (to_scan <= 0) break; + cond_resched(); } }