Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5216425rwd; Tue, 23 May 2023 21:01:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5mStdVhHTOOJjkAWdYTe/5nt2VNeKTOCgL5HSObgmWkBifXXqMT3lUZK+wZHHf1G6p4CNI X-Received: by 2002:a17:903:2343:b0:1ac:a9c1:b61d with SMTP id c3-20020a170903234300b001aca9c1b61dmr18423598plh.11.1684900906234; Tue, 23 May 2023 21:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684900906; cv=none; d=google.com; s=arc-20160816; b=EXJfpYV3w35JKlGkBlO/6DOyBeUEEHBXa9umbQbCvAa9zhx+W1n6uNzMG+NfIebzz2 PiKp6uiOQ3B/LSVO3WxdyHwZYITQJmgPc+ekmEIS5OD/iWrYXLXUNEk/N3wm1lylqDNc vefZ2mQsVIT5v4ZDklwBGgXuNRFINfltuPvo87S79/hKnLjj3iEPP9lXiYgRfmAR8LTm AW2Xm6aXan4tQw0Ccs8CvhC7CO6eiw/VFTmivjPaQMN8jhM+AaFCeKpRH4+vA8Akz59/ quWn/EObUEno/7bkX/a0hvCN+xur7B/RThLi+M5iZe7iApA7pFa3ya77ABw39DFpdBBD cAaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=zptm10s4FWGNuDqotiyHNqzSBWdZWYYk5Du9kKCZq8I=; b=veagh/IsrpL6dzAR8BIXIEFhrSAT5eXCjwumihLEPWJmNgZlVs+soNHCnV7bH4Ph0S Gjphsqs2hQtkaKJ4YktSMTZnChDWAW4l7327Gpt2XA33GvgV50qIu9y84H/Vp51VDYEG LiSH662s6BOFxs2ae3s2YGsILc4j8jLs+V1K4D3du4gV425DQMYSSlRPuJ8EzMlUWJR/ cki1ronOexKQVo2HFyCj3MQjotkjmdSchIkrqAYRKQtoE9LKL+N3YCfFo+ruivxKo3o2 f4OEvRRQrhMKBMt37rC9FAnxEqoppBBl3kMRXCe5wMpDF5kF+kpXHSMbkUFaGviXgV9H zbhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=kOtI8EGA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a170902a60800b001ae488bbbd4si296577plq.344.2023.05.23.21.01.31; Tue, 23 May 2023 21:01:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=kOtI8EGA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239325AbjEXDRQ (ORCPT + 99 others); Tue, 23 May 2023 23:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239323AbjEXDQh (ORCPT ); Tue, 23 May 2023 23:16:37 -0400 Received: from out-39.mta0.migadu.com (out-39.mta0.migadu.com [IPv6:2001:41d0:1004:224b::27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C269410CA for ; Tue, 23 May 2023 20:15:02 -0700 (PDT) Message-ID: <03e44919-fa89-5719-466e-90e7738633aa@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684898070; h=from:from: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=zptm10s4FWGNuDqotiyHNqzSBWdZWYYk5Du9kKCZq8I=; b=kOtI8EGAFZbUN6zzUkFOdQ7CpFoauCOESyTYomdMRtcOTlEUhcsE42MNvndJvZOd3gUMQo ejuQdwiPfEqilZ3otUWcc5/SBH9AysOULQNtSrZv6mav4fMXXIROLmhlI87cA/bRHAEHd1 SlYbN19jkfBj7okOi721QZIhvExMeXU= Date: Wed, 24 May 2023 11:14:17 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 05/31] mm/filemap: allow pte_offset_map_lock() to fail Content-Language: en-US To: Hugh Dickins Cc: Andrew Morton , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> <3e6d4f8-9f4d-fa7e-304e-1494dddd45b@google.com> <8f6057b5-362b-a0f6-2f2f-579debe48fce@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/24 10:35, Hugh Dickins wrote: > On Mon, 22 May 2023, Qi Zheng wrote: >> On 2023/5/22 12:54, Hugh Dickins wrote: >>> filemap_map_pages() allow pte_offset_map_lock() to fail; and remove the >>> pmd_devmap_trans_unstable() check from filemap_map_pmd(), which can safely >>> return to filemap_map_pages() and let pte_offset_map_lock() discover that. >>> >>> Signed-off-by: Hugh Dickins >>> --- >>> mm/filemap.c | 12 +++++------- >>> 1 file changed, 5 insertions(+), 7 deletions(-) >>> >>> diff --git a/mm/filemap.c b/mm/filemap.c >>> index 28b42ee848a4..9e129ad43e0d 100644 >>> --- a/mm/filemap.c >>> +++ b/mm/filemap.c >>> @@ -3408,13 +3408,6 @@ static bool filemap_map_pmd(struct vm_fault *vmf, >>> struct folio *folio, >>> if (pmd_none(*vmf->pmd)) >>> pmd_install(mm, vmf->pmd, &vmf->prealloc_pte); >>> - /* See comment in handle_pte_fault() */ >>> - if (pmd_devmap_trans_unstable(vmf->pmd)) { >>> - folio_unlock(folio); >>> - folio_put(folio); >>> - return true; >>> - } >>> - >>> return false; >>> } >>> >>> @@ -3501,6 +3494,11 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, >>> >>> addr = vma->vm_start + ((start_pgoff - vma->vm_pgoff) << PAGE_SHIFT); >>> vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, addr, &vmf->ptl); >>> + if (!vmf->pte) { >>> + folio_unlock(folio); >>> + folio_put(folio); >> >> Missing: >> ret = VM_FAULT_NOPAGE; >> ? > > No, not missed. Here ret is 0, which leads do_read_fault() to try > __do_fault() afterwards. Whereas VM_FAULT_NOPAGE would send it back > to userspace to retry the whole fault. Either will work, but I think > the intention of VM_FAULT_NOPAGE here in filemap_map_pages() is to say > "the page you want is now inserted", which is probably not the case. Got it. Thanks for the explanation. > > Hugh -- Thanks, Qi