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 42A2AC433EF for ; Tue, 15 Feb 2022 02:40:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5CAC6B007B; Mon, 14 Feb 2022 21:40:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D0C356B007D; Mon, 14 Feb 2022 21:40:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFBE56B007E; Mon, 14 Feb 2022 21:40:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id B09C46B007B for ; Mon, 14 Feb 2022 21:40:08 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7606B8F84F for ; Tue, 15 Feb 2022 02:40:08 +0000 (UTC) X-FDA: 79143459696.28.3142F80 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf04.hostedemail.com (Postfix) with ESMTP id 562DA40006 for ; Tue, 15 Feb 2022 02:40:07 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4JyQG51HZfz8wZv; Tue, 15 Feb 2022 10:36:45 +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.2308.21; Tue, 15 Feb 2022 10:40:02 +0800 Subject: Re: [PATCH 2/8] mm/memory-failure.c: avoid walking page table when vma_address() return -EFAULT To: Naoya Horiguchi CC: , , , References: <20220210141733.1908-1-linmiaohe@huawei.com> <20220210141733.1908-3-linmiaohe@huawei.com> <20220214144826.GB2624914@u2004> From: Miaohe Lin Message-ID: <1c464c41-81f4-fff9-c4e0-45fd4d05e34b@huawei.com> Date: Tue, 15 Feb 2022 10:40:02 +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: <20220214144826.GB2624914@u2004> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam07 X-Rspam-User: X-Rspamd-Queue-Id: 562DA40006 X-Stat-Signature: 1h6mqckqd7xru8pwmozkuprjhrure49g X-HE-Tag: 1644892807-970837 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/2/14 22:48, Naoya Horiguchi wrote: > On Thu, Feb 10, 2022 at 10:17:27PM +0800, Miaohe Lin wrote: >> It's unnecessary to walk the page table when vma_address() return -EFAULT. >> Return early if so to save some cpu cycles. >> >> Signed-off-by: Miaohe Lin > > Acked-by: Naoya Horiguchi Many thanks for your review and Acked-by tag! > > Does this patch fix the real problem rather than just saving cpu cycles? > Without this patch, "address == -EFAULT" seems to make pgd_offset() return > invalid pointer and result in some serious result like general protection fault. I think you're right. We might dereference the invalid pointer in the following pagetable walk and results in general protection fault. > If that's the case, this patch might be worth sending to stable. But I'am not sure vma_address will return -EFAULT for dax pages in the real workload? If so, I will send a v2 with Fixes tag. Thanks again. > > Thanks, > Naoya Horiguchi > >> --- >> mm/memory-failure.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >> index b3ff7e99a421..f86819145ea8 100644 >> --- a/mm/memory-failure.c >> +++ b/mm/memory-failure.c >> @@ -315,6 +315,8 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page, >> pmd_t *pmd; >> pte_t *pte; >> >> + if (address == -EFAULT) >> + return 0; >> pgd = pgd_offset(vma->vm_mm, address); >> if (!pgd_present(*pgd)) >> return 0; >> --- >> 2.23.0 >> > . >