Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1791629rdb; Tue, 3 Oct 2023 00:32:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPglatOup6hGubnPjxwiuJzMr2nQ5FQFll2ifhe7t5T+hTXq2Z/NQ8vafRhyht/2qtUBPB X-Received: by 2002:a17:90b:1d04:b0:268:5bed:708e with SMTP id on4-20020a17090b1d0400b002685bed708emr10426823pjb.24.1696318362477; Tue, 03 Oct 2023 00:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696318362; cv=none; d=google.com; s=arc-20160816; b=Wsf7VrH1BlSVXIu+194tHCkVR228fMvEAfddhIqgwBfbSAlhant63SdCE5zPE1QLoY RTJu7pmNjVf4G5xLJGZFfh2qYd6UcFUi6ZewNjBH7PtTmEl7pnBlW8FOFxHL7bT56twk aBbp2/tswVBGqTqEVsW4KnRUxB7EglquO2UknucZQJZF749LUHTO8nQjTZmBRbs/8uLb +eOdF6iEU+MGhkwEqYlGNsblJUYXREB0GEAYYk2wRuNWgGYXldh2sG+et/tnTfwOW+C8 qJ/3BJ8KGgB+h5hzoFsSsOIUeXjd+o/sDFK0FwsphbJeP9qL0m5veHKZU48ocakbDiPO SwGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=FVpaoZVlYC0SQsn3P6GvLjvnV4rdyJlVcXP8PuYK2TU=; fh=621qCeruO7/VOrees7GgZ0BwCEX3M+UOLKNTFIH1EaU=; b=x8Xbk9ZtYYQE5lOxxzhvEgPhpmqZymDlHO3Y94lkJt6FhX8EZmDJJi2msqei3cA8Mq Wys9V6gw1GC63GGLorgbuu+uecAZVC0ka2zD1wNdg34JIQa3LJZ+qvYm7uyQYhO8EFYn 7lP5IhA6E3EonjD/3UslO32ngrEc5IiPlgvNUpS+PojORI4w+mUpzbOyudjb5v2QYitK j1vIn3z00G4XaDeS/H2XOKdqGsYIct25Jk9H7SPpecMEA92wVZ2PkVMf8msW33ORxh4G WnRr8RQlPPIZ2kXwn1ul1/qO4GXmze+9zeciXn4RngNSfI7E5jFS/srHpXMzGLEFihX4 kdjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bs125-20020a632883000000b00578cbee11easi860472pgb.9.2023.10.03.00.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 00:32:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 7021B81143E0; Tue, 3 Oct 2023 00:32:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbjJCHci (ORCPT + 99 others); Tue, 3 Oct 2023 03:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbjJCHch (ORCPT ); Tue, 3 Oct 2023 03:32:37 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C8B3CA9 for ; Tue, 3 Oct 2023 00:32:34 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C668DC15; Tue, 3 Oct 2023 00:33:12 -0700 (PDT) Received: from [10.57.66.79] (unknown [10.57.66.79]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4E17F3F59C; Tue, 3 Oct 2023 00:32:31 -0700 (PDT) Message-ID: <0fb0840f-02f0-4103-a6be-eeb4fcc16f8f@arm.com> Date: Tue, 3 Oct 2023 08:32:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 7/9] arm64/mm: Override arch_wants_pte_order() Content-Language: en-GB To: Catalin Marinas Cc: Andrew Morton , Matthew Wilcox , Yin Fengwei , David Hildenbrand , Yu Zhao , Anshuman Khandual , Yang Shi , "Huang, Ying" , Zi Yan , Luis Chamberlain , Itaru Kitayama , "Kirill A. Shutemov" , John Hubbard , David Rientjes , Vlastimil Babka , Hugh Dickins , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20230929114421.3761121-1-ryan.roberts@arm.com> <20230929114421.3761121-8-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 00:32:41 -0700 (PDT) On 02/10/2023 16:21, Catalin Marinas wrote: > On Fri, Sep 29, 2023 at 12:44:18PM +0100, Ryan Roberts wrote: >> Define an arch-specific override of arch_wants_pte_order() so that when >> anon_orders=recommend is set, large folios will be allocated for >> anonymous memory with an order that is compatible with arm64's HPA uarch >> feature. >> >> Reviewed-by: Yu Zhao >> Signed-off-by: Ryan Roberts > > Acked-by: Catalin Marinas > >> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h >> index 7f7d9b1df4e5..e3d2449dec5c 100644 >> --- a/arch/arm64/include/asm/pgtable.h >> +++ b/arch/arm64/include/asm/pgtable.h >> @@ -1110,6 +1110,16 @@ extern pte_t ptep_modify_prot_start(struct vm_area_struct *vma, >> extern void ptep_modify_prot_commit(struct vm_area_struct *vma, >> unsigned long addr, pte_t *ptep, >> pte_t old_pte, pte_t new_pte); >> + >> +#define arch_wants_pte_order arch_wants_pte_order >> +static inline int arch_wants_pte_order(void) >> +{ >> + /* >> + * Many arm64 CPUs support hardware page aggregation (HPA), which can >> + * coalesce 4 contiguous pages into a single TLB entry. >> + */ >> + return 2; >> +} > > I haven't followed the discussions on previous revisions of this series > but I wonder why not return a bitmap from arch_wants_pte_order(). For > arm64 we may want an order 6 at some point (contiguous ptes) with a > fallback to order 2 as the next best. > This sounds like good idea to me - I'll implement it, assuming there is a next rev. (Or in the unlikely event that this is the only pending change, I'd rather defer it to when we actually need it with the contpte series). This is just a hangover from the "MVP" approach that I was persuing in v5, where we didn't want to configure too many orders for fear of fragmentation. But in v6 I've introduced UABI to configure the set of orders, and this function feeds into the special "recommend" set. So I think it is appropriate that this API allows expression of multiple orders as you suggest. Side note: I don't think order-6 is ever a contpte size? Its order-4 for 4K, order-7 for 16k and order-5 for 64k.