From patchwork Mon May 22 05:22:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13249786 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 8861FC7EE23 for ; Mon, 22 May 2023 05:22:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 144946B0075; Mon, 22 May 2023 01:22:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CC5A6B0078; Mon, 22 May 2023 01:22:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB10C900002; Mon, 22 May 2023 01:22:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DBB2A6B0075 for ; Mon, 22 May 2023 01:22:20 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A27D3C0432 for ; Mon, 22 May 2023 05:22:20 +0000 (UTC) X-FDA: 80816745240.08.A9B638D Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by imf01.hostedemail.com (Postfix) with ESMTP id CD8FF4000D for ; Mon, 22 May 2023 05:22:17 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xxliRdiY; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of hughd@google.com designates 209.85.219.176 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=1684732937; 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=bf4ovlbip9o2eAgzZYzeIq4fNWAxMs47VtohjgZo/Hc=; b=EGtpdPsSfeulOzpSgsxFQpZQ1zMvDV1MUeq2WqkQyJpxhWvd3okek3JB/naaxtNd2RK6QN 814EC89WxHBOgv0liYh+WIrA/Sb5mj8mxFIE6Y30jmrpC2cgDcragyioylxU9lHY5A7Rem blJFDeP2WMJkG35Kh+v+HVr99FlAFtk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xxliRdiY; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of hughd@google.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732937; a=rsa-sha256; cv=none; b=hDiHtUTnXwyNLLjM9bKJRj5Y8St2XUnBz9tROMb2GrOXfUkBCKyz+Vzw1yHsBero6R/Mve R0bWAWdJad0BcpP67p0UAzucebgVuBHMHYEwW77ekSoJjS1grYH6CwjxEmB77wnhXVzzo/ NVdp9/6hx/x3mSLtdpOE51NC3cM6ldo= Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-ba80dc46972so8132797276.2 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=YlIvjbOMdsEPSeDfv52FU74NR+7CKVIHP9nRN4H0qa1g25LQz9E5pXH+/CP9AQRADi 5/R3UFQkT2lNiN1h0G/fY3yepq3IB5PxNjGKXfc4JdTHbPOlRAhJmQb7KE2O51yPBGPg QEnVdNXSNFioAK6QZcW0FRi9J4pp4lTE/WEnbxAhEuVh79HZNrtYQ4xmeDNbRLrIqDlc UaxTn8ne3bcYNEuGmlE6ARcx+fVg2PqMvb8GwI68rjrwTC5AfNt39wlNXQiI99hgrmT7 xeMP3wNMjDjXO1tQpYuY2nNMygNYbYW0F6GNT7mCfMyeATALndWYNbnWt8J5VsR/WsCG txIw== X-Gm-Message-State: AC+VfDxRYg3Sxkoy6S+81zhPuoAPJPbRp4S/Pyfnpz10XFLviUcEhl3u sdZvh5xpXlo8AG7tjz411KNj1A== X-Google-Smtp-Source: ACHHUZ6vQXHbZLVvPerE0Fu3jg6OZ5EHbThB/3RtX3VnGbimP3VA+F9C2VHWinuyuwC+mVweYmLjPw== 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 X-Rspamd-Queue-Id: CD8FF4000D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: wrt1kbty51bk5pj6ctx56inh388ttpst X-HE-Tag: 1684732937-824645 X-HE-Meta: U2FsdGVkX188zd3gnMvxtjV17dyUPyedETMov3ikzRDlxtKCfWfGqN3v9SGVPXJFOVgrnlxTm2XI771GuFh8o387RQrncQXpLE8IcOrwTUpybyvhZx9I6sZkEu9w9zoaWV7vIWBb6aRByqZ4ALuLSChrtNYeBLzouVYM4+IefR9AyzizEHSvsAYt+UJRnBMvDLkmcJMkYEyoz5t95haXZOupMnsfEcAsmQKSKddYjgCorwEe+klqv5ZhvB7gocV+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7pwjAXUagtzQNr3C7hcrsQHzcmkaF0eDEFPjJdAeoh3IiLoN+JlC4bEDf0cdFFj++UG1DY/qK1XSYPGyCCnoWmD3PIsOTtHfwUWvw== 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: 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);