Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1420143rwd; Thu, 8 Jun 2023 18:21:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7n1TVz4YAgoTw0mDrahxUvldigS6YPkJfDVLyamDOC7DzLHHSYIZKIQmPH4C+PVUjRnbCt X-Received: by 2002:a17:90a:191a:b0:259:3fe2:e78f with SMTP id 26-20020a17090a191a00b002593fe2e78fmr114234pjg.4.1686273718604; Thu, 08 Jun 2023 18:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686273718; cv=none; d=google.com; s=arc-20160816; b=EavPM14Su3dufK7+AT91SThY+NTZHuXECcybnSyzLDN3xSOvW6NAlVxi4EKUxpDFo6 xOMkk3SohU9Lu3wx7y3gHNccZ+9qMztHxkz0P/Ihw3+PVEernuUh7tXHQriKG4pMxlk/ mRKf+pEjZntOPajYDFAvbTtcFa814x62Kdr7UdonImAsX3kW7wEtZprvdyuCSi9f82CS ru5vhWMt8QB7uNt0N4n1evmqwqiocLjQIupkjlDi0CNaxI6HMPoEbbzxCCSGwZTE4D0P U57QvGRxLjCADsY/qGzh31ys+RqPtDptffTkRQ64bpWZKFwCH0bxw7CZIcAQ4zjF+bBb iUeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=DKO2MGlysYL+7+oQy8UdaapVjC7HViDdumwjMefUUFk=; b=dh4kMKbpYU3yZEmkNhXwYNNT/HXg2cnMbHGCzKKYFM+ajSvYjf0QCcNWr04BblhzRI m4iA0igYh78xmNIQmZW2Goe2qgZKO/RJ3P/g/i5YyuE5rp+nG2NE1LqrE/Gj0cdV8WMT nTEbgK1aE4xz5Q7IEhCXsMaMbdH09QYLginZg/ORGT8zPteE5wIQf0EC6vwC7fCokQtD ENHRlKmlgunEkHKHHu3toUShwoe2fU8JL4WtccrE1KtOiyaWVzrmRxgUI4vjK3eq5yXN PqxMphHjfJDyCLgXM7sVzNcwnUozNgi5QzwKmbX5EHffQZr+0yqsNDV6HLKtZ78BMPYj GJZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=sgrtTue3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt24-20020a17090af2d800b00258f959be0csi3519579pjb.182.2023.06.08.18.21.43; Thu, 08 Jun 2023 18:21:58 -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=@google.com header.s=20221208 header.b=sgrtTue3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237236AbjFIBLk (ORCPT + 99 others); Thu, 8 Jun 2023 21:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbjFIBLj (ORCPT ); Thu, 8 Jun 2023 21:11:39 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E4330F2 for ; Thu, 8 Jun 2023 18:11:35 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-75d4b85b3ccso117688185a.2 for ; Thu, 08 Jun 2023 18:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686273094; x=1688865094; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=DKO2MGlysYL+7+oQy8UdaapVjC7HViDdumwjMefUUFk=; b=sgrtTue3rv24LYzFS1k289BQNEsOuAchrD6cHOusSyoPb1K73NZICBU4ccdS+MDThN zBEewtmtI4CNAWNB55+HxFZZrtyp16opIUtn0ashIh7fwhjdgk+9O/mwLbz9OSd84hi/ pBLFfsBUzEB4I2fW6b9r72oAK2m+QnFCxV5NwJBtw2NTKg7epNTeTUcPNH+shND90LBV x2i2pLMwvamhFrNXJIWV1Y51CIqpk9A6NTBVqHI51CoxyJBUf9QXsv4+sDVgvqVWsQDD RoswrTGcvQxNRpRSEw4ateSoH47vdZ8PWjBeC9XQHtwBxYtSov2fw90M/6dX+45eNcbK 0hmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686273094; x=1688865094; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DKO2MGlysYL+7+oQy8UdaapVjC7HViDdumwjMefUUFk=; b=Lws1I3lclU1q+6zInSyGiwQzMf+Gs3PMYWrRrKQPhNDBQnhkie/51y9NANO6Kpt5Nu QxY5/FnkMV27SVDEkCAD0LnaPQakAnFNjLJQTKR+SjdxB5Cc5o6e/fAy7MOyq8vl0MXL /GuiDxek7krBnQ4qg5NfLS4X27REZr3AXxOfBd5ToXbsoJ5UieXkuWO0jrH4De0Unyfc s6pNQxXlZZBgWMkBVpCUdSxL9aL5AE86x47d0A9/N4KMo8XghZ1W784GIVa5ztQ9QlQT KnRPW2BorJV8HHBM3db/+J6yDDAKvYOLErN1DQfpX0UNNEzJtT5+zxUpkFvgHJ+pNxAH PS0A== X-Gm-Message-State: AC+VfDx9AJoFaVwFy1ASMgzqQETBCROO5Wg6hBG+uGjFRvgxRqsG/lI3 HC4rSRfTn+7KZMmtEj5NPlq47g== X-Received: by 2002:a05:620a:a02:b0:75e:ba6e:be65 with SMTP id i2-20020a05620a0a0200b0075eba6ebe65mr6769325qka.55.1686273094097; Thu, 08 Jun 2023 18:11:34 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id y63-20020a817d42000000b0056507de3d82sm273863ywc.104.2023.06.08.18.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 18:11:33 -0700 (PDT) Date: Thu, 8 Jun 2023 18:11:29 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: 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 , Lorenzo Stoakes , Huang Ying , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 05/32] mm/filemap: allow pte_offset_map_lock() to fail In-Reply-To: Message-ID: <54607cf4-ddb6-7ef3-043-1d2de1a9a71@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 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); + goto out; + } do { again: page = folio_file_page(folio, xas.xa_index); -- 2.35.3