From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D61CC001DF for ; Tue, 1 Aug 2023 11:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233875AbjHALO2 (ORCPT ); Tue, 1 Aug 2023 07:14:28 -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> 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