From patchwork Fri Jul 14 16:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13313837 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A843EB64DC for ; Fri, 14 Jul 2023 16:17:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90EE28E000A; Fri, 14 Jul 2023 12:17:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C078900006; Fri, 14 Jul 2023 12:17:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70FE68E000F; Fri, 14 Jul 2023 12:17:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5B7708E000A for ; Fri, 14 Jul 2023 12:17:49 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 332CE160301 for ; Fri, 14 Jul 2023 16:17:49 +0000 (UTC) X-FDA: 81010723458.21.B7AC580 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf06.hostedemail.com (Postfix) with ESMTP id 791EF18002E for ; Fri, 14 Jul 2023 16:17:47 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf06.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689351467; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RwsmSgL54KvIcN9UUxItjXrDFbdgmMPuqsBrxLvJGfQ=; b=vf2T3Q6Z2O9UGRT3ZXGwnzIRatSMSX5oG1iK16SBb6exwhgKo6lGnoJyVR+0xjuGzRYhfo GcU2f+KF+AnDjhq/WQeIT4ehVxrtAn3h2Np2vepznuC+j9MPsaUXffbTBUfdUxsNRoQWtl V/E3AnfMTc1nSWJh+3GIaG5S33b2sn8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf06.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689351467; a=rsa-sha256; cv=none; b=nr9lvwP8/gDnlgFlvl39SE844kvkgx2qdoxt3UWgL9E7Vv9rC9HuU0orRvrl1fzGC7gle2 9hwiTS0zfse6lahPY7bFBklF3ReU0iJIuJ0hnNIt6NrtF2Q2ia3mQpMLhd1MtOdVVLjvg8 z6ORveN85IREO/6jVxfZgOrO6BakVGs= 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 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 791EF18002E X-Stat-Signature: jc9jx4enr799x5bjqgwyacyohog9yk1y X-HE-Tag: 1689351467-710830 X-HE-Meta: U2FsdGVkX18Ho40TwBz2kUL9CfHN9NkCZeb+rdQq2CLpkCgfdWlla3inqkWoy16O/kDV8Lgl65f3a+UenRhKdNBMtVE5You2Zi4tiAAKC036Xh6YTD905nVvrpFYakESNC5vyct5eF1C/7HjEUguqsgsYPqoZFTH5Fi60Dhze3t+PD87RiFRGHpsMMxv9w8NsnNLwLkiOlBAzEsj9Ketubi3+muTB56G2g7BIqIIPgVOsZOF5M77j6PCZYiQaxseW6HKPANd+RWVffEBCSzXz0NS5LCpVwoI2LOQ2RpB8x2tPVK+5ynCFSeWgE+JxHX1qfaqJCd4xLOaGsdTjW7uieMR+uyhqYWNA+P1NYiUDrYaFeJC0lzNXq5FpbnvGRWk5bPVrhF8nNxl/3k33plkoDmegs6eY7qAkO+bgV4kpnGz/2ZTguKTdqtbPmBEiof8RaLMcgNUA7w90KVpe5kraTtKziT5qbQkK44r/KorajeIZCfVgWoHxX7bbCUjlTEFNtn2sjwuW8nlvM2wSfwGDVKnGgPPAVMr+QbSwYgKUjFrdBTVvVqpZvq64S5IfyeLUg4w6SdxQnG1eZXTj2yd3t266iELkgQfnrtYuty12WPDmkbQJM/tKfxoTtZHwJVuyQttD5UpNDupxMsQcAnhh65GuepWDv6O7ZFc9DbJVF2lt28su7Nc2ZGSEWnYnXNui6XuN3lniNAeosFEIvdw8lhjfswW76JXlxJk/5sT15y9RxtPzogExpxkjuhdylNB83DzhTeWWdKqUSHkBqi81MNZkWoNNz7gcs4MG3S+GMA6NaTqmHMObcaeeAn2DnC5hFMtA3Dv4bIOvz3UgvjUw1kfSGFvnsOSWql5u69HpBwNVYvHpyL8UUNFhO78JPyREboqaQce8NrdWOsUsKTlQ7bkg2cwLkxgVCC9WP7KQ8ncvAGnFQ2wDxgWzsKoBBM+IogjdL1YWRWlQomwcLe UIiO9wgI 8W9z874cvIbrGs5m3ou71bgckqR0wfRM36VJqAjlD2idbN6pS/EVXXCnCw2+2ITzMcLpsYnMylUc8BmO5IZQ7A21z0oBSB/HEsm9zU2q5nF8ldwhAstWl6lvTqre6K/wQgGrTvYNu/csespZcaBJ6iii3KFiW9b3BI7C6ba5rJBLgXfGT05LGbgnNCoOfQfn7Y9CpHD3Yigg+SRw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Yu Zhao Reviewed-by: Yin Fengwei --- 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,