From patchwork Mon May 22 04:54:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13249755 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 404D4C7EE23 for ; Mon, 22 May 2023 04:54:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5C81900007; Mon, 22 May 2023 00:54:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE4EC900002; Mon, 22 May 2023 00:54:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8555900007; Mon, 22 May 2023 00:54:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A6AA5900002 for ; Mon, 22 May 2023 00:54:31 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 631461C7587 for ; Mon, 22 May 2023 04:54:31 +0000 (UTC) X-FDA: 80816675142.29.2EA0827 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by imf07.hostedemail.com (Postfix) with ESMTP id 878BC4000C for ; Mon, 22 May 2023 04:54:29 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=J9ylJNba; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684731269; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DKO2MGlysYL+7+oQy8UdaapVjC7HViDdumwjMefUUFk=; b=GhunT1IQ7Dqy5wbnDfsWJQY7FQGfmSWw613ezKqiIjYUKz6fr9d4fmiqzKK36U9nEBFRwm 2gTIoVDSPNZy1B831qnaRTwKv5G2uaGuXu9SdDK+vYmoPElqImlFrgNECW5GLLlXgq5F4D W+g1XtMdc7JA1QL2w3qnQVb2vMA7A40= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=J9ylJNba; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684731269; a=rsa-sha256; cv=none; b=hAcFnIuba5WZgkuClIEB3ksz6x90Vg0J3jgEBFN808OfBxNNmx6hcikMy6pMDzIX6LHDRh Cr17xgS/sV+3WdQq6lPkuuSh0dpdYje0GfzyxWwKsrTDTcUbUrTM20ffL0ZatvhfNpU5+E X0kcV7BQuhpQ51Z/rv3sfgMTOpBXy5Q= Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-561c46e07d7so76332627b3.2 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=aotFiMD8qgtbKoYsphnSnwyrykw94qIASsUUV3v54zk4jSVvvuqWWm04gRvaPwJy2Y bQr4sYgo0oTHmc3jiydjeBUBpP2gJbN72VTZ76hN4Ce1CPTUidG69yOXEsH5TpaGjAYv qOf40jlhzEbBydYWwToBtI11xXOYe3cbyYlMUG5S2LlGnfFupvnoyGzYVoW5sNA7fS8Y pRIht3nkaDGHT4kwhMaF69ABMGPIIjZB6M7qC5HNR7vno2uaZ31Ot/x82JvfRHFyOtjv 3vfvR5BKapBSocPur49aboOMgCu1eGWWZDEpHDFeJd9kTE72/wuHbaKQczpf0fOTQxp8 tW9Q== X-Gm-Message-State: AC+VfDxS/CTkYhvhYdTxk5ohliqb63diW13V7IJZuNaotkWyS9beKa2C HZwEVqTguI34LcYpRmPHMYVVGA== X-Google-Smtp-Source: ACHHUZ4551zDAoXcCIh8jhAd8f8X+Cxw/fLbkIrjHAC/+8ziZTZq6Fx4vtipE1QtRd7bp1hgyGTCog== 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 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 878BC4000C X-Stat-Signature: 1ptygqj3rnthtn7brhpb55mbonyi83c6 X-Rspam-User: X-HE-Tag: 1684731269-376775 X-HE-Meta: U2FsdGVkX19F3BBw2YslYZBSzFh1nmP0kLoOHXyNuRnPEdKYO1MpsIWhUFebi7aLpZwNFIHXCCTTfJB5b5GV5xKZ7xUjVOgt5P1b17T9rFWxdU9qw398ITyuw1uNVOaFndYVsgcI1KVdFjH9xWz9jHtPRnnBEgAbl1L6710LDovagqpuPjUt+y7414WfwJE918hjnLf06NCyrKmEFnL7xJNb0lDgVxMru9glE8ZLm4ZTPk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Dr7ayX4vlJQnYWFEVGGfBp/c6lcSHLpo5ADdHfw6Ov+sOccaugBvHLdZ+Pt5RXUtKZMSYQqbEWggtr5tZxfYzzAoyI9M71CcNzfX/pa5Nz5eOfZYdNBl5RWy3Eoxawyg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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);