Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4161963rwb; Mon, 31 Jul 2023 02:24:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlGL1jCMIRl0svKFfflTjWFZvIS3meM0EfpA+WrDsLpJNjikK0IF8zB1Q8jpLw7NLuIrrDht X-Received: by 2002:a05:622a:18a3:b0:40e:cda8:dc23 with SMTP id v35-20020a05622a18a300b0040ecda8dc23mr2480764qtc.9.1690795480572; Mon, 31 Jul 2023 02:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690795480; cv=none; d=google.com; s=arc-20160816; b=izP0SyQLOAOcSeQjGoHJ2BH2p9DUmgPaQfQIenNeh6qdIPJCb9kcVjulK6GN+AnQ6G dnnZzvBceHCQ+phyU/06RMl6vyQohFLu14fKrcB0ewfzPEClugNsl64NZcsM1EPm9q3b Dm10Qzasd8TaEleWIXqv2CvCsKv3kf4HzBAY1ueyKvScwxU97vNlN5DDG7/geuUpOacX 9FM17MLjVfJXITyUT8d/dzL+SNqtCs3e+w8E1BkednUpOyjhA4QYTVm/TRhwc2523G3b vzja6cAY5njYQaVyXD6nOrmDmWJ+M1qpRhC2dUnwCiyUD8/YwVdTH/dDX10FhAc7CuqV m9xQ== 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=ckP7NF4Z1GYTZiK2dYi1nNlDBTWx4/E1X/qSymornb4=; fh=nm1Uwau7ybVci/YuVDeY6HdqJb0Y/HCPv05BTJJoEvE=; b=YjqCGj4GX87zcFpKhV2p94LOd/7Gfb1n8O2fsVkuMw43FzAXFADjSeeUGQbr6FDS57 /MdPvpyQwH3BWO/fkwUo97emkEaqcSWaYXdR4Oa6EIyfdWV57rGGLz5QjpAF8AyLc4mr sqXBZZzDuFrmm+QYlBnutkKplQua8XHqxqqjvMhXdawk/4yvnVQbwi+C6vuLKpusQi4u 3gSWN/pgw+D9YJEg7JERUW1914Q6MaX0oCueTRBbV7hQqC76xgDwkF2C8evfpU//Gv3f LYTraDTGbiRINZWuK89Z2BbYoSi7b6bzy/Mkoc+BkQV/vUH8jhOhUdQqzwr7ahvTM2KV EFEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=guWCLMET; 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 4-20020a630e44000000b00563e15edb8bsi6068304pgo.370.2023.07.31.02.24.21; Mon, 31 Jul 2023 02:24:40 -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=guWCLMET; 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 S230214AbjGaIiY (ORCPT + 99 others); Mon, 31 Jul 2023 04:38:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbjGaIh0 (ORCPT ); Mon, 31 Jul 2023 04:37:26 -0400 Received: from mail-vk1-xa34.google.com (mail-vk1-xa34.google.com [IPv6:2607:f8b0:4864:20::a34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9434BE57 for ; Mon, 31 Jul 2023 01:33:48 -0700 (PDT) Received: by mail-vk1-xa34.google.com with SMTP id 71dfb90a1353d-486198c70adso1342486e0c.0 for ; Mon, 31 Jul 2023 01:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690792427; x=1691397227; 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=ckP7NF4Z1GYTZiK2dYi1nNlDBTWx4/E1X/qSymornb4=; b=guWCLMET61252C+Y3fHlLWURhdE33BrI72qoF3c3XbX3saGrvm5yGS7DN+T13z9opB GkF+MFpYqRTjp3KZ3qrZtTCcvFP05XmUYYHuYnSZ2QAYWCRoyWGnb5X+u5hzLx/UhenD wahK+HTVUyA/dbOZjpxeK16hBdGCTSjutPtR1N8jAKrgyEQissAUDWm9IEcVNOtbTp7+ l90XD8MeYwuvXIC9XsnPpDZFGnMIVkzrmu23rHRnLK5cupra2yZN/qYVSL75/MMKrJPb 6nTKVzO7aB6eG5t6FmMofBadGV62EfIdWQN+rbZxqfNjrtvloHDbzzSeaMWNIl71m41a nuTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690792427; x=1691397227; 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=ckP7NF4Z1GYTZiK2dYi1nNlDBTWx4/E1X/qSymornb4=; b=L9ygJMYCEETZqYiHxSDCJIC1ycqY6vWmjowCyI2yqOp3fetF1b2ylh7fwOh3wwonHG 1KkrDwOK4xli47jOcoDe3hSBTNfgRjukB393p2dh1BG+MC7Jukn3XDSYTlRRhN14NrrV j6qDROpRXY+tmYWUx/wrWIXGEqMfScMqexlYzzomkTHaC/Y7JpUkaKzJISvSpAZXNmsD IE3Dnyp/ND/k3+nLc3pF1Mb0muPBSzcrj7PXoSxz0+2NSVigtJCRQGtnmjXVxtU+96Ko Djxq97oUWiIdO3yaaa5VLAcVJJhyaJyw+ZjhpwmJ+ktngih9cBNk5r3XP199yT/iMNfM Jm+w== X-Gm-Message-State: ABy/qLa+gAMwdhcEBd844JSF+h9/MsxXDEZmkF9wIWt4gRvv8ZKO5mQG kHPpyfHO3FYYRjmxujXr/nafpQVhJdAvZTnj30BuWeENWd+knQ== X-Received: by 2002:a1f:6013:0:b0:486:4c0b:b4cf with SMTP id u19-20020a1f6013000000b004864c0bb4cfmr4757886vkb.10.1690792427512; Mon, 31 Jul 2023 01:33:47 -0700 (PDT) MIME-Version: 1.0 References: <20230731074829.79309-1-wangkefeng.wang@huawei.com> <20230731074829.79309-5-wangkefeng.wang@huawei.com> In-Reply-To: <20230731074829.79309-5-wangkefeng.wang@huawei.com> From: Barry Song <21cnbao@gmail.com> Date: Mon, 31 Jul 2023 16:33:36 +0800 Message-ID: Subject: Re: [PATCH 4/4] arm64: tlb: set huge page size to stride for hugepage To: Kefeng Wang Cc: Andrew Morton , Catalin Marinas , Will Deacon , Mike Kravetz , Muchun Song , Mina Almasry , kirill@shutemov.name, joel@joelfernandes.org, william.kucharski@oracle.com, kaleshsingh@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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, Jul 31, 2023 at 4:14=E2=80=AFPM Kefeng Wang wrote: > > It is better to use huge_page_size() for hugepage(HugeTLB) instead of > PAGE_SIZE for stride, which has been done in flush_pmd/pud_tlb_range(), > it could reduce the loop in __flush_tlb_range(). > > Signed-off-by: Kefeng Wang > --- > arch/arm64/include/asm/tlbflush.h | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > > diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/t= lbflush.h > index 412a3b9a3c25..25e35e6f8093 100644 > --- a/arch/arm64/include/asm/tlbflush.h > +++ b/arch/arm64/include/asm/tlbflush.h > @@ -360,16 +360,17 @@ static inline void __flush_tlb_range(struct vm_area= _struct *vma, > dsb(ish); > } > > -static inline void flush_tlb_range(struct vm_area_struct *vma, > - unsigned long start, unsigned long end= ) > -{ > - /* > - * We cannot use leaf-only invalidation here, since we may be inv= alidating > - * table entries as part of collapsing hugepages or moving page t= ables. > - * Set the tlb_level to 0 because we can not get enough informati= on here. > - */ > - __flush_tlb_range(vma, start, end, PAGE_SIZE, false, 0); > -} > +/* > + * We cannot use leaf-only invalidation here, since we may be invalidati= ng > + * table entries as part of collapsing hugepages or moving page tables. > + * Set the tlb_level to 0 because we can not get enough information here= . > + */ > +#define flush_tlb_range(vma, start, end) \ > + __flush_tlb_range(vma, start, end, \ > + ((vma)->vm_flags & VM_HUGETLB) \ > + ? huge_page_size(hstate_vma(vma)) \ > + : PAGE_SIZE, false, 0) > + seems like a good idea. I wonder if a better implementation will be MMU_GATHER_PAGE_SIZE, in this = case, we are going to support stride for other large folios as well, such as thp. > > static inline void flush_tlb_kernel_range(unsigned long start, unsigned = long end) > { > -- > 2.41.0 > Thanks Barry