Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2468462rwd; Fri, 9 Jun 2023 11:38:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tYAw9VMSsx54fmAPDC5jZM6pFohTktmZd1bjBctAooHMke+hO3wG/ii1pxGri6jgsTEjU X-Received: by 2002:a17:903:2452:b0:1b1:e327:75f3 with SMTP id l18-20020a170903245200b001b1e32775f3mr1892676pls.67.1686335904277; Fri, 09 Jun 2023 11:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686335904; cv=none; d=google.com; s=arc-20160816; b=KB+SMebDKTjrGh3BKEGSz3WdtRRXtE2NiAyRAuqUNZNFw0QXlEpySlIqYfyb4evfFF jiQLIZJiMXd9v9p7HAuWIycR92pl5J+rQ/86cBDpg6z4ZlSt17sSB4nbkoJ2z3hrC3rv dl5jA/g9FpUjw/sN7Rz9dv2uNPtxCL3aXcvckB6fwWulY4D1FfzBPLe2IJg55FMk42by yy6W5r2fvPxf+gESemiZ2OrfNL8S3FM3fewST2qWzD4mMxWkrbqMYfbHDxjjU7Oq41aa pK0TBzNoZKcoyEIBjSoUCvGQI2S7vn5WHCRA5wc3mlKmU4+2s62ip/Is8oImkphDoRIX yXPg== 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=kR7meK9SrYWFcO0nvlLiL65rZmB26fYCU3wzB0PdsHQ=; b=ugmquwtsPvPiChPamWHrv+R5JJsCs8IeveewNdgYgT2UjMZY917nCf5FhhzVkxK5pA y+wUHhnfJpSJbuAn9ojyZSPeZYVSFSWyIuRmhkQc697pV2oXSjXXA1INyyEEksNDAqfP /uRGvuoql9nnvDwh31QKsBUT1mTaJTB/f5ElRBzvzZPusPaC/V5aX8pKNO1ECzUj03CR 3EXJeXRQKufpLbHlDaXTUnaGrOJkFDiCtSio5wwN2b+gAK0waYl1o1y0pWGgLcg8okhl kDlWFaJoTG5QzAmgoL/KiJSlx2SIunnFCHZDRs8MTqgK5HQy5+RAXobVGLOb0tVEEE89 rxrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=qglArcF5; 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 j14-20020a170903028e00b001b251877944si350937plr.50.2023.06.09.11.38.12; Fri, 09 Jun 2023 11:38:24 -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=qglArcF5; 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 S229664AbjFISZO (ORCPT + 99 others); Fri, 9 Jun 2023 14:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjFISZN (ORCPT ); Fri, 9 Jun 2023 14:25:13 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B91035A9 for ; Fri, 9 Jun 2023 11:25:12 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1b02fcde49aso8360915ad.0 for ; Fri, 09 Jun 2023 11:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686335111; x=1688927111; 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=kR7meK9SrYWFcO0nvlLiL65rZmB26fYCU3wzB0PdsHQ=; b=qglArcF5C7uMcpve+xn5t7ptCNi6uIwQC+132275NZaue9XGXvk2LlsydqyHbQF/U3 DqGDOaVyGxsv/CLoQQ+cJSGL2UeL8zir0ga1+Abo5JI2r+aP27hXfZWjVrVc7+nGlO9y 9u1OUn2sDg0x6cURn52ra0KfysNxyLV58Mot6UfubaxwPwWhFxaxu4rVAThwtIcnGxSz ODRlWBtbE5Iw0YRgP4H7ajsqBrCHlBQaopXQVcszeTFYAEr7YX3PNDDmVOpAvonA45an 1Naz+Ou1NmT+z9LmSwdr2FPgcfQBJbPmXQm3FVE7RDniIvyB4w4ssrudcYVPa45nRg7l sRUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686335111; x=1688927111; 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=kR7meK9SrYWFcO0nvlLiL65rZmB26fYCU3wzB0PdsHQ=; b=OWeGZ/oh2YFBfPfKN7P8Uq4sem3Xrt/B3UABNXOk6CTt8u9aZhI84MTqJdJf3dyOh3 3BR2ppqw00oXa6KwA7z3M41fAo3cWEQwaJphrtqZ8u9zzERRb3aCe3dJ4OguggWrc+lE b7xlctL2iP+8i5iqJ2yQiF3SeONGSRkHJPisFsANSVOVu0HJ3scPUpkhaD+7nm/mBbR0 bUNl3iYe4C5pRhP8GfYrGJhxhYRALx7ZH6Hjc8osdLCaxwq9ZQJTDF26/C5DRaMvTZpY cyz+SJ6z1P3r6mLKitb49Ka4BJyOFPX5xmgN+3x3wWBHb+4lIHOAjxQu1wkdC/9uLNDL c0OQ== X-Gm-Message-State: AC+VfDwFS2O2nkFRVof1Q8nKiYwytRwuP9XX4RZguvdiZiAv2R8p/mwH qk0b3688PNPnTdSyY5Pds9mlNADiEZolkMZR/JE= X-Received: by 2002:a17:903:41ce:b0:1b1:76c2:296a with SMTP id u14-20020a17090341ce00b001b176c2296amr2041083ple.60.1686335111206; Fri, 09 Jun 2023 11:25:11 -0700 (PDT) MIME-Version: 1.0 References: <59fd15dd-4d39-5ec-2043-1d5117f7f85@google.com> In-Reply-To: <59fd15dd-4d39-5ec-2043-1d5117f7f85@google.com> From: Yang Shi Date: Fri, 9 Jun 2023 11:24:59 -0700 Message-ID: Subject: Re: [PATCH v2 25/32] 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 , 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 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 Thu, Jun 8, 2023 at 6:40=E2=80=AFPM Hugh Dickins wrot= e: > > 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->pg= map); > } > 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; > - } 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 qui= ckly */ > + return pte_alloc(mm, pmd) ? ERR_PTR(-ENOMEM) : > follow_page_pte(vma, address, pmd, flags, &ctx->p= gmap); > } > page =3D follow_trans_huge_pmd(vma, address, pmd, flags); > -- > 2.35.3 >