Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5588918rwb; Tue, 1 Aug 2023 05:15:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlEZl7Ql603Ec+qfE97UBIYpTNOYKKmlwd33MEt0K8p5ggtGrUL1OS1bZLDMA2VU8fJAUsgz X-Received: by 2002:a05:6512:3613:b0:4fe:a2e:890c with SMTP id f19-20020a056512361300b004fe0a2e890cmr1638421lfs.49.1690892103774; Tue, 01 Aug 2023 05:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690892103; cv=none; d=google.com; s=arc-20160816; b=0zAm1gy4F4ctC0LPBYMuYJ74w/enJVTEE3PgVKjQqhhahw1/32sxsG0rHtoqyI1J4a uGwYBl4iBVgELV6ymnoTIMFd7JuO2Hu3niJyT0B1UDir3pOx5JGycjEJ16dVSbitNFYm UfiPCGPfZkwNjd8EdS7Ya/oWzybrcHaHK4ZiLrI/pKyZTFGoRD9XDNbgSNvgyLS7TNdU VckO1ewSPHHLT0qHYMvG/5RESqA4G14uwQ5J7Pp87l94SRbz/C8unBc8CMh7FkhuJpaH SUdHwBLz9MBs4gzA2Bql07pHEJcsqB01+GxRuz8tHwFjg4WIGLUUNW8e1Nr7nJqACful CoPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Ki7VtB/htfjhbg39k2YcdULKNRvpMatY6tXnfypuilA=; fh=RSXLHFGyAGSkmEn+CDvNTunViWhVqIGqePrrYPEAYD8=; b=xZeM0taf73IlHX+UWHmGvPu55lmwJDaOTHJ1Nb01FdRMIcOjuCZ+ZbiJ/5tTxidchk SbaDCwV32c5xrsTNagRx380L+INRlyUFGEZh7nB/NWm/ZiIshOcrytQKbipzT+6ysVXG Gziix7rSw5sU6mVk7Zk6Z9pafqGPjX/Eo7DIazlATPIPM5Y8WFVoVGm9QEVINkxfw5cg s120im5Jct0fhsqOUMViG88xCwylDLZJBzsnSIbzm1u5ATN8noJ2rkaFur9fP72QbrTD rbUvX5H5AgxRiKysMxycaJAiIE1HVVuYoDMIYpD6R9n9n9ZwQFKTOg795IdLAnUUFOnc QQcA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020aa7dd07000000b0051e041a38f0si8257208edv.596.2023.08.01.05.14.38; Tue, 01 Aug 2023 05:15:03 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234314AbjHALO0 (ORCPT + 99 others); Tue, 1 Aug 2023 07:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233738AbjHALOE (ORCPT ); Tue, 1 Aug 2023 07:14:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243ED49F5 for ; Tue, 1 Aug 2023 04:09:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EF1D16150F for ; Tue, 1 Aug 2023 11:09:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20930C433C8; Tue, 1 Aug 2023 11:09:49 +0000 (UTC) Date: Tue, 1 Aug 2023 12:09:47 +0100 From: Catalin Marinas To: Kefeng Wang Cc: Andrew Morton , 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, 21cnbao@gmail.com Subject: Re: [PATCH v2 2/2] arm64: hugetlb: enable __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE Message-ID: References: <20230801023145.17026-1-wangkefeng.wang@huawei.com> <20230801023145.17026-3-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230801023145.17026-3-wangkefeng.wang@huawei.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, Aug 01, 2023 at 10:31:45AM +0800, Kefeng Wang wrote: > +#define __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE > +static inline void flush_hugetlb_tlb_range(struct vm_area_struct *vma, > + unsigned long start, > + unsigned long end) > +{ > + unsigned long stride = huge_page_size(hstate_vma(vma)); > + > + if (stride != PMD_SIZE && stride != PUD_SIZE) > + stride = PAGE_SIZE; > + __flush_tlb_range(vma, start, end, stride, false, 0); We could use some hints here for the tlb_level (2 for pmd, 1 for pud). Regarding the last_level argument to __flush_tlb_range(), I think it needs to stay false since this function is also called on the hugetlb_unshare_pmds() path where the pud is cleared and needs invalidating. That said, maybe you can rewrite it as a switch statement and call flush_pmd_tlb_range() or flush_pud_tlb_range() (just make sure these are defined when CONFIG_HUGETLBFS is enabled). -- Catalin