Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5881767rwb; Tue, 1 Aug 2023 09:07:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlG0cI8qb7xrQynAG0Nmvn4+6y8nwGpYlXe5/BvuUGnt+DW0s+bjOI58xD0/LF7qt+fGQ/Fo X-Received: by 2002:a17:902:a405:b0:1bb:b86e:8d6d with SMTP id p5-20020a170902a40500b001bbb86e8d6dmr11366727plq.29.1690906046356; Tue, 01 Aug 2023 09:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690906046; cv=none; d=google.com; s=arc-20160816; b=eBBSMG50vspQ/qHhsjpi/E24LO4cpCH1e4xB1qPrnjk5shsKg5hJqz1aOQK0lA526G fpCxtaralshTB0p9LDwVJc1vAVEHflw//11MtrvBZtBfC7q3zBL9YPHmZciadMRASA+X pmarvyapAoJjnzoOfZjhOQFCMPdX8rMxxgefx3FQXI6ESEP1y4BlOfUyQ2XL4D4QADe8 Jk4Se9eHqaMvy7O1oP/pw6M27LilNHKlMY0TVQ4m9AgnrZcQuWJb1Xk6w/014l2PYSIi iqPONvfOP1JjEg9TyHHIueIRXijDxCTWhVklIwoaJ0D+JrAKieJOH7FinAJZKWj9bWt0 F+wg== 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=KKbznrcKlkp6XdAUuWkM4XjqWQxuov1aSrRpz+HHAus=; fh=RSXLHFGyAGSkmEn+CDvNTunViWhVqIGqePrrYPEAYD8=; b=OMiZgihmg8GTWNij9CczObz5F8BFpXEH6hn9l172NzvYPSw1Bo/j790TObbnrpLhi6 P73VF3QUa4Xkvgql39JQma7f5oGt3bWHucOTTYoWJdtDPsHI33CiLFOJAeTgxeFe/iZi pCEFTDQUjR+tiIaDjGheZ5ZuzVBxMs8qheOrdtyerdWHi5pds/V2beGrl7VUQrCtgkLS 59e910OORoNM1vxGTkgIjM5tRooM98EyQKZ4uNwZDllpUlx6n3q/nxV6FVDW6qwopzOR VConl52oyEGp1EpAdjAHZaTnp58f63wjdh3FDAfjBzjs+WZB9XGEDcZt03KHWQ3Frc8i iUFg== 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 kw7-20020a170902f90700b001b0450241d1si2251401plb.283.2023.08.01.09.07.05; Tue, 01 Aug 2023 09:07:26 -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 S232568AbjHAP2r (ORCPT + 99 others); Tue, 1 Aug 2023 11:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbjHAP2q (ORCPT ); Tue, 1 Aug 2023 11:28:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 905E4193 for ; Tue, 1 Aug 2023 08:28:45 -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 2EB88615DE for ; Tue, 1 Aug 2023 15:28:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D81CC433C8; Tue, 1 Aug 2023 15:28:36 +0000 (UTC) Date: Tue, 1 Aug 2023 16:28:33 +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 v3] arm64: hugetlb: enable __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE Message-ID: References: <20230801023145.17026-3-wangkefeng.wang@huawei.com> <20230801135616.165067-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230801135616.165067-1-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 09:56:16PM +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)); > + > + switch (stride) { > +#ifndef __PAGETABLE_PMD_FOLDED > + case PUD_SIZE: > + flush_pud_tlb_range(vma, start, end); > + break; > +#endif > + case PMD_SIZE: > + flush_pmd_tlb_range(vma, start, end); > + break; > + default: > + __flush_tlb_range(vma, start, end, PAGE_SIZE, false, 0); > + } > +} I think we should be consistent and either use __flush_tlb_range() everywhere or flush_p*d_tlb_range() together with flush_tlb_range(). Maybe using __flush_tlb_range() for the pmd/pud is not too bad, smaller patch. That said, I'd avoid the #ifndef and just go for an if/else statement: if (stride == PMD_SIZE) __flush_tlb_range(vma, start, end, stride, false, 2); else if (stride == PUD_SIZE) __flush_tlb_range(vma, start, end, stride, false, 1); else __flush_tlb_range(vma, start, end, PAGE_SIZE, 0); With the pmd folded, the P*D_SIZE is the same and the compiler should eliminate the second branch. -- Catalin