From patchwork Fri May 17 18:59:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13667311 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 39738C04FFE for ; Fri, 17 May 2024 19:00:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6EEC6B008C; Fri, 17 May 2024 15:00:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1F786B0092; Fri, 17 May 2024 15:00:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE7E16B0093; Fri, 17 May 2024 15:00:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 908EF6B008C for ; Fri, 17 May 2024 15:00:21 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 48CF61204B8 for ; Fri, 17 May 2024 19:00:21 +0000 (UTC) X-FDA: 82128803442.22.A883AD1 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf03.hostedemail.com (Postfix) with ESMTP id 2160020027 for ; Fri, 17 May 2024 19:00:18 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf03.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=1715972419; 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=J6qNqEo1Gxqk9ayHNCYLAa2uGeZ6NbYgAu/Wwmqm2V4=; b=zhQFnfpzkZT/TfRcSGtTLoUzRJRrMfsHViRvaxZpPOTwu0Q/FWxLHOO6blpmRKQSxQdFCp SccwOHwtgW4UXAoZ/OQZ7yhVtQ/l1UEtXfU2FFPd0kfXD8D7zsx6af+fIYTXEIPwevG7dD /U2I8TD+Fojl++Yw/Cm0h2Koe37VILU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715972419; a=rsa-sha256; cv=none; b=eaPhImqvJ8pXc2WAHMZX0DRekJGkhqbvPqpoyGVP9R4HqrYuli8tgz+BTGCiX+hzkz4lA0 wgY0TMGLb0EJpxzNgmj2deKVw3Th1jfy/H4UXWWcGQuRoLdJj4VZTuaNH2vI4GotoxHVc9 hkeLTNUkm5TgTxdC2Fl3/+lAleIZMSY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf03.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4Vgx9L15H6z9syQ; Fri, 17 May 2024 21:00:06 +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 ZubkgE9RBfQR; Fri, 17 May 2024 21:00:06 +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 4Vgx9J6TWWz9sv8; 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 D9E288B783; 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 K8bPZqaUNiS5; 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 4D7848B775; Fri, 17 May 2024 21:00:04 +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 03/20] mm: Provide pmd to pte_leaf_size() Date: Fri, 17 May 2024 20:59:57 +0200 Message-ID: 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=4424; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=Dh0nhguSpL9n3XQFSbUbzJ8GDug0jKbT2rL1D1ri4LQ=; b=wvraNPMkAKUlglx94Er8Qmm1y2YxNqFMrMAfd0xmtKmew69Jy03RGG1CstL3zHihW0dmzSVVd vdSl4fQh+mcBXkBHxMcABuo4U+z1HETYzKkIEE25b/I7VEwLq9+t2J8 X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Stat-Signature: y6ek73gx9g31hcromki4qaf8jxndoexr X-Rspamd-Queue-Id: 2160020027 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1715972418-36264 X-HE-Meta: U2FsdGVkX1+8Vo4RySpxZ4rXFs3/kIJA+dbmQNlyfBkQt6Meq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WSQlSnyLmxmNlzgBPCiFW0qRXdiwDU= 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: On powerpc 8xx, when a page is 8M size, the information is in the PMD entry. So provide it to pte_leaf_size(). Signed-off-by: Christophe Leroy --- arch/arm64/include/asm/pgtable.h | 2 +- arch/powerpc/include/asm/nohash/32/pte-8xx.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- arch/sparc/include/asm/pgtable_64.h | 2 +- arch/sparc/mm/hugetlbpage.c | 2 +- include/linux/pgtable.h | 2 +- kernel/events/core.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index afdd56d26ad7..57c40f2498ab 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -624,7 +624,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, #define pmd_bad(pmd) (!pmd_table(pmd)) #define pmd_leaf_size(pmd) (pmd_cont(pmd) ? CONT_PMD_SIZE : PMD_SIZE) -#define pte_leaf_size(pte) (pte_cont(pte) ? CONT_PTE_SIZE : PAGE_SIZE) +#define pte_leaf_size(pmd, pte) (pte_cont(pte) ? CONT_PTE_SIZE : PAGE_SIZE) #if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS < 3 static inline bool pud_sect(pud_t pud) { return false; } diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h index 137dc3c84e45..07df6b664861 100644 --- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h +++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h @@ -151,7 +151,7 @@ static inline unsigned long pgd_leaf_size(pgd_t pgd) #define pgd_leaf_size pgd_leaf_size -static inline unsigned long pte_leaf_size(pte_t pte) +static inline unsigned long pte_leaf_size(pmd_t pmd, pte_t pte) { pte_basic_t val = pte_val(pte); diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 6afd6bb4882e..9d9abe161a89 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -434,7 +434,7 @@ static inline pte_t pte_mkhuge(pte_t pte) } #ifdef CONFIG_RISCV_ISA_SVNAPOT -#define pte_leaf_size(pte) (pte_napot(pte) ? \ +#define pte_leaf_size(pmd, pte) (pte_napot(pte) ? \ napot_cont_size(napot_cont_order(pte)) :\ PAGE_SIZE) #endif diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 4d1bafaba942..67063af2ff8f 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -1175,7 +1175,7 @@ extern unsigned long pud_leaf_size(pud_t pud); extern unsigned long pmd_leaf_size(pmd_t pmd); #define pte_leaf_size pte_leaf_size -extern unsigned long pte_leaf_size(pte_t pte); +extern unsigned long pte_leaf_size(pmd_t pmd, pte_t pte); #endif /* CONFIG_HUGETLB_PAGE */ diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index 5a342199e837..60c845a15bee 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -276,7 +276,7 @@ static unsigned long huge_tte_to_size(pte_t pte) unsigned long pud_leaf_size(pud_t pud) { return 1UL << tte_to_shift(*(pte_t *)&pud); } unsigned long pmd_leaf_size(pmd_t pmd) { return 1UL << tte_to_shift(*(pte_t *)&pmd); } -unsigned long pte_leaf_size(pte_t pte) { return 1UL << tte_to_shift(pte); } +unsigned long pte_leaf_size(pmd_t pmd, pte_t pte) { return 1UL << tte_to_shift(pte); } pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long sz) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 85fc7554cd52..e605a4149fc7 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1802,7 +1802,7 @@ typedef unsigned int pgtbl_mod_mask; #define pmd_leaf_size(x) PMD_SIZE #endif #ifndef pte_leaf_size -#define pte_leaf_size(x) PAGE_SIZE +#define pte_leaf_size(x, y) PAGE_SIZE #endif /* diff --git a/kernel/events/core.c b/kernel/events/core.c index 724e6d7e128f..5c1c083222b2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7585,7 +7585,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr) pte = ptep_get_lockless(ptep); if (pte_present(pte)) - size = pte_leaf_size(pte); + size = pte_leaf_size(pmd, pte); pte_unmap(ptep); #endif /* CONFIG_HAVE_FAST_GUP */