From patchwork Mon Dec 5 14:03:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13064535 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40EB2C4321E for ; Mon, 5 Dec 2022 13:54:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 575458E0002; Mon, 5 Dec 2022 08:54:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5257E8E0001; Mon, 5 Dec 2022 08:54:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EDD48E0002; Mon, 5 Dec 2022 08:54:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 317458E0001 for ; Mon, 5 Dec 2022 08:54:34 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F2EE114095E for ; Mon, 5 Dec 2022 13:54:33 +0000 (UTC) X-FDA: 80208397626.05.A3D3ECF Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf24.hostedemail.com (Postfix) with ESMTP id 7388A180009 for ; Mon, 5 Dec 2022 13:54:31 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670248473; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=Zx8ryHtLNfgNEld6vz5aC14DFYoVAPc/4p+ocezuNVM=; b=aKSciddfEEXmeSntDaFEL0kw3kG6XXNBrFphZss9BYeNH5Qi94JydVP9nlIkFr1Q+1bJaL FVQ2UQYWOWcy06k88XqUU3sDvhX93b6+z98RrMGSNsW1H5s3HZoLUvn4nsPC6NdYFmJjc4 Ijag/jUJ1PsyuSQI/RlTbE70UYdh8EE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670248473; a=rsa-sha256; cv=none; b=2gChESQrMEiFlkejRCxmpmiKJdgmL7Mt707S6V8KpH7RA4WqgM+S9h7k4j0TniwBbHpK+w 0YPaAI85lzid0Rijiw4bsRuUHFYhmm9vVvLXC8wjCRIRBvYvdJ6mDLoZn+/6QXcapihoHO EWRc3Cwwh51K/3ZTYkZS4i6UKDDkDbc= 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 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 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7388A180009 X-Stat-Signature: ew4fswu8xm3sxukmxm89yq3ywqxqcn36 X-Spamd-Result: default: False [2.51 / 9.00]; R_MISSING_CHARSET(2.50)[]; BAYES_HAM(-1.29)[82.50%]; MID_CONTAINS_FROM(1.00)[]; SUBJECT_HAS_UNDERSCORES(1.00)[]; DMARC_POLICY_ALLOW(-0.50)[huawei.com,quarantine]; R_SPF_ALLOW(-0.20)[+ip4:45.249.212.187/29]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; MIME_TRACE(0.00)[0:+]; HAS_XOIP(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[] X-Rspam-User: X-HE-Tag: 1670248471-871672 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 prefetch") 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 long start, put_page(page); } swap_read_unplug(splug); + cond_resched(); return 0; }