Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5575737rwp; Mon, 17 Jul 2023 06:27:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlHxeH9eu4eWXjJ4jOB1PZDJvlOiMKVpQHEpkL/oS01dfZ2vxtwixLKMfOBAGYQyhV2dw/1X X-Received: by 2002:a05:6a00:3a26:b0:67f:1d30:9e51 with SMTP id fj38-20020a056a003a2600b0067f1d309e51mr14698875pfb.33.1689600470172; Mon, 17 Jul 2023 06:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689600470; cv=none; d=google.com; s=arc-20160816; b=0slNotsmr6plxKUPl4KgEKsNGD73Iq/DxHICBojqG7vvkfnuBL15ckqaL5m+gVEj/n BfWdww7Vnbyohm8kV9HvLIH93mT6nX9bAm++Yne7XrV+91eKJdtM3BKfvUZXnKMdZPdy jiZaSh8NJRf/o5N1930Gba1dIAAys6Ro+U93MStHtsBqj9ClFcSFOPRY4b7crbjL/r6s y4J0kHBPxlGOtIRxGoTpMsBxvCSXVqCw9PyChwXzBXumtIRrM4/t24yf3Qi73JqA+0U7 mN6GRSd6SmbIS/m3EXCIlOILJdjZ967zQmv6CHCQUsmFFSeNL4PTOYdzryUsBEUSx8jE /6Mg== 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:subject:user-agent:mime-version:date:message-id; bh=aNJ8k9Uspo4Tyj3NwE/QcgCwC947zqoXAIWJdkvrO/Q=; fh=SvddnUkB+Bq+JeHaEOef2xjELFndJBUtlrl/Wc/zdw8=; b=xwCto7HYDtqkz/+14Hb3HESuvnJNyQu1/v/1cQ114oVbNV48uNaYNMeO64WU3xEdt6 H30zzI6wq0MRU1mCcxeRu2NlCpD6U2F2eRnbknt4UbwzpaUKu5Hs/JIOHNLUUct0bmI6 S+rjwWHImsLfWix7ITTM/+9QUszvMtRknX9fV87IpS9tvuLmS99XgrNcXHnLL2dKgOO6 wLzbSiGHwM/3Kf7NAsZKxzsVWHIBV6nSvBWPiNdeI+Ji3LDYvhdBlRPgaXbwZcYPl89k lsrZkXyfisojd9Wbp+REfNWzsZg6Wv6JPxMNsQxLTJvwkbn5mrKVSUGQy3hz5DEx47wi t28Q== 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 cq9-20020a056a00330900b0066844d4ec59si4614869pfb.168.2023.07.17.06.27.37; Mon, 17 Jul 2023 06:27:50 -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 S230422AbjGQNP0 (ORCPT + 99 others); Mon, 17 Jul 2023 09:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230219AbjGQNPX (ORCPT ); Mon, 17 Jul 2023 09:15:23 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8C7ADC7 for ; Mon, 17 Jul 2023 06:15:22 -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 A4B4DD75; Mon, 17 Jul 2023 06:16:05 -0700 (PDT) Received: from [10.57.76.30] (unknown [10.57.76.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E9183F67D; Mon, 17 Jul 2023 06:15:19 -0700 (PDT) Message-ID: <7e7145b0-149c-c09d-08a6-99227519df87@arm.com> Date: Mon, 17 Jul 2023 14:15:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 2/4] mm: Default implementation of arch_wants_pte_order() To: David Hildenbrand , Andrew Morton , Matthew Wilcox , "Kirill A. Shutemov" , Yin Fengwei , Yu Zhao , Catalin Marinas , Will Deacon , Anshuman Khandual , Yang Shi , "Huang, Ying" , Zi Yan , Luis Chamberlain Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230714160407.4142030-1-ryan.roberts@arm.com> <20230714161733.4144503-2-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On 17/07/2023 14:01, David Hildenbrand wrote: > On 14.07.23 18:17, Ryan Roberts wrote: >> arch_wants_pte_order() can be overridden by the arch to return the >> preferred folio order for pte-mapped memory. This is useful as some >> architectures (e.g. arm64) can coalesce TLB entries when the physical >> memory is suitably contiguous. >> >> The first user for this hint will be FLEXIBLE_THP, which aims to >> allocate large folios for anonymous memory to reduce page faults and >> other per-page operation costs. >> >> Here we add the default implementation of the function, used when the >> architecture does not define it, which returns -1, implying that the HW >> has no preference. In this case, mm will choose it's own default order. >> >> Signed-off-by: Ryan Roberts >> --- >>   include/linux/pgtable.h | 13 +++++++++++++ >>   1 file changed, 13 insertions(+) >> >> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h >> index 5063b482e34f..2a1d83775837 100644 >> --- a/include/linux/pgtable.h >> +++ b/include/linux/pgtable.h >> @@ -313,6 +313,19 @@ static inline bool arch_has_hw_pte_young(void) >>   } >>   #endif >>   +#ifndef arch_wants_pte_order >> +/* >> + * Returns preferred folio order for pte-mapped memory. Must be in range [0, >> + * PMD_SHIFT-PAGE_SHIFT) and must not be order-1 since THP requires large folios >> + * to be at least order-2. Negative value implies that the HW has no preference >> + * and mm will choose it's own default order. >> + */ >> +static inline int arch_wants_pte_order(void) >> +{ >> +    return -1; >> +} >> +#endif >> + >>   #ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR >>   static inline pte_t ptep_get_and_clear(struct mm_struct *mm, >>                          unsigned long address, > > What is the reason to have this into a separate patch? That should simply be > squashed into the actual user -- patch #3. There was a lot more in this at v1 IIRC, so made more sense as standalone. I agree it can be squashed into the next patch now. Will do for next version. >