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 DA5C6C001DF for ; Tue, 1 Aug 2023 13:36:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234105AbjHANgx (ORCPT ); Tue, 1 Aug 2023 09:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232499AbjHANgv (ORCPT ); Tue, 1 Aug 2023 09:36:51 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F337C10DB for ; Tue, 1 Aug 2023 06:36:49 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RFbhw2SLjzrS3m; Tue, 1 Aug 2023 21:35:44 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 1 Aug 2023 21:36:45 +0800 Message-ID: <7208b261-d764-2332-1c0b-ff0cda5469dc@huawei.com> Date: Tue, 1 Aug 2023 21:36:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v2 2/2] arm64: hugetlb: enable __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE Content-Language: en-US From: Kefeng Wang To: Catalin Marinas CC: Andrew Morton , Will Deacon , Mike Kravetz , Muchun Song , Mina Almasry , , , , , , , , <21cnbao@gmail.com> References: <20230801023145.17026-1-wangkefeng.wang@huawei.com> <20230801023145.17026-3-wangkefeng.wang@huawei.com> <4b5a3cfb-e13d-4df4-c08a-fb176cc2cbf6@huawei.com> In-Reply-To: <4b5a3cfb-e13d-4df4-c08a-fb176cc2cbf6@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/8/1 19:22, Kefeng Wang wrote: > > > On 2023/8/1 19:09, Catalin Marinas wrote: >> 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). I try the way your mentioned, it won't change much, will send v3, thanks.