From nobody Thu Sep 18 15:37:45 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B19BC4321E for ; Mon, 5 Dec 2022 13:49:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbiLENtZ (ORCPT ); Mon, 5 Dec 2022 08:49:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiLENtX (ORCPT ); Mon, 5 Dec 2022 08:49:23 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6C9F11813 for ; Mon, 5 Dec 2022 05:49:22 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NQlJ02rFVzRpl4; Mon, 5 Dec 2022 21:48:32 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 5 Dec 2022 21:49:20 +0800 From: Kefeng Wang To: Andrew Morton , , CC: , Kefeng Wang Subject: [PATCH] mm: add cond_resched() in swapin_walk_pmd_entry() Date: Mon, 5 Dec 2022 22:03:27 +0800 Message-ID: <20221205140327.72304-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When handle MADV_WILLNEED in madvise(), the soflockup may be occurred in swapin_walk_pmd_entry() if swapin lots of memory on slow device, add a cond_resched() into it to avoid the possible softlockup. Fixes: 1998cc048901 ("mm: make madvise(MADV_WILLNEED) support swap file pre= fetch") Signed-off-by: Kefeng Wang --- mm/madvise.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/madvise.c b/mm/madvise.c index b913ba6efc10..fea589d8a2fb 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -226,6 +226,7 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned l= ong start, put_page(page); } swap_read_unplug(splug); + cond_resched(); =20 return 0; } --=20 2.35.3