From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AA08F417F3 for ; Mon, 9 Mar 2026 15:19:31 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fV0zj4ZQ6z3bnm; Tue, 10 Mar 2026 02:19:29 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c0a:e001:78e:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1773069569; cv=none; b=mucw68qxuv8v+X/q88QYQpZV8R7/8WQDcjE9Lsg6xaCH+FtxT9R/nZe0C7E76lcC3tw32mrXoyHKl5QTTomDsDJ887MehIPjCdGjY7Ifkfm7EQx4C1TEvw/g4selX5KpIKQ/iDxG9xa+ixRQaPD/xyHtykAX8bdG9+m2irBX8waEqs6GER+JChjGMUuK+LWbThsVEX3wtbnOrQbx145EPx/Bvdfmzmpov7bcsL1yn+OaaI5Xtl51GLQHGztQnccMvN4clSi9g1WIJSAwOaf8b1WIodXFue2ATuAHnmgwIvrX81FsDLHxPH1tZPdtX0kqCGLQHgk/wViGt75OWV784g== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1773069569; c=relaxed/relaxed; bh=8TSEUSGyzIrSnUfG1DVi5eGrw9YR0I+2760zFGy4g+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jbwF4WxcK/GqqHVjbgMncw420f0ZCgfRSpQ3Bh5/uCSwRt7MJojJGGsBUa8aDR5xHpQqZfmZuhkJt9jUEYizLBe446Y98NXBnnQY0nZsG7knnVtdansXz5MVIcp5ejZpEceElYn2CCSDPcBgidbgBNr7QMmK/sYGn4zwSbzDY4/2TENc2GUzRyFxbWW/CxalYl+X50kRvyJrEBBsJgyGOLMoEagjm7lccTsHJnw96tr2XkIucITt7LaYdXA6CZdYW+xBvOudxiJAzrnsAXrzsOJb4vsIH1g2cbr3KtkKgcndAyOoJB90xyqg2d9fz2pUhE1zMp0PHi8jMsRZ4fIb+A== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=vIzLDFSz; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=david@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=vIzLDFSz; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org; envelope-from=david@kernel.org; receiver=lists.ozlabs.org) Received: from sea.source.kernel.org (sea.source.kernel.org [IPv6:2600:3c0a:e001:78e:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fV0zh5tlMz2xm3 for ; Tue, 10 Mar 2026 02:19:28 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id E0F1F43A8D; Mon, 9 Mar 2026 15:19:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B98AC4CEF7; Mon, 9 Mar 2026 15:19:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773069566; bh=Mhr7tHNnk4w6+iI/utOSEhEAAttuf6c8xcPh/66ACkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vIzLDFSzRjakKohtre+2VeVYCY78KNKV3+vsvOm4E91ML/9l4r5EZZ+H73I/hKO3F +ymncYI/de8NbufE4brWEUyrTiWHk5hR4K/ODmDyvuR8uVZXpCDVCky0p3O0yIIj/V 5/S/nWoXlmvP+gF3GyW18r8iURaGdQ7QSgf7rHclKZkN+mavll8dKHMfh11QOJA8qF pn777/LRL7Y0CRCImdIB7ue6zCaTupvWYrAu67gKmPH76E13Cg6AbI7tb59lhTh8Rx 0Y9XxMlJvjbf32TuaMTLmyoKbJKfWIHiR7E9KZqnbICSP+ItP6CoXrazRZ5L2DRS/Z auQaLD4Xrx4vg== From: "David Hildenbrand (Arm)" To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, "David Hildenbrand (Arm)" , Andrew Morton , Madhavan Srinivasan , Nicholas Piggin , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Muchun Song , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , Paolo Bonzini , Dan Williams Subject: [PATCH v2 2/4] mm: move vma_mmu_pagesize() from hugetlb to vma.c Date: Mon, 9 Mar 2026 16:18:59 +0100 Message-ID: <20260309151901.123947-3-david@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260309151901.123947-1-david@kernel.org> References: <20260309151901.123947-1-david@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit vma_mmu_pagesize() is also queried on non-hugetlb VMAs and does not really belong into hugetlb.c. PPC64 provides a custom overwrite with CONFIG_HUGETLB_PAGE, see arch/powerpc/mm/book3s64/slice.c, so we cannot easily make this a static inline function. So let's move it to vma.c and add some proper kerneldoc. To make vma tests happy, add a simple vma_kernel_pagesize() stub in tools/testing/vma/include/custom.h. Reviewed-by: Lorenzo Stoakes (Oracle) Acked-by: Mike Rapoport (Microsoft) Signed-off-by: David Hildenbrand (Arm) --- include/linux/hugetlb.h | 7 ------- include/linux/mm.h | 2 ++ mm/hugetlb.c | 11 ----------- mm/vma.c | 21 +++++++++++++++++++++ tools/testing/vma/include/custom.h | 5 +++++ 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 44c1848a2c21..aaf3d472e6b5 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -777,8 +777,6 @@ static inline unsigned long huge_page_size(const struct hstate *h) return (unsigned long)PAGE_SIZE << h->order; } -extern unsigned long vma_mmu_pagesize(struct vm_area_struct *vma); - static inline unsigned long huge_page_mask(struct hstate *h) { return h->mask; @@ -1175,11 +1173,6 @@ static inline unsigned long huge_page_mask(struct hstate *h) return PAGE_MASK; } -static inline unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) -{ - return PAGE_SIZE; -} - static inline unsigned int huge_page_order(struct hstate *h) { return 0; diff --git a/include/linux/mm.h b/include/linux/mm.h index 227809790f1a..22d338933c84 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1327,6 +1327,8 @@ static inline unsigned long vma_kernel_pagesize(struct vm_area_struct *vma) return PAGE_SIZE; } +unsigned long vma_mmu_pagesize(struct vm_area_struct *vma); + static inline struct vm_area_struct *vma_find(struct vma_iterator *vmi, unsigned long max) { diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 66eadfa9e958..f6ecca9aae01 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1017,17 +1017,6 @@ static pgoff_t vma_hugecache_offset(struct hstate *h, (vma->vm_pgoff >> huge_page_order(h)); } -/* - * Return the page size being used by the MMU to back a VMA. In the majority - * of cases, the page size used by the kernel matches the MMU size. On - * architectures where it differs, an architecture-specific 'strong' - * version of this symbol is required. - */ -__weak unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) -{ - return vma_kernel_pagesize(vma); -} - /* * Flags for MAP_PRIVATE reservations. These are stored in the bottom * bits of the reservation map pointer, which are always clear due to diff --git a/mm/vma.c b/mm/vma.c index be64f781a3aa..e95fd5a5fe5c 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -3300,3 +3300,24 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma) return 0; } + +/** + * vma_mmu_pagesize - Default MMU page size granularity for this VMA. + * @vma: The user mapping. + * + * In the common case, the default page size used by the MMU matches the + * default page size used by the kernel (see vma_kernel_pagesize()). On + * architectures where it differs, an architecture-specific 'strong' version + * of this symbol is required. + * + * The default MMU page size is not affected by Transparent Huge Pages + * being in effect, or any usage of larger MMU page sizes (either through + * architectural huge-page mappings or other explicit/implicit coalescing of + * virtual ranges performed by the MMU). + * + * Return: The default MMU page size granularity for this VMA. + */ +__weak unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) +{ + return vma_kernel_pagesize(vma); +} diff --git a/tools/testing/vma/include/custom.h b/tools/testing/vma/include/custom.h index 802a76317245..4305a5b6e433 100644 --- a/tools/testing/vma/include/custom.h +++ b/tools/testing/vma/include/custom.h @@ -117,3 +117,8 @@ static inline vma_flags_t __mk_vma_flags(size_t count, const vma_flag_t *bits) vma_flag_set(&flags, bits[i]); return flags; } + +static inline unsigned long vma_kernel_pagesize(struct vm_area_struct *vma) +{ + return PAGE_SIZE; +} -- 2.43.0