From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F36832C9C for ; Tue, 7 Feb 2023 13:06:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AF37C433D2; Tue, 7 Feb 2023 13:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675775195; bh=Fe4pM66UR2F/uBjXDzUQ3X9eZwkv0k/CIZWbTMy8RHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sJeo1YQB/ELCfH+p8Y8FK6bfO2ORzkIIn72p+As03ldiy37qrw5HuZoBB8DHNx8k+ yraP2jUdQ7toUKSshXtZ1joLhNME7MJREYThAqPlghq2ZSapoI2zVQzG8t1kekMdGU 9lZTOF6UX8f66atj58uvz9qg1qWs9ewli3fnLjmA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Longlong Xia , "Huang, Ying" , Chen Wandun , Kefeng Wang , Nanyong Sun , Hugh Dickins , Andrew Morton Subject: [PATCH 6.1 168/208] mm/swapfile: add cond_resched() in get_swap_pages() Date: Tue, 7 Feb 2023 13:57:02 +0100 Message-Id: <20230207125642.021209048@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207125634.292109991@linuxfoundation.org> References: <20230207125634.292109991@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Longlong Xia commit 7717fc1a12f88701573f9ed897cc4f6699c661e3 upstream. The softlockup still occurs in get_swap_pages() under memory pressure. 64 CPU cores, 64GB memory, and 28 zram devices, the disksize of each zram device is 50MB with same priority as si. Use the stress-ng tool to increase memory pressure, causing the system to oom frequently. The plist_for_each_entry_safe() loops in get_swap_pages() could reach tens of thousands of times to find available space (extreme case: cond_resched() is not called in scan_swap_map_slots()). Let's add cond_resched() into get_swap_pages() when failed to find available space to avoid softlockup. Link: https://lkml.kernel.org/r/20230128094757.1060525-1-xialonglong1@huawei.com Signed-off-by: Longlong Xia Reviewed-by: "Huang, Ying" Cc: Chen Wandun Cc: Huang Ying Cc: Kefeng Wang Cc: Nanyong Sun Cc: Hugh Dickins 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 @@ -1101,6 +1101,7 @@ start_over: goto check_out; pr_debug("scan_swap_map of si %d failed to find offset\n", si->type); + cond_resched(); spin_lock(&swap_avail_lock); nextsi: