From patchwork Fri Jun 9 01:11:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp649012vqr; Thu, 8 Jun 2023 18:30:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/bP7EE5to5WCkI1BtvgIDDRWL2dFrrRgKKfq2uwAkYq8U7KJUWpry7bR88uws+3YsrxoD X-Received: by 2002:a05:6830:104c:b0:6af:8348:6a5f with SMTP id b12-20020a056830104c00b006af83486a5fmr78254otp.22.1686274231063; Thu, 08 Jun 2023 18:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686274231; cv=none; d=google.com; s=arc-20160816; b=E64tbKyu/tUW+CXWw4wrSqen+FwC7zWR/pDdv4mXI6VetAnpF/X3BwvKKgyWjEJdl0 KmAPu+iv5c7YgpQnmeC197RgXHM+4BH+MdAl/xfzlyZphZmxuku6qYcnEh8NEo3PDy+N mrr3nI4Y4bpV2lDv5eqfZpO3w3DKDoys+sPuDuicmF1MIlvbrUeX3pnjv+MC1ZiC+hLN OmozmJMUsRgpAjg9KtARnbp48gAgGrCuy3OOGmxCqW0Kp4okOpWoPgrQqD0hzehceMQp 1ihAmV9uuf6VBZ8UgaEXc5SwNb52I/3C15Wd+IBnP2PiEOzT2eMDuWMSKuRtzGMj/wcm HA7g== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a137-20020a621a8f000000b0063c56e46f9esi1645419pfa.294.2023.06.08.18.30.17; Thu, 08 Jun 2023 18:30:31 -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 S236602AbjFIBLk (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768186688324864484?= X-GMAIL-MSGID: =?utf-8?q?1768186688324864484?= 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);