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 303CFC43334 for ; Mon, 18 Jul 2022 06:49:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0FF16B0093; Mon, 18 Jul 2022 02:49:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BF786B0095; Mon, 18 Jul 2022 02:49:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8ADF96B0096; Mon, 18 Jul 2022 02:49:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7BE726B0093 for ; Mon, 18 Jul 2022 02:49:51 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 4B6D1604CC for ; Mon, 18 Jul 2022 06:49:51 +0000 (UTC) X-FDA: 79699295382.12.D99A8C5 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf30.hostedemail.com (Postfix) with ESMTP id 745488007C for ; Mon, 18 Jul 2022 06:49:50 +0000 (UTC) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LmXZ52934zjX3l; Mon, 18 Jul 2022 14:46:53 +0800 (CST) Received: from [10.174.178.157] (10.174.178.157) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 14:49:34 +0800 Message-ID: <9a4e42af-a354-2947-5088-436df2b4cc9f@huawei.com> Date: Mon, 18 Jul 2022 14:49:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] mm/huge_memory: Return from zap_huge_pmd after WARN_ONCE. Content-Language: en-US To: Matthew Wilcox CC: , , , References: <20220715092238.22663-1-zhouguanghui1@huawei.com> From: Zhou Guanghui In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.157] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of zhouguanghui1@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=zhouguanghui1@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658126990; a=rsa-sha256; cv=none; b=oMQBikrG0+STQIgEtnpWc9QgA+b/nRmUKvEpLUfIKZ+r21cddJDjF9jCwwx3PJX5vAtZh8 sPgFXYjqZM+qZs8anwtrg+gxuKkEGdENyjBOEzKzmxEt2OIoLqwVpjNAc3uEAqLoEAsxAn PEbw7Uqjh8srPnI9fKaHQJ2gjJ2Mzfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658126990; 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=yPyOvqbRNd7k3y1rNJcKPOaqwByhLk08JFDbWalnkZs=; b=CnB9XkoeTsPNyirNklI4FflmSbBi/tvd/DbIkVncygGsuPfTpUDoZvoXrLM2QUAufHmiHS fCjFf/y42suQw0rPOiq9WNvhnZa0cbRWJirCr5mNCaSrj0W8Oe3HAMNPXrelVo3rjryito rc3kUN0ogr2k2mvbqo9n7QoFRlPdaBU= Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of zhouguanghui1@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=zhouguanghui1@huawei.com X-Rspam-User: X-Stat-Signature: b89dbkb6swqh4nf9agg7q8kz4o51374q X-Rspamd-Queue-Id: 745488007C X-Rspamd-Server: rspam03 X-HE-Tag: 1658126990-464989 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/7/16 1:50, Matthew Wilcox wrote: > On Fri, Jul 15, 2022 at 09:22:38AM +0000, Zhou Guanghui wrote: >> After WARN_ONCE is processed, the subsequent page judgment results >> in NULL pointer access. It is more reasonable to return from the >> function here. > > I'm not sure this is a good idea. Probably better to crash than > continue. Except present pmd and pmd migration entry, there should be no other possible scenarios. Whether crash or warn is unnecessary. However, the current process that crashes after a warning is reported is not reasonable. Like this: if (pmd_present(orig_pmd)) { xxx } else { swp_entry_t entry; VM_BUG_ON(!is_pmd_migration_entry(orig_pmd)); entry = pmd_to_swp_entry(orig_pmd); page = pfn_to_page(swp_offset(entry)); flush_needed = 0; } Thanks. > >> Signed-off-by: Zhou Guanghui >> --- >> mm/huge_memory.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/mm/huge_memory.c b/mm/huge_memory.c >> index 834f288b3769..7f5ccca6792a 100644 >> --- a/mm/huge_memory.c >> +++ b/mm/huge_memory.c >> @@ -1601,8 +1601,11 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, >> entry = pmd_to_swp_entry(orig_pmd); >> page = pfn_swap_entry_to_page(entry); >> flush_needed = 0; >> - } else >> + } else { >> + spin_unlock(ptl); >> WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); >> + return 1; >> + } >> >> if (PageAnon(page)) { >> zap_deposited_table(tlb->mm, pmd); >> -- >> 2.17.1 >> >> > > .