Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3740903rwd; Mon, 22 May 2023 20:00:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QW+Le2UwnndXROrEOYIMjn8/mdscqzMH0q0OtPSWB3o7xXot1rPdEkqmjLJEbzM/hxWXB X-Received: by 2002:a17:90a:5792:b0:24d:f2f5:f571 with SMTP id g18-20020a17090a579200b0024df2f5f571mr12630065pji.36.1684810852144; Mon, 22 May 2023 20:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684810852; cv=none; d=google.com; s=arc-20160816; b=Mm+pGyHUUa+BOAD+ca2ejqwXfzyEoBRAs8PahdRwHWVZ4zXcU7rRc9voG+sK18TrMr afBWe/ANu1Xug7uuj/KfB0xREtVDkIuqrxO8DU9TGfaBr6yapw+AkSaiPsr8E1c8fyPe hUxWYbaXwRWceO8K5NZswEZJql8FJs2gVGGMxq1Dl1nKQd6sO8RnQHVY0Eh5qBDEhq/S zGNGWPskSVcISAVJ+Wfv/Ci5SxwIiMegeoetTRQmdpFb2Ccl9zp5B1W3neVjZTEAFwV+ dOfdKfY9CdUTdyFFl+r6S//MLlSYRV52zD0oKAVn132z29lv8VMkBhflj7Ky2ZonetL2 tJ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ZHxjOHFezdgtF4NBYBIMb6jc3c6vhP3piT2YLvnyXjM=; b=vn1uedbgs78/Wzm6ztPyG+4QZRA2sZAjZD+5O5KEGP3X2atD0Lu7JUnPmx4GqPcJNZ ChIHnc04UsOFDd6KiEVIJHTcdrIS42VWwU8S4LjYVvvks8d0yPrz6RofkpoAw5jTNZsE I9F+NzPIJHpeMDnhflr/0IU5p2NGATK+yB9L/b3vQn/TAN0xliJCk6mZnVRL6Ykmt4cZ 5XFymeoZHZq2a9duRxP+8hIP+0O0sD4Lk2mW82vrAZk1JEv2MWtqnnIQGD2TBDtbOK7Z 9PwrtWlEPE2BeVnAlfO3IjCTSEkeNw/9OseT7JzWnxIPUJNSm+kbn2xVIEDb3tDxLK3m NK1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=RrzmUBLX; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v3-20020a17090a898300b0025054d888c5si731446pjn.114.2023.05.22.20.00.39; Mon, 22 May 2023 20:00:52 -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=@gmail.com header.s=20221208 header.b=RrzmUBLX; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbjEWCpN (ORCPT + 99 others); Mon, 22 May 2023 22:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234906AbjEWCpL (ORCPT ); Mon, 22 May 2023 22:45:11 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AABFE9 for ; Mon, 22 May 2023 19:45:09 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2537909d28cso3057861a91.0 for ; Mon, 22 May 2023 19:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684809908; x=1687401908; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZHxjOHFezdgtF4NBYBIMb6jc3c6vhP3piT2YLvnyXjM=; b=RrzmUBLXd13viYNCNSEK8TDRcqf5eaBA4G+zJtgpMI+fsu+1pOaRNG+/oKmMWQnlZP qlFB4/7tYWmrgn/z8IPz4PEqNB7ipFpdi41qBHSqH4CYbs2cBkczRrF2q8/mSitCMOlf PYGa6rAYQtV1dfSAJPvrMK416VSV+45kWPeoEzIN/v3kFmhpnrdKNCjZJ95oriDYLC9H RJYh57YBFi2kBDRzdRiLEVf8TkkO0FrxMY3y/JB/FSe5T1kDKhaVsgTV/kIbHDL6FEic pigp9+ZFKMCBRp67VuAfYnOXx7K6dhb0l+Fn3ob+t4z8JYcdtF2GFVlmZ0ZlkBuigYPQ AFGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684809908; x=1687401908; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZHxjOHFezdgtF4NBYBIMb6jc3c6vhP3piT2YLvnyXjM=; b=EA5rKr+/OufpKmIKZIg2yO/fqKaaQGqWkT9uOT8hzWJZBFUQebBt4vlmmxat/T0qQp Mue+eWnli1uWTgofY0LaHJtwV8siQYtQ1whcyt8uPuAeSEYVaZQJOG1h3TRIvuQ9SPws Ba5xwBkcJvy4gVsNOMI9+b8UaPwfcbSmiR6bvv4lPJsLXU/LdLPTEed9KndlCWtXRRD6 CDXzNPX/Go9KGHpimeR+PWH2z1su1fa18pbW/1ldWeqRUqgdjkBw27GzdBTTsmN1jPND dQamL88A6BUaB99M6OJmfesKQ1lPExG04IQ5ArinlC2UmXoKUnAy2sBIFfmRSWSo1+kb e1ZA== X-Gm-Message-State: AC+VfDyvWT7B5d9HUGk9CJGVGAAMOKtMjenMhdRqO/brnOCIc55EyQAu u1bCoFrIUyQvJwHC5HEyH38Jyj+/UPHE0NB1R9I= X-Received: by 2002:a17:90a:6309:b0:24d:f1a5:e279 with SMTP id e9-20020a17090a630900b0024df1a5e279mr11549623pjj.12.1684809908632; Mon, 22 May 2023 19:45:08 -0700 (PDT) MIME-Version: 1.0 References: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> In-Reply-To: From: Yang Shi Date: Mon, 22 May 2023 19:44:57 -0700 Message-ID: Subject: Re: [PATCH 25/31] mm/gup: remove FOLL_SPLIT_PMD use of pmd_trans_unstable() To: Hugh Dickins Cc: Andrew Morton , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On Mon, May 22, 2023 at 7:26=E2=80=AFPM Yang Shi wrot= e: > > On Sun, May 21, 2023 at 10:22=E2=80=AFPM Hugh Dickins = wrote: > > > > 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_are= a_struct *vma, > > return follow_page_pte(vma, address, pmd, flags, &ctx->= pgmap); > > } > > if (flags & FOLL_SPLIT_PMD) { > > - int ret; > > - page =3D pmd_page(*pmd); > > - if (is_huge_zero_page(page)) { > > - spin_unlock(ptl); > > - ret =3D 0; > > - split_huge_pmd(vma, pmd, address); > > - if (pmd_trans_unstable(pmd)) > > - ret =3D -EBUSY; > > IIUC the pmd_trans_unstable() check was transferred to the implicit > pmd_none() in pte_alloc(). But it will return -ENOMEM instead of > -EBUSY. Won't it break some userspace? Or the pmd_trans_unstable() is > never true? If so it seems worth mentioning in the commit log about > this return value change. Oops, the above comment is not accurate. It will call follow_page_pte() instead of returning -EBUSY if pmd is none. For other unstable cases, it will return -ENOMEM instead of -EBUSY. > > > - } else { > > - spin_unlock(ptl); > > - split_huge_pmd(vma, pmd, address); > > - ret =3D 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 q= uickly */ > > + return pte_alloc(mm, pmd) ? ERR_PTR(-ENOMEM) : > > follow_page_pte(vma, address, pmd, flags, &ctx-= >pgmap); > > } > > page =3D follow_trans_huge_pmd(vma, address, pmd, flags); > > -- > > 2.35.3 > >