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 8006FC433FE for ; Tue, 15 Feb 2022 09:36:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B4EF6B0078; Tue, 15 Feb 2022 04:36:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 065466B007B; Tue, 15 Feb 2022 04:36:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBD406B007D; Tue, 15 Feb 2022 04:36:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id DC8DF6B0078 for ; Tue, 15 Feb 2022 04:36:03 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9D944181AC9C6 for ; Tue, 15 Feb 2022 09:36:03 +0000 (UTC) X-FDA: 79144507806.15.0996C45 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id D536F40004 for ; Tue, 15 Feb 2022 09:36:02 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4JybWx0LNyz9sgP; Tue, 15 Feb 2022 17:34:21 +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 17:35:57 +0800 Subject: Re: [PATCH 2/8] mm/memory-failure.c: avoid walking page table when vma_address() return -EFAULT To: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= CC: Naoya Horiguchi , "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: <20220210141733.1908-1-linmiaohe@huawei.com> <20220210141733.1908-3-linmiaohe@huawei.com> <20220214144826.GB2624914@u2004> <1c464c41-81f4-fff9-c4e0-45fd4d05e34b@huawei.com> <20220215083755.GA2001565@hori.linux.bs1.fc.nec.co.jp> From: Miaohe Lin Message-ID: <335dffa8-fc2d-d3da-e64b-b6d608e3fba6@huawei.com> Date: Tue, 15 Feb 2022 17:35:57 +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: <20220215083755.GA2001565@hori.linux.bs1.fc.nec.co.jp> Content-Type: text/plain; charset="utf-8" Content-Language: en-US X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: D536F40004 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: y7z9ttdnuc9x666q3t4m4tsesfthcoxu X-Rspamd-Server: rspam03 X-HE-Tag: 1644917762-305105 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000133, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2022/2/15 16:37, HORIGUCHI NAOYA(=E5=A0=80=E5=8F=A3 =E7=9B=B4=E4=B9=9F= ) wrote: > On Tue, Feb 15, 2022 at 10:40:02AM +0800, Miaohe Lin wrote: >> 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 -E= FAULT. >>>> 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! >=20 > You're welcome :) >=20 >> >>> >>> Does this patch fix the real problem rather than just saving cpu cycl= es? >>> Without this patch, "address =3D=3D -EFAULT" seems to make pgd_offset= () return >>> invalid pointer and result in some serious result like general protec= tion 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. >=20 > Hm, actually I'm not sure either. But dev_pagemap_mapping_shift() is c= alled only > when vma associated to the error page is found already in collect_procs= _{file,anon}, > so vma_address() should not return -EFAULT except with some bug. > So VM_BUG_ON() might be more suitable? Agree. anon_vma_interval_tree_foreach/vma_interval_tree_foreach in collec= t_procs_{file,anon} should have guaranteed the validity of the vma_address(). And rmap_walk_anon and= rmap_walk_file do the VM_BUG_ON_VMA(address =3D=3D -EFAULT, vma). So VM_BUG_ON() might be reall= y more suitable. Will do this in v2. Many thanks. >=20 > Thanks, > Naoya Horiguchi >=20