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 3551C63B8 for ; Mon, 20 Feb 2023 13:41:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF04DC433D2; Mon, 20 Feb 2023 13:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676900469; bh=SlWbWYmZrh8aoyJUtEFNBlHGe6+Dr9Rir8DfE20T9F0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wgbaufz++OvLrwMX4uwTHI4WC3gU6ZduEdXaRSndAXGdK5CnHLPUpRIBldGkAj4oA BFJ1fvo3ao2KvzZIL6eNoBJy4eJ61D601OsQhpfsbjJHkrWl2m5Ol9CiZWHhXETTER byGxoHSqfqonQCE2c1dg3Fq2bd0ez1YIaWkx4IvE= 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 4.19 37/89] mm/swapfile: add cond_resched() in get_swap_pages() Date: Mon, 20 Feb 2023 14:35:36 +0100 Message-Id: <20230220133554.451302667@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230220133553.066768704@linuxfoundation.org> References: <20230220133553.066768704@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 @@ -1008,6 +1008,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: