From mboxrd@z Thu Jan 1 00:00:00 1970 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 51824C43334 for ; Mon, 20 Jun 2022 06:38:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAFC76B0073; Mon, 20 Jun 2022 02:38:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D8FC16B0074; Mon, 20 Jun 2022 02:38:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C74A58E0001; Mon, 20 Jun 2022 02:38:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B55446B0073 for ; Mon, 20 Jun 2022 02:38:21 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 7AD0380703 for ; Mon, 20 Jun 2022 06:38:21 +0000 (UTC) X-FDA: 79597660002.11.F31E053 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf22.hostedemail.com (Postfix) with ESMTP id 9986DC000A for ; Mon, 20 Jun 2022 06:38:19 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LRKhL38b5zDsJM; Mon, 20 Jun 2022 14:37:38 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 20 Jun 2022 14:38:09 +0800 Subject: Re: [PATCH] mm: stricter check on THP migration entry To: Matthew Wilcox CC: , , References: <20220618073243.9423-1-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: Date: Mon, 20 Jun 2022 14:38:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655707100; 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:in-reply-to:references:references; bh=jkpLklgt1XgnEz/6nPxri5v8anzhG0WOvAqxQ/RW4J8=; b=MyPevcZ2XWT6c4J3XNVgJgvJeMkSdZeKxlojaa40sRTcr7S5++LSzggHD/SDs6moCm6ErY JKDLih+5RdJsb7KjJHUB06Fcc7qd/d+2nc8FCmYPUr2SzkkDQSJcZn0xcYHQsEDNO1gEmp IP4N5mJSa4GCdT4dqzXsH1Df4WjNEo8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655707100; a=rsa-sha256; cv=none; b=5eEJCr5SeVHvt0fBsJ9HnaHPwFxvNwHDh+/v0W+L8Z7l2ZVxJiXFk4FoMYUUiOQ3dypdE+ oA9F6Bk5fF7AmT+g5YKeuWmM+sh7aicp94msmWGiFZzZpKBQGixk8+LhQF8mlDhRPtq3w2 XNFJCSGkugjrxgpdLupXtYwM0G/I2K4= X-Rspamd-Queue-Id: 9986DC000A Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: uhdogzggznf9479ntimm53t89ipz35jy X-HE-Tag: 1655707099-908916 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: On 2022/6/20 12:48, Matthew Wilcox wrote: > On Sat, Jun 18, 2022 at 03:32:43PM +0800, Miaohe Lin wrote: >> When VM_BUG_ON check for THP migration entry, the existing code only check >> thp_migration_supported case, but not for !thp_migration_supported case. >> If !thp_migration_supported() and !pmd_present(), the original code may >> dead loop in theory. To make the VM_BUG_ON check more consistent, we need >> to catch both cases. > > This patch makes no sense to me. Could you please explain it more? This patch is inspired by below commit indeed: 28b0ee3fb350 ("mm/gup.c: stricter check on THP migration entry during follow_pmd_mask"). Thanks. > >> Signed-off-by: Miaohe Lin >> --- >> mm/memory.c | 7 +++---- >> 1 file changed, 3 insertions(+), 4 deletions(-) >> >> diff --git a/mm/memory.c b/mm/memory.c >> index fee2884481f2..6a9a17c7f58a 100644 >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -5043,10 +5043,9 @@ static vm_fault_t __handle_mm_fault(struct vm_area_struct *vma, >> >> barrier(); >> if (unlikely(is_swap_pmd(vmf.orig_pmd))) { >> - VM_BUG_ON(thp_migration_supported() && >> - !is_pmd_migration_entry(vmf.orig_pmd)); >> - if (is_pmd_migration_entry(vmf.orig_pmd)) >> - pmd_migration_entry_wait(mm, vmf.pmd); >> + VM_BUG_ON(!thp_migration_supported() || >> + !is_pmd_migration_entry(vmf.orig_pmd)); >> + pmd_migration_entry_wait(mm, vmf.pmd); >> return 0; >> } >> if (pmd_trans_huge(vmf.orig_pmd) || pmd_devmap(vmf.orig_pmd)) { >> -- >> 2.23.0 >> >> > > . >