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: 13273066 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 8D4CCC7EE25 for ; Fri, 9 Jun 2023 01:11:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B9CF8E0012; Thu, 8 Jun 2023 21:11:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 269F68E0001; Thu, 8 Jun 2023 21:11:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1323A8E0012; Thu, 8 Jun 2023 21:11:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0621A8E0001 for ; Thu, 8 Jun 2023 21:11:37 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DBD0F16026D for ; Fri, 9 Jun 2023 01:11:36 +0000 (UTC) X-FDA: 80881431792.29.279DC89 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf11.hostedemail.com (Postfix) with ESMTP id 198A84000C for ; Fri, 9 Jun 2023 01:11:34 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=sgrtTue3; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686273095; 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=KUKwx9dBOJiqmYPGK1C8IK5r+dVWsnE4qYtLcc7IX3Gu5+Zx1TkqlxlNXSRyeFaouWGhIx AlQmpTUCOE1beRfliXi2rXvz8EpqudA5gEHGfBWf1kKsph7EeEb6Sj6jZgTpV70gYJLKiY cADvjje82+LYpHMiqpjPwJ0WiukrfEM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686273095; a=rsa-sha256; cv=none; b=h6k6atARq5+MUNyEhzlkPHt0Y1CYbITIwze4CBPWLpNQjSyBtl5hDcXeuEP9bkjvA+FXGm OlkTEX3EMsdEE0tj3aRGX7BzaRfMEKku/NZYRvnuBDIK62fL2APZYmASevFDqntLMpUYxl uqC2FqdJYI13njHtR4GrXAYbt7VSMBI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=sgrtTue3; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-75d3f2c9d13so118226985a.1 for ; Thu, 08 Jun 2023 18:11:34 -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=CXMGvAzU4pgx9hI+RBz1w3BZD+0tCOmeXXPocZ80Xu4NKsK0DE/vUIphC0IZvFQUIP 25N4a+GiVAgpINVFqpd5uNSl+7fb6W3MJilMhw/og2ShovPIPxKxYMIC5bSnNDiTnfkE bWBy+za+YxoJq4Zlbp+/6MPGfNGEQdb7H7KmHlYv9aLGaSXpz/5Lpz0VlI4j8lW1JvrS wwJaxE1Voil/VNAjfp5t0CzY7T4N2CWJo7l+TaBPjXe4jeF+i4PVMK/k27VO6pO65c+k sS2LG01zD04hkrcLxiQjR/wExxFfyELpS/ChC9b8sjOrjv4JH3jhVO5TRELuI0U7ChEg BHzw== X-Gm-Message-State: AC+VfDwE/2SRTC3wIfaY6fXW30PFU82UZTqmhJ0Ov1z5vFtYixa+mO7A tSs87DdqsWn6q4/fpzSpiSy83A== X-Google-Smtp-Source: ACHHUZ43VqWz0kXy5mK3UV6S1YjsSZPeNy+eW38Rkn5m5MYDr07ka9TKGJWrHyw+7CpJWl7tn2JLMg== 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-Stat-Signature: mjd3k5ec61jpz1ncy4gm4fprys6qabme X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 198A84000C X-Rspam-User: X-HE-Tag: 1686273094-536537 X-HE-Meta: U2FsdGVkX1+Iaa0zhVUy6gr2WIwifBS4vDDZuXyy6IDgueTHpgVg1kYvkejI6YMVt+TxL5JeXCoBkeQ5RrZtVm/2npso1/OXb44bKJ/TlQ6HG0W0xeir726zT77Z68Satkjj2WAoFBzsvY6ZjljtFdWHPDnSY68v8GaltSbCi6hG7b1krRH0DWC8Bgx1W3MPkrk8Lf9LCMnVnSglpAKrQTf1PqG1BoG+eSmHaWKh7txNhcs5jot9pjpTtP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z+Dnf/qhB1Wua+qPfKGPLuurhWiMV0qwuPS71vV0aTj0m1w5OB5EJG+Ev1KwEq97cR8W8e1+g5mYYcmnDU7jB0ncZTT3l2Ug29w== 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);