Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2463246rwd; Sun, 21 May 2023 22:08:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43bgRFUmoMF9fLERVtwycQsFWxJ0txzEY+sdM4AhuzNzvzp9y+Fx6U/OKOdQLxHbZ1g/Ni X-Received: by 2002:a17:903:492:b0:1ad:ca0e:cf23 with SMTP id jj18-20020a170903049200b001adca0ecf23mr8958320plb.3.1684732097035; Sun, 21 May 2023 22:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684732097; cv=none; d=google.com; s=arc-20160816; b=N538uOYpy8D2LwM1nkb2m5FPQdc33JYf0TaLpA+tE4CZRmcmo7RRkMRmTuuZjupP0O YiPqVv80grj1wluDm4Rb6oPDnzF+evoYr1xXdNSWl+7/Q/3wt3oqoBYR3R+tj5ayyosU 2FMHFP6sEN0nevuO8gepHI0i5jVY1kzSdkjemkbvuYHYLoe8mBrUoP9RS5kfggkxZXhw 5Z6GyhaOiEck+8/FdF7zQrhg21KYWKdDQLmywHYf7FZxHZ6Z37C97sP9lpDWtYGlyDeQ UK/fC7EdOvkE6khFIPQRwHqTs+T/qEa/1TC9LrpbEbDaNQzzzcxYW06fRsYrlDlW26Xo hdDw== 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=txYbcI1IxxoiY7TMRq349L5NdsMvtbBJAEph8Rk4HInPSmglvpKgqjvN8BOHhR5c2y 0dduiTjCSwWXbIWwGNDktqSDbtTf8atldyySAGSJtw8I+Wpx3kqIaTdjiFUc6OERxf3i yhukLBFSrsAzg+fHBs+9GgQ03h9GiSFiDX/me6PpWZWMitXVo4+CWu3hNAMnyasmSAQn sOBhlMOdkI/MFNPr/ZANyGVDmcBHk6iFEkcP34EtA+mjZGfTP+GlxL8jq4sYhO26WMZD Tkd68WLt6pW20lDZY/pUAbkMLWcXC/hLOBqHsXwcv7nLLC0VwSWgGSBXuNOBgy43ulBY qRsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=J9ylJNba; 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 iz11-20020a170902ef8b00b001a980a2b405si3818517plb.471.2023.05.21.22.08.04; Sun, 21 May 2023 22:08:17 -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=J9ylJNba; 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 S231622AbjEVEyd (ORCPT + 99 others); Mon, 22 May 2023 00:54:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbjEVEyb (ORCPT ); Mon, 22 May 2023 00:54:31 -0400 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 699DEE9 for ; Sun, 21 May 2023 21:54:29 -0700 (PDT) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-561afe72a73so76337857b3.0 for ; Sun, 21 May 2023 21:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684731268; x=1687323268; 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=J9ylJNbawMeH4tOfy11w+ZaO/6872J2rqfHP5lovPYJFW8zB72NKQpN6jeQPkFtYO5 7RHmvMjgUcPMPHqNGnXVyrAFqE5jQbr7ovn6/CLPgFbf3l4X7M/QuLcTo+6IociOTnvp 5CQ9bnI6x5YxJS4Rh5hvct/0Yo5JX0qxeMmK1yabPvgHVQgZYihchIYIgKApcKzJ3IRg ROh6CHyiaDDOL+Ex2mG/L8yyWOYTqU/rosesPvWEE4ijihe6qctq0T8BNRcL6ZpZfkCn M6FU+PpeRPkKqHsAb2AldyKg/94bE7H6WNY4ZFE5SlqswttpLgasmwxgkPJXNEXdyjtP 03EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684731268; x=1687323268; 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=Pymt1ElQf608iFI+8jZDVJTW3E//lxwzfyY6rgB3vvX+Z1wYsH7162FejLcmsK3zj7 LfTvtUTGfg8Xh0UN1KtmnCjq0UCIUWefKalz68eZ+bQcLys2InsYlvXXRvvFNyGj2MGY FP0fWktXqGVpHdlghFVlEApfHDu/H+OGgwsOIlJF6M0eTHj2xjpBRg++fabGVuD/YBLk rsa2XoHD1s0AOwc82FAZwC+2NG0Z9xvE/MO4868TqVIqQFW3a1HhVPgmPNLfnI1A7Eam N0J1m9IEzYyBbwjRPEOBLH4N0oW9lzKWSYg5g5gJmHzMnF+XvGLTmv0Y+URZULk/dl/b lskQ== X-Gm-Message-State: AC+VfDxNNRvLbkBGmuE5OeTFEUQiIUT0GKbyRlW5ry6S4DbHQKmj6AII Zv+t2laoX3XD+xIRMmXZ4CrGDQ== X-Received: by 2002:a81:4e97:0:b0:561:e7bb:36a1 with SMTP id c145-20020a814e97000000b00561e7bb36a1mr8839265ywb.49.1684731268515; Sun, 21 May 2023 21:54:28 -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 r190-20020a0de8c7000000b0056189f9ec2asm1803508ywe.133.2023.05.21.21.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 21:54:28 -0700 (PDT) Date: Sun, 21 May 2023 21:54:25 -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 , 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 Subject: [PATCH 05/31] mm/filemap: allow pte_offset_map_lock() to fail In-Reply-To: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> Message-ID: <3e6d4f8-9f4d-fa7e-304e-1494dddd45b@google.com> References: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> 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