From patchwork Fri Jun 9 01:39:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13273090 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 CCE41C7EE23 for ; Fri, 9 Jun 2023 01:40:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CD9F8E0002; Thu, 8 Jun 2023 21:40:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67DE48E0001; Thu, 8 Jun 2023 21:40:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51E5D8E0002; Thu, 8 Jun 2023 21:40:07 -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 3E9438E0001 for ; Thu, 8 Jun 2023 21:40:07 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1899A1602C7 for ; Fri, 9 Jun 2023 01:40:07 +0000 (UTC) X-FDA: 80881503654.15.0D4DAE3 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 56D2040003 for ; Fri, 9 Jun 2023 01:40:05 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xtJR0sJI; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of hughd@google.com designates 209.85.219.172 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=1686274805; 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=UwuVNK2fY7F7iaoH+tt2s4ap3NLwMgK8mAcGkUuV1QI=; b=7yTCsPdTQbS8Bmpsp68fLw6+6TdSZ6oKcuW6lUzXkTG0YIKeUeHcybBFWIvUoccN5aWvYd 9WaO1Fh1/BNce5NjftRmjsDoYGTXHZJLrcx8oLYvuuVFac6jzGQk19ubz0rXpr0F7ofgAS NhixDWSq0Nh0RvUMQ5qigFlRZ0w6o2M= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xtJR0sJI; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of hughd@google.com designates 209.85.219.172 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686274805; a=rsa-sha256; cv=none; b=KQZ5Rem7hXqaJGzL3nZcNqFx49Cgk8QpmVW1VRvB0cwjtqsizKI2tCoS/Pa9vpXeO8L/u1 X4SdC8B2N3E5TVRF9qWeWT9lKzpagLWiwm/nh+51scTo+s4ycaV2oMSXzLelh12V0i+bF+ DFs2pNuzQ2DGuSM9r9yaAlojhxht2A8= Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-ba841216e92so1373526276.1 for ; Thu, 08 Jun 2023 18:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686274804; x=1688866804; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=UwuVNK2fY7F7iaoH+tt2s4ap3NLwMgK8mAcGkUuV1QI=; b=xtJR0sJIJzLTXBky/wVlZo29dNTxzgA54BszS4z+bL4XgGa67uu8WNTm+JM7XI/l9k 6m4Lc80dzOLZH5qTELBlC5YxGQJLyz1bh8ZNW1tEJ8D6xjLzQ+u4+WAilxn55/jW0XRb Epze0ZHSodQnM7E7VM26/xnDCzhsJKvRWH4eXMeV0AMMehd09rxHboGfxvtXMtgKk1Z4 SnsamQypCiUjdvefoXG4abvyN6tDU3XIw1oNbEazjBhrMx+Kg+mHF/zkH+Ct85cC8hz5 iw1woW6T1GIXQ5NWzRO4+D6+WwHZuB7CFNtHE38x8bXk+v2L1K3lyzT2dxXGxy6c449H V+iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686274804; x=1688866804; 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=UwuVNK2fY7F7iaoH+tt2s4ap3NLwMgK8mAcGkUuV1QI=; b=g5sZ8/tCXGookJ1aJCACudUfuqGZKpngieMqoNtP6X8//wa7p5+zegG8BwEa+ZMe1U p6cj+NPLJKiSv8+dDAdzHbgoxUluas9mWpn6pdqV+bdPpH173Wo6SlxYvDAkszNcxDqP VMRTf93rJjkTMLixgDhV2SOOJVekWQCymKQodfcTRryo6SDy99dpAhQQudv05xWiUMgh +qIoOEuVpzRvXTyK5/ETckFOZbt3UZZVZDKk7x2cKGU8HkDg+6ZjTaCAPjExfFyGWMIP at0moILnZLSnKsRIGiQZ6Qx7DlOFuXeYrzbqGGMjcaZOd9vDfo6Gmh2rzrb9ZuXDOlOB 85Og== X-Gm-Message-State: AC+VfDzJx88F1UOaaPkipfgmb/r2oe0cNNUrT26ynpUm8CfC0hF6B2nX qzFgiCIWd2cFhycVPIblNdrwzw== X-Google-Smtp-Source: ACHHUZ4q7dBjgPopIYtcorM5R7hyIrmP9CgiCOnb4btr582PPdFwrjvxsL7Fli0sAzIP7Ak/8SJsSA== X-Received: by 2002:a0d:f543:0:b0:561:ce93:b560 with SMTP id e64-20020a0df543000000b00561ce93b560mr1378798ywf.43.1686274804318; Thu, 08 Jun 2023 18:40:04 -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 t202-20020a8183d3000000b005619cfb1b88sm306230ywf.52.2023.06.08.18.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 18:40:03 -0700 (PDT) Date: Thu, 8 Jun 2023 18:39:59 -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 25/32] mm/gup: remove FOLL_SPLIT_PMD use of pmd_trans_unstable() In-Reply-To: Message-ID: <59fd15dd-4d39-5ec-2043-1d5117f7f85@google.com> References: MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: siitm36mecx1xeg36wg94kbubtqz7gqi X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 56D2040003 X-HE-Tag: 1686274805-84261 X-HE-Meta: U2FsdGVkX1+AFZEt7qXfIwp6EdkyC1uRxa/+Vnw8eo9r2IsqGkUUOB/4SP6IhT9Rn7QsIEX2Uw/Sdfbe7cW9R8N9ng76VMHHENQeDlMQfFZ2bufSXuzSXXw6atfsgaI2rCpU2Y9RE1eOf1NdjD9nJe8NO32WMGJ9+DAEapNxtr8yTioncEwPoPaIbcr7mRaBlfHUQ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3sSJ5qcUH2XzBqbihaB2+0J/QZ/eEBbnUxAn/XbCJgi8brxwjPNKXi6bzT2GomP1YYyW1VZSdNqeDyA7RQ6vxGxnGKc38IjEEMRlNnhiCrsLt7atOOiY0CenV54koK7cPJWMs3DDRZL0VZkJlbYTR2Os5HRyA== 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; and this removes an unnecessary possibility of -EBUSY failure. (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 Reviewed-by: Yang Shi --- 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);