Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2703564rwp; Fri, 14 Jul 2023 10:00:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlE894+UPV4NNUVD8auN8JyG/Gdc1vqO5xY3jawvii3iXGiqyl/R58dqfLHtclereGLHe5Sq X-Received: by 2002:a17:90a:db06:b0:263:8eec:550f with SMTP id g6-20020a17090adb0600b002638eec550fmr3399061pjv.10.1689354037732; Fri, 14 Jul 2023 10:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689354037; cv=none; d=google.com; s=arc-20160816; b=dYzBKm7uti3QsImwH3+YKKUgiXBVL4JzG57JcLFvh8TVYaQDv/kRkV37MQMrlCJOid JNvOTH8GKqhaWg/1GWWcvTMdIl3pDJtAklAryBlVon1MDgOfR1A5SuN1Tdmj4SQQ/Iie oXX1LA69uMcRH+3mkeSX2SDOIXwc/XNgrHwsb1/duIY2Pixggks/VRs8R+SahR+H6pxo eBmIaLFoqpFoct0czJymAFM/sspINJ6G0GgBbNVhd06cncll6dGFc5rgYUnLIkbkppR1 ojDSTpAGdv5VnVqZFhUweUTVnvTqAy0lHT9zn25sXQqhe0TFUNE8bbvPklEH7EVJ45ze dAnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RwsmSgL54KvIcN9UUxItjXrDFbdgmMPuqsBrxLvJGfQ=; fh=KUn9/czOF/CUegSsbpumpb8eTeZtYrbN2VF58YsSKuI=; b=SzRdjeLpQFBxd3cGUxPK+H9F0DBwUlpaqeaS0c33t40cGmLXt2vTODcwhVnR3+eDEE PvmQmsaBc6ebIsbLrfqM/vLHdYkHcWV+gvAK6+14fVltmB0alorT7spebLoMiMXpWAYu 97St+0JR4raKfM88OhhDIGIZqIgPetA1x5DOhgoVNvc3zVMRWtF62ugu8P61gf7DtgtM XZBrv1GcxEB5bwwAJZjtu224j2fF7XgNv/mA8GxvtavyxAKMUcLyDwD8rIOM0VZYcVDd FGH9TwMbebZIDyJRVz6FRjWqfccho+kE6mYbFJ1+0SYnQjTTKN+5vugKLh6M56zrJTp8 Wh8g== 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 e24-20020a656798000000b005533cf1fdbfsi7418188pgr.629.2023.07.14.10.00.24; Fri, 14 Jul 2023 10:00:37 -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 S236120AbjGNQSJ (ORCPT + 99 others); Fri, 14 Jul 2023 12:18:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236296AbjGNQRt (ORCPT ); Fri, 14 Jul 2023 12:17:49 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F3B0535B3 for ; Fri, 14 Jul 2023 09:17:46 -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 9EB8E1576; Fri, 14 Jul 2023 09:18:28 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 527963F740; Fri, 14 Jul 2023 09:17:44 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Matthew Wilcox , "Kirill A. Shutemov" , Yin Fengwei , David Hildenbrand , Yu Zhao , Catalin Marinas , Will Deacon , Anshuman Khandual , Yang Shi , "Huang, Ying" , Zi Yan , Luis Chamberlain Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 2/4] mm: Default implementation of arch_wants_pte_order() Date: Fri, 14 Jul 2023 17:17:31 +0100 Message-Id: <20230714161733.4144503-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230714160407.4142030-1-ryan.roberts@arm.com> References: <20230714160407.4142030-1-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 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, -- 2.25.1