From patchwork Fri May 17 18:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13667310 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 9D1A1C04FFE for ; Fri, 17 May 2024 19:00:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D2966B008A; Fri, 17 May 2024 15:00:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25B276B008C; Fri, 17 May 2024 15:00:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 149A86B0092; Fri, 17 May 2024 15:00:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E82616B008A for ; Fri, 17 May 2024 15:00:17 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6B4F01C09AF for ; Fri, 17 May 2024 19:00:17 +0000 (UTC) X-FDA: 82128803274.04.029F59C Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf16.hostedemail.com (Postfix) with ESMTP id 44F3C180017 for ; Fri, 17 May 2024 19:00:15 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf16.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715972415; 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=wYTKjrLt87Fe/e1PAvuMThWwYR3/JPu2eipCFurKucc=; b=eckm4NLbCJBxM1osuz4gT2Z4GpJN4W7H1KU7z3ctlwhF1ebRqDkMILShbybpS23i8LjbKx BLTNOcHMWCaZdoCGUxJAjHx7LqxsPCsnSlSD9MD918bWgyrfeeBGDQP9tROHfRfwrl50hA rCqOP0sARv5wgm9n8U+FfawyOhuf7fY= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf16.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715972415; a=rsa-sha256; cv=none; b=rGahS0byW5r2AuentqiuJ4FRo2uRDr+Dp/qBjfiDc6zdn6x2BWxVhIwIgP489mQgdteOdE TgKhGfV6GqZStsY15h10s168wSzLRvAvRAvKFuXFjX2cLv2EdLAGjbrt83uzl29xaUVaVj pz/YLvGNULshF916PoQfzza/ulx/Ly8= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4Vgx9K2jYtz9swJ; Fri, 17 May 2024 21:00:05 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gMGO7naZoj9R; Fri, 17 May 2024 21:00:05 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4Vgx9J2YGvz9st0; Fri, 17 May 2024 21:00:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 531748B783; Fri, 17 May 2024 21:00:04 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 9pZ5saJOEJBi; Fri, 17 May 2024 21:00:04 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.121]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BFECB8B766; Fri, 17 May 2024 21:00:03 +0200 (CEST) From: Christophe Leroy To: Andrew Morton , Jason Gunthorpe , Peter Xu , Oscar Salvador , Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH v2 02/20] mm: Provide page size to pte_alloc_huge() Date: Fri, 17 May 2024 20:59:56 +0200 Message-ID: <948e6fc68864c828d29378b6a6cdd646978f0d72.1715971869.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715972396; l=4165; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=CTYyLk66YS0+OdgpLXOZR1qF0kcbsr8yDQZpdQ5zBt4=; b=dAKl6Em8xkfyfxIIKsYEdC7P9K8L8qBOqIPl6RMLJyfgLNi/KfzNUajNF3HAgqR1hUOVvbtT3 q99tm0UJjHpDPZYvntspvgUWxi3wQLhboksALUd5IY1rTrYJNY1mhJh X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 44F3C180017 X-Stat-Signature: kojq4z5zkx73miumhcjaxmd87xm9da46 X-HE-Tag: 1715972415-758234 X-HE-Meta: U2FsdGVkX1/KfdvXQv4YDJ9QXa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ppcoWdENfaq2RXNgXUEmG3nL6SikjFnf6NybjUKDJQGwADicqyUGAgsObFxlk1rIYybAq7xiBDcvMBf4= 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: List-Subscribe: List-Unsubscribe: In order to be able to flag the PMD entry with _PMD_HUGE_8M on powerpc 8xx, provide page size to pte_alloc_huge() and use it through the newly introduced pte_alloc_size(). Signed-off-by: Christophe Leroy --- arch/arm64/mm/hugetlbpage.c | 2 +- arch/parisc/mm/hugetlbpage.c | 2 +- arch/powerpc/mm/hugetlbpage.c | 2 +- arch/riscv/mm/hugetlbpage.c | 2 +- arch/sh/mm/hugetlbpage.c | 2 +- arch/sparc/mm/hugetlbpage.c | 2 +- include/linux/hugetlb.h | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index b872b003a55f..aa7ded49f8cf 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -292,7 +292,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; WARN_ON(addr & (sz - 1)); - ptep = pte_alloc_huge(mm, pmdp, addr); + ptep = pte_alloc_huge(mm, pmdp, addr, sz); } else if (sz == PMD_SIZE) { if (want_pmd_share(vma, addr) && pud_none(READ_ONCE(*pudp))) ptep = huge_pmd_share(mm, vma, addr, pudp); diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c index a9f7e21f6656..2f4c6b440710 100644 --- a/arch/parisc/mm/hugetlbpage.c +++ b/arch/parisc/mm/hugetlbpage.c @@ -66,7 +66,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, if (pud) { pmd = pmd_alloc(mm, pud, addr); if (pmd) - pte = pte_alloc_huge(mm, pmd, addr); + pte = pte_alloc_huge(mm, pmd, addr, sz); } return pte; } diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 594a4b7b2ca2..66ac56b26007 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -183,7 +183,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; if (IS_ENABLED(CONFIG_PPC_8xx) && pshift < PMD_SHIFT) - return pte_alloc_huge(mm, (pmd_t *)hpdp, addr); + return pte_alloc_huge(mm, (pmd_t *)hpdp, addr, sz); BUG_ON(!hugepd_none(*hpdp) && !hugepd_ok(*hpdp)); diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index 5ef2a6891158..dc77a58c6321 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -67,7 +67,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, for_each_napot_order(order) { if (napot_cont_size(order) == sz) { - pte = pte_alloc_huge(mm, pmd, addr & napot_cont_mask(order)); + pte = pte_alloc_huge(mm, pmd, addr & napot_cont_mask(order), sz); break; } } diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c index 6cb0ad73dbb9..26579429e5ed 100644 --- a/arch/sh/mm/hugetlbpage.c +++ b/arch/sh/mm/hugetlbpage.c @@ -38,7 +38,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, if (pud) { pmd = pmd_alloc(mm, pud, addr); if (pmd) - pte = pte_alloc_huge(mm, pmd, addr); + pte = pte_alloc_huge(mm, pmd, addr, sz); } } } diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index b432500c13a5..5a342199e837 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -298,7 +298,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; if (sz >= PMD_SIZE) return (pte_t *)pmd; - return pte_alloc_huge(mm, pmd, addr); + return pte_alloc_huge(mm, pmd, addr, sz); } pte_t *huge_pte_offset(struct mm_struct *mm, diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 77b30a8c6076..d9c5d9daadc5 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -193,9 +193,9 @@ static inline pte_t *pte_offset_huge(pmd_t *pmd, unsigned long address) return pte_offset_kernel(pmd, address); } static inline pte_t *pte_alloc_huge(struct mm_struct *mm, pmd_t *pmd, - unsigned long address) + unsigned long address, unsigned long sz) { - return pte_alloc(mm, pmd) ? NULL : pte_offset_huge(pmd, address); + return pte_alloc_size(mm, pmd, sz) ? NULL : pte_offset_huge(pmd, address); } #endif