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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABE0EC61D85 for ; Fri, 24 Nov 2023 02:04:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbjKXCEp (ORCPT ); Thu, 23 Nov 2023 21:04:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjKXCEc (ORCPT ); Thu, 23 Nov 2023 21:04:32 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 783C11708 for ; Thu, 23 Nov 2023 18:04:06 -0800 (PST) Received: from kwepemm000020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SbyvD4YXCzvR5d; Fri, 24 Nov 2023 10:03:36 +0800 (CST) Received: from [10.174.179.160] (10.174.179.160) by kwepemm000020.china.huawei.com (7.193.23.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 24 Nov 2023 10:04:01 +0800 Message-ID: Date: Fri, 24 Nov 2023 10:04:00 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [RFC PATCH] mm: filemap: avoid unnecessary major faults in filemap_fault() Content-Language: en-US To: Matthew Wilcox CC: "Huang, Ying" , , , , , , , , , , References: <20231122140052.4092083-1-zhangpeng362@huawei.com> <87a5r4988r.fsf@yhuang6-desk2.ccr.corp.intel.com> <5b0e168a-dd43-80d4-2eeb-5c8a5d470f5e@huawei.com> From: "zhangpeng (AS)" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.160] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000020.china.huawei.com (7.193.23.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/11/23 23:33, Matthew Wilcox wrote: > On Thu, Nov 23, 2023 at 05:09:04PM +0800, zhangpeng (AS) wrote: >>>> + pte_t *ptep = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd, >>>> + vmf->address, &vmf->ptl); >>>> + if (ptep) { >>>> + /* >>>> + * Recheck pte with ptl locked as the pte can be cleared >>>> + * temporarily during a read/modify/write update. >>>> + */ >>>> + if (unlikely(!pte_none(ptep_get(ptep)))) >>>> + ret = VM_FAULT_NOPAGE; >>>> + pte_unmap_unlock(ptep, vmf->ptl); >>>> + if (unlikely(ret)) >>>> + return ret; >>>> + } >>>> + >>> Need to deal with ptep == NULL. Although that is high impossible. >> If ptep == NULL, we may just need to return VM_FAULT_SIGBUS. >> I'll add it in the next version. > no? wouldn't ptep being NULL mean that the ptep has been replaced with > a PMD entry, and thus should return NOPAGE? Yes, ptep == NULL means that the ptep has been replaced with a PMD entry. I'll add return NOPAGE in the next version. Thanks! -- Best Regards, Peng