Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2495705rwd; Sun, 21 May 2023 22:55:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5nI/b1dNsncenNDyhU64t4SBoM0PBt7ttpLF8vIUOuxOY8PO+6fmkxZ1tZKqHcUv2S2Kw1 X-Received: by 2002:a05:6a21:33a2:b0:10a:fad7:43bf with SMTP id yy34-20020a056a2133a200b0010afad743bfmr5781452pzb.39.1684734909445; Sun, 21 May 2023 22:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684734909; cv=none; d=google.com; s=arc-20160816; b=XGEhf41Fp5Jl3vzy++mBtyIAkhiU+NGfeqsH/McLbo7pbcyVng0V11IBarxtB/AsE4 OO+LQPmWSaaKFR25Tr6T5yRn0PumG6Dm8CtYCAZC9dGZkUKftSDzCA+GR3j3J634gxSo 9MxeCz9UXLRqQh0RIfo6A+eAYKRh0VY22aEcqupFupLMiw+2yoveZLxNtC6TlB8z8gDh cijT6icOX8NdDs4EFfTmh6oJ4sq5ZTOUvWes911qaI8Kc0puTU9+Q952PUmKaqhoUw8E xrpRL/X4h++V8bbKSwq97cH3DRaLs14F+BEfaqJGMvCL6LghjZtg84F2L+StZULTFDXL T5pg== 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=bf4ovlbip9o2eAgzZYzeIq4fNWAxMs47VtohjgZo/Hc=; b=vTLEVyNnMA/ERiLHfr4ClEZ3Lgw8cWZYHxE77wa4x8oOHcSAehmD/aR+1xguk3owdH wQke03vkNg7h0mgf++1ZG9SZE9I5MLwTT+ZKMmfd8MKlA+TMB43WyiTbF3h19bWAOhTj 8GPLV+Nzzc49LvL6NvXXBwNJJIwj/OCO1Erky806bmF+fqHDN49ay9qlK081glkugiIO 7TBGmbS5BHh4ZZT8gEmKmO2OxojFlaZoeX7cKgGf2OJ7hO00YSUpxf9GZ8N08i9Y+XQb dnWE8fNyao0uGza1uXfyIDZ7ooWfOGOrC47ZAn+IWUKzDHhMYKJ6zIszSsUxL+d9Gmte N2lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xxliRdiY; 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 k24-20020a63f018000000b00534866eb2c2si4206056pgh.835.2023.05.21.22.54.54; Sun, 21 May 2023 22:55:09 -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=xxliRdiY; 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 S231965AbjEVFWX (ORCPT + 99 others); Mon, 22 May 2023 01:22:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231958AbjEVFWS (ORCPT ); Mon, 22 May 2023 01:22:18 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8347CA for ; Sun, 21 May 2023 22:22:17 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-ba829f93da3so8148830276.1 for ; Sun, 21 May 2023 22:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684732937; x=1687324937; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=bf4ovlbip9o2eAgzZYzeIq4fNWAxMs47VtohjgZo/Hc=; b=xxliRdiYq491ddtLAOp7IvlP6Tgs09+WixlM6YG4PIP9hmkihY34Mp7pqS8UXaXWhi RqkBsAewEsCIX9b0ejcCa5E2jV6uN+a3W57TZ3FlG9ZI/Xxbjh+C1MSqcwhmQFBu25PN rRzcJXLhWTtkRDhu7m269tBf4pXwAXhsMjAzMdb8HFMIiX2bUkp/5SZfLmQ8JxH4T0vk wKyQPeorZ9iGKOGhWx6oCTIHOln7Bg8pdmjG1PPm7ouSR3zthhZvslly93YlThiYWoSt Uq6if1E3nt9EtldOeJnlIf2uspBMjaO0EQ7qGUle/0SCGanLsme+EJIaES6VTaJRp/ZR yfYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732937; x=1687324937; 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=bf4ovlbip9o2eAgzZYzeIq4fNWAxMs47VtohjgZo/Hc=; b=XbgnM2eD0eOUhKeTJb/YcZu+b7myoXKFCdSuRo1xLr1rJRyPucBV/tNQjRpafiVBqE AmBYdR55lX4wMxlp7YIdKrrzAZq8LYovhWLkuc2uLHqia0ElNsYeR8hPQetQuLRUqO2p LduEJpg/DpFF6/sVHIv3T6NN8yXoC/Fdp+qUf4Neyi7OOKq1oJgq0KqgaAYQEdVOsSgF etd7qqvPuP6Z3kdQ58JI+swGrggIlT49dIDujJ4eZTiGImaQ3jzQeGljh2cwP28ZOZ7A KUe7fmsHN99LPsWnzNDyJJ0kN5Y3HlyG6Hdb8Iy3LJww9NiAiYPb8OYY27Pz+WjenG7g y/aQ== X-Gm-Message-State: AC+VfDweAb3yJIMOD7a0CuEeZnlsgaUn8NHR/FQ9ee0swtUxdxKy6pjx gz/0FtdgNe0wfIUTrk6y7JfByw== X-Received: by 2002:a25:f812:0:b0:ba8:3590:4302 with SMTP id u18-20020a25f812000000b00ba835904302mr10377914ybd.36.1684732936746; Sun, 21 May 2023 22:22:16 -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 x7-20020a259a07000000b00b8f6ec5a955sm1266497ybn.49.2023.05.21.22.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 22:22:16 -0700 (PDT) Date: Sun, 21 May 2023 22:22:13 -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 25/31] mm/gup: remove FOLL_SPLIT_PMD use of pmd_trans_unstable() In-Reply-To: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> Message-ID: 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 There is now no reason for follow_pmd_mask()'s FOLL_SPLIT_PMD block to distinguish huge_zero_page from a normal THP: follow_page_pte() handles any instability, and here it's a good idea to replace any pmd_none(*pmd) by a page table a.s.a.p, in the huge_zero_page case as for a normal THP. (Hmm, couldn't the normal THP case have hit an unstably refaulted THP before? But there are only two, exceptional, users of FOLL_SPLIT_PMD.) Signed-off-by: Hugh Dickins --- mm/gup.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index bb67193c5460..4ad50a59897f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -681,21 +681,10 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma, return follow_page_pte(vma, address, pmd, flags, &ctx->pgmap); } if (flags & FOLL_SPLIT_PMD) { - int ret; - page = pmd_page(*pmd); - if (is_huge_zero_page(page)) { - spin_unlock(ptl); - ret = 0; - split_huge_pmd(vma, pmd, address); - if (pmd_trans_unstable(pmd)) - ret = -EBUSY; - } else { - spin_unlock(ptl); - split_huge_pmd(vma, pmd, address); - ret = pte_alloc(mm, pmd) ? -ENOMEM : 0; - } - - return ret ? ERR_PTR(ret) : + spin_unlock(ptl); + split_huge_pmd(vma, pmd, address); + /* If pmd was left empty, stuff a page table in there quickly */ + return pte_alloc(mm, pmd) ? ERR_PTR(-ENOMEM) : follow_page_pte(vma, address, pmd, flags, &ctx->pgmap); } page = follow_trans_huge_pmd(vma, address, pmd, flags); -- 2.35.3