From patchwork Mon Mar 25 14:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13602368 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 AC369C54E64 for ; Mon, 25 Mar 2024 14:56:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CC6F6B0088; Mon, 25 Mar 2024 10:56:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27D426B0089; Mon, 25 Mar 2024 10:56:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11E6D6B008A; Mon, 25 Mar 2024 10:56:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EDDC46B0088 for ; Mon, 25 Mar 2024 10:56:24 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8A40B160529 for ; Mon, 25 Mar 2024 14:56:24 +0000 (UTC) X-FDA: 81935862288.04.9007588 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf06.hostedemail.com (Postfix) with ESMTP id 526D1180013 for ; Mon, 25 Mar 2024 14:56:22 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf06.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=1711378582; 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=qUkEJqYUVjEh5Z6oyXqL7B5FhLnD5QL9G0hteLFS7dg=; b=DxzRdQ2CPOpOvmyN4hRyog3fTOUsHa9GnqskxgcwqPSLUpa7eJHjSPkvGEqThC1EC6hAau p9d+MMFZLCloOxLo7snGtfrLE1yOwv67CHot9goiPw7tuCLj5Nl4B5A0yAiZ1BxntDnb41 a4LTrjuXQ3hZykufwHy622Z5MHQZxUY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf06.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=1711378582; a=rsa-sha256; cv=none; b=VqL1/10FFO/6mBoBwLUMp3uabFrK4JrIlFk1mYygYksTcQJCCW8BK9z+NZw3HA5q9q+TCq TVL9qgnjAFbmOD2ndGY4FLHs3GHb3DfNCRUfhGJbToG6yHQblNuipXdz95T/d9C2yB56t7 qAR3p+aRbFlxwM3I1PbIoeYt39VfK9I= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4V3GGN4Xwnz9sqS; Mon, 25 Mar 2024 15:56:12 +0100 (CET) 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 Dh3jRGrDMhrs; Mon, 25 Mar 2024 15:56:12 +0100 (CET) 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 4V3GGK2Nmzz9sHR; Mon, 25 Mar 2024 15:56:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4EBDB8B765; Mon, 25 Mar 2024 15:56:09 +0100 (CET) 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 A_57aGmhzA1A; Mon, 25 Mar 2024 15:56:09 +0100 (CET) Received: from PO20335.idsi0.si.c-s.fr (unknown [172.25.230.108]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2208C8B76E; Mon, 25 Mar 2024 15:56:09 +0100 (CET) From: Christophe Leroy To: Andrew Morton , Jason Gunthorpe , Peter Xu Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 2/8] mm: Provide page size to pte_alloc_huge() Date: Mon, 25 Mar 2024 15:55:55 +0100 Message-ID: <32f0c0802a202cc738f3f21682f53d76f01fc70e.1711377230.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1711378567; l=4165; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=G0Wo+zSPvm0zKcYamX7mo4IBjfP690rcbl767tVRdqk=; b=FskSsaG4xsnz5gHg1RDzdpAAKIx/z4JVr9MAnODJ+e8Ywfb4R16JcI9JRXe2WOfUslhVdSRvk VwbcylHgRCdB6arpi04zDdwNgCSdflFTtov6OEfbi3s3u+96ivxekvC X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Queue-Id: 526D1180013 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: oqwosgi8xpnbfm98ycd5w6paxkz1wqez X-HE-Tag: 1711378582-193845 X-HE-Meta: U2FsdGVkX196xjEM5Yv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FKwVsxo+0Ftez8lyTpARSAEe5Kk5kd1Ec2P5p+HBj86i0no6hxntq07LO40URlk0PvfSE= 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 0f0e10bb0a95..71161c655fd6 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -289,7 +289,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