mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Subsystems (7)
David Hildenbrand (Arm)
maintainercover mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Looking into vma_(kernel|mmu)_pagesize(), I realized that there is one scenario where DAX would not do the right thing when the kernel is not compiled with hugetlb support.
Without hugetlb support, vma_(kernel|mmu)_pagesize() will always return PAGE_SIZE instead of using the ->pagesize() result provided by dax-device code.
Fix that by moving vma_kernel_pagesize() to core MM code, where it belongs. I don't think this is stable material, but am not 100% sure.
Also, move vma_mmu_pagesize() while at it. Remove the unnecessary hugetlb.h inclusion from KVM code.
Cross-compiled heavily.
David Hildenbrand (Arm) (4):
mm: move vma_kernel_pagesize() from hugetlb to mm.h
mm: move vma_mmu_pagesize() from hugetlb to vma.c
KVM: remove hugetlb.h inclusion
KVM: PPC: remove hugetlb.h inclusion
arch/powerpc/kvm/book3s_hv.c | 1 - include/linux/hugetlb.h | 14 -------------- include/linux/mm.h | 22 ++++++++++++++++++++++ mm/hugetlb.c | 28 ---------------------------- mm/vma.c | 21 +++++++++++++++++++++ virt/kvm/kvm_main.c | 1 - 6 files changed, 43 insertions(+), 44 deletions(-)
base-commit: f75825cdfc4c5477cffcfd2cafa4e5ce5aa67f13
Signature · 1 line
2.43.0
David Hildenbrand (Arm)
maintainerPATCH 1/4 mm: move vma_kernel_pagesize() from hugetlb to mm.h
In the past, only hugetlb had special "vma_kernel_pagesize()" requirements, so it provided its own implementation.
In commit 05ea88608d4e ("mm, hugetlbfs: introduce ->pagesize() to vm_operations_struct") we generalized that approach by providing a vm_ops->pagesize() callback to be used by device-dax.
Once device-dax started using that callback in commit c1d53b92b95c ("device-dax: implement ->pagesize() for smaps to report MMUPageSize") it was missed that CONFIG_DEV_DAX does not depend on hugetlb support.
So building a kernel with CONFIG_DEV_DAX but without CONFIG_HUGETLBFS would not pick up that value.
Fix it by moving vma_kernel_pagesize() to mm.h, providing only a single implementation. While at it, improve the kerneldoc a bit.
Ideally, we'd move vma_mmu_pagesize() as well to the header. However, its __weak symbol might be overwritten by a PPC variant in hugetlb code. So let's leave it in there for now, as it really only matters for some hugetlb oddities.
This was found by code inspection.
--- include/linux/hugetlb.h | 7 ------- include/linux/mm.h | 20 ++++++++++++++++++++ mm/hugetlb.c | 17 ----------------- 3 files changed, 20 insertions(+), 24 deletions(-)
include/linux/hugetlb.h +0 -7
@@ -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_kernel_pagesize (struct vm_area_struct *vma); -extern unsigned long vma_mmu_pagesize (struct vm_area_struct *vma);static inline unsigned long huge_page_mask (struct hstate *h)
@@ -1177,11 +1175,6 @@ static inline unsigned long huge_page_mask(struct hstate *h)return PAGE_MASK ; } -static inline unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) -{ -return PAGE_SIZE ; -} -static inline unsigned long vma_mmu_pagesize (struct vm_area_struct *vma) {return PAGE_SIZE ;
include/linux/mm.h +20 -0
@@ -1307,6 +1307,26 @@ static inline bool vma_is_shared_maywrite(const struct vm_area_struct *vma)return is_shared_maywrite (&vma->flags); } +/** +* vma_kernel_pagesize - Default page size granularity for this VMA. +* @vma: The user mapping. +* +* The kernel page size specifies in which granularity VMA modifications +* can be performed. Folios in this VMA will be aligned to, and at least +* the size of the number of bytes returned by this function. +* +* The default kernel page size is not affected by Transparent Huge Pages +* being in effect. +* +* Return: The default page size granularity for this VMA. +*/ +static inline unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) +{ +if (unlikely (vma->vm_ops && vma->vm_ops->pagesize)) +return vma->vm_ops->pagesize (vma); +return PAGE_SIZE ; +} +static inline struct vm_area_struct *vma_find (struct vma_iterator *vmi,unsigned long max) {
mm/hugetlb.c +0 -17
@@ -1017,23 +1017,6 @@ static pgoff_t vma_hugecache_offset(struct hstate *h, (vma->vm_pgoff >>huge_page_order (h)); } -/** -* vma_kernel_pagesize - Page size granularity for this VMA. -* @vma: The user mapping. -* -* Folios in this VMA will be aligned to, and at least the size of the -* number of bytes returned by this function. -* -* Return: The default size of the folios allocated when backing a VMA. -*/ -unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) -{ -if (vma->vm_ops && vma->vm_ops->pagesize) -return vma->vm_ops->pagesize (vma); -return PAGE_SIZE ; -} -EXPORT_SYMBOL_GPL (vma_kernel_pagesize); -/* * 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
Signature · 1 line
2.43.0
David Hildenbrand (Arm)
maintainerPATCH 2/4 mm: move vma_mmu_pagesize() from hugetlb to vma.c
In reply to David Hildenbrand (Arm)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.
--- include/linux/hugetlb.h | 7 ------- include/linux/mm.h | 2 ++ mm/hugetlb.c | 11 ----------- mm/vma.c | 21 +++++++++++++++++++++ 4 files changed, 23 insertions(+), 18 deletions(-)
include/linux/hugetlb.h +0 -7
@@ -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 ;
include/linux/mm.h +2 -0
@@ -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) {
mm/hugetlb.c +0 -11
@@ -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
mm/vma.c +21 -0
@@ -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); +}
Signature · 1 line
2.43.0
David Hildenbrand (Arm)
maintainerPATCH 3/4 KVM: remove hugetlb.h inclusion
In reply to David Hildenbrand (Arm)hugetlb.h is no longer required now that we moved vma_kernel_pagesize() to mm.h.
--- virt/kvm/kvm_main.c | 1 - 1 file changed, 1 deletion(-)
virt/kvm/kvm_main.c +0 -1
@@ -41,7 +41,6 @@#include <linux/spinlock.h> #include <linux/compat.h> #include <linux/srcu.h> -#include <linux/hugetlb.h> #include <linux/slab.h> #include <linux/sort.h> #include <linux/bsearch.h>
Signature · 1 line
2.43.0
David Hildenbrand (Arm)
maintainerPATCH 4/4 KVM: PPC: remove hugetlb.h inclusion
In reply to David Hildenbrand (Arm)hugetlb.h is no longer required now that we moved vma_kernel_pagesize() to mm.h.
--- arch/powerpc/kvm/book3s_hv.c | 1 - 1 file changed, 1 deletion(-)
arch/powerpc/kvm/book3s_hv.c +0 -1
@@ -36,7 +36,6 @@#include <linux/gfp.h> #include <linux/vmalloc.h> #include <linux/highmem.h> -#include <linux/hugetlb.h> #include <linux/kvm_irqfd.h> #include <linux/irqbypass.h> #include <linux/module.h>
Signature · 1 line
2.43.0
Re: [PATCH v1 1/4] mm: move vma_kernel_pagesize() from hugetlb to mm.h
In reply to David Hildenbrand (Arm)Quoted 22 lines · David Hildenbrand (Arm)
In the past, only hugetlb had special "
vma_kernel_pagesize()" requirements, so it provided its own implementation.In commit
05ea88608d4e("mm, hugetlbfs: introduce ->pagesize() tovm_operations_struct") we generalized that approach by providing avm_ops->pagesize()callback to be used by device-dax.Once device-dax started using that callback in commit
c1d53b92b95c("device-dax: implement ->pagesize() for smaps to report MMUPageSize") it was missed thatCONFIG_DEV_DAXdoes not depend on hugetlb support.So building a kernel with
CONFIG_DEV_DAXbut withoutCONFIG_HUGETLBFSwould not pick up that value.Fix it by moving
vma_kernel_pagesize()tomm.h, providing only a single implementation. While at it, improve the kerneldoc a bit.Ideally, we'd move
vma_mmu_pagesize()as well to the header. However, its__weaksymbol might be overwritten by a PPC variant in hugetlb code. So let's leave it in there for now, as it really only matters for some hugetlb oddities.
Quoted 5 lines
This was found by code inspection.
Fixes c1d53b92b95c ("device-dax: implement ->pagesize() for smaps to report MMUPageSize")Cc Dan Williams <[email protected]>Signed-off-by David Hildenbrand (Arm) <[email protected]>
LGTM, but you need to fix up VMA tests, I attach a patch below to do this. Will this resolved:
Quoted 91 lines
--- include/linux/hugetlb.h | 7 ------- include/linux/mm.h | 20 ++++++++++++++++++++ mm/hugetlb.c | 17 ----------------- 3 files changed, 20 insertions(+), 24 deletions(-)include/linux/hugetlb.h +0
-7@@ -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_kernel_pagesize (struct vm_area_struct *vma); -extern unsigned long vma_mmu_pagesize (struct vm_area_struct *vma);static inline unsigned long huge_page_mask (struct hstate *h)@@ -1177,11 +1175,6 @@ static inline unsigned long huge_page_mask(struct hstate *h)return PAGE_MASK ; } -static inline unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) -{ -return PAGE_SIZE ; -} -static inline unsigned long vma_mmu_pagesize (struct vm_area_struct *vma) {return PAGE_SIZE ;include/linux/mm.h +20
-0@@ -1307,6 +1307,26 @@ static inline bool vma_is_shared_maywrite(const struct vm_area_struct *vma)return is_shared_maywrite (&vma->flags); } +/** +* vma_kernel_pagesize - Default page size granularity for this VMA. +* @vma: The user mapping. +* +* The kernel page size specifies in which granularity VMA modifications +* can be performed. Folios in this VMA will be aligned to, and at least +* the size of the number of bytes returned by this function. +* +* The default kernel page size is not affected by Transparent Huge Pages +* being in effect. +* +* Return: The default page size granularity for this VMA. +*/ +static inline unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) +{ +if (unlikely (vma->vm_ops && vma->vm_ops->pagesize)) +return vma->vm_ops->pagesize (vma); +return PAGE_SIZE ; +} +static inline struct vm_area_struct *vma_find (struct vma_iterator *vmi,unsigned long max) {mm/hugetlb.c +0
-18@@ -1017,23 +1017,6 @@ static pgoff_t vma_hugecache_offset(struct hstate *h, (vma->vm_pgoff >>huge_page_order (h)); } -/** -* vma_kernel_pagesize - Page size granularity for this VMA. -* @vma: The user mapping. -* -* Folios in this VMA will be aligned to, and at least the size of the -* number of bytes returned by this function. -* -* Return: The default size of the folios allocated when backing a VMA. -*/ -unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) -{ -if (vma->vm_ops && vma->vm_ops->pagesize) -return vma->vm_ops->pagesize (vma); -return PAGE_SIZE ; -} -EXPORT_SYMBOL_GPL (vma_kernel_pagesize); -/* * 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 --
Quoted 2 lines
2.43.0
----8<----
This breaks the VMA tests when patch 2/4 removes the references in other headers. So this patch should also update them, I enclose a simple fix for convenience:
From bec84895cbdbe28e3495c4d90e097074598419e5 Mon Sep 17 00:00:00 2001
From: "Lorenzo Stoakes (Oracle)" <[email protected]>
Date: Fri, 6 Mar 2026 11:05:12 +0000
Subject: [PATCH] fix
--- tools/testing/vma/include/dup.h | 7 +++++++ 1 file changed, 7 insertions(+)
tools/testing/vma/include/dup.h +7 -0
@@ -1318,3 +1318,10 @@ static inline void vma_set_file(struct vm_area_struct *vma, struct file *file)swap (vma->vm_file, file);fput (file); } + +static inline unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) +{ +if (unlikely (vma->vm_ops && vma->vm_ops->pagesize)) +return vma->vm_ops->pagesize (vma); +return PAGE_SIZE ; +}
--
2.53.0
Re: [PATCH v1 2/4] mm: move vma_mmu_pagesize() from hugetlb to vma.c
In reply to David Hildenbrand (Arm)Quoted 10 lines · David Hildenbrand (Arm)
vma_mmu_pagesize()is also queried on non-hugetlb VMAs and does not really belong intohugetlb.c.PPC64 provides a custom overwrite with
CONFIG_HUGETLB_PAGE, seearch/powerpc/mm/book3s64/slice.c, so we cannot easily make this a static inline function.So let's move it to
vma.cand add some proper kerneldoc.Signed-off-by David Hildenbrand (Arm) <[email protected]>
LGTM, so:
Quoted 99 lines
--- include/linux/hugetlb.h | 7 ------- include/linux/mm.h | 2 ++ mm/hugetlb.c | 11 ----------- mm/vma.c | 21 +++++++++++++++++++++ 4 files changed, 23 insertions(+), 18 deletions(-)include/linux/hugetlb.h +0
-7@@ -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 ;include/linux/mm.h +2
-0@@ -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) {mm/hugetlb.c +0
-11@@ -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 mm/vma.c +21
-1@@ -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); +} --2.43.0
Re: [PATCH v1 3/4] KVM: remove hugetlb.h inclusion
In reply to David Hildenbrand (Arm)Quoted 4 lines · David Hildenbrand (Arm)
hugetlb.his no longer required now that we movedvma_kernel_pagesize()tomm.h.Signed-off-by David Hildenbrand (Arm) <[email protected]>
Aww this is the tiniest cutest patch evah!
Quoted 17 lines
--- virt/kvm/kvm_main.c | 1 - 1 file changed, 1 deletion(-)virt/kvm/kvm_main.c +0
-2@@ -41,7 +41,6 @@#include <linux/spinlock.h> #include <linux/compat.h> #include <linux/srcu.h> -#include <linux/hugetlb.h> #include <linux/slab.h> #include <linux/sort.h> #include <linux/bsearch.h> --
Quoted 2 lines
2.43.0
Cheers, Lorenzo
Re: [PATCH v1 4/4] KVM: PPC: remove hugetlb.h inclusion
In reply to David Hildenbrand (Arm)Quoted 4 lines · David Hildenbrand (Arm)
hugetlb.his no longer required now that we movedvma_kernel_pagesize()tomm.h.Signed-off-by David Hildenbrand (Arm) <[email protected]>
You've gone mega cute on this one too! <3
Quoted 17 lines
--- arch/powerpc/kvm/book3s_hv.c | 1 - 1 file changed, 1 deletion(-)arch/powerpc/kvm/book3s_hv.c +0
-2@@ -36,7 +36,6 @@#include <linux/gfp.h> #include <linux/vmalloc.h> #include <linux/highmem.h> -#include <linux/hugetlb.h> #include <linux/kvm_irqfd.h> #include <linux/irqbypass.h> #include <linux/module.h> --
Quoted 2 lines
2.43.0
Cheers, Lorenzo
Pedro Falcato
reviewerQuoted 25 lines · David Hildenbrand (Arm)
Looking into vma_(kernel|mmu)_pagesize(), I realized that there is one scenario where DAX would not do the right thing when the kernel is not compiled with hugetlb support.
Without hugetlb support, vma_(kernel|mmu)_pagesize() will always return
PAGE_SIZEinstead of using the ->pagesize() result provided by dax-device code.Fix that by moving
vma_kernel_pagesize()to core MM code, where it belongs. I don't think this is stable material, but am not 100% sure.Also, move
vma_mmu_pagesize()while at it. Remove the unnecessaryhugetlb.hinclusion from KVM code.Cross-compiled heavily.
Cc Andrew Morton <[email protected]>Cc Madhavan Srinivasan <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Michael Ellerman <[email protected]>Cc "Christophe Leroy (CS GROUP)" <[email protected]>Cc Muchun Song <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc "Liam R. Howlett" <[email protected]>
Quoted 8 lines
Cc Vlastimil Babka <[email protected]>Cc Mike Rapoport <[email protected]>Cc Suren Baghdasaryan <[email protected]>Cc Michal Hocko <[email protected]>Cc Jann Horn <[email protected]>Cc Pedro Falcato <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Dan Williams <[email protected]>
Although we all love less mail, FYI it seems like this didn't work properly for the patches (no CC's on there).
Did you try git-email --cc-cover?
Signature · 1 line
Pedro
Lorenzo Stoakes (Oracle)
maintainerQuoted 35 lines · Pedro Falcato
Quoted 25 lines · David Hildenbrand (Arm)
Looking into vma_(kernel|mmu)_pagesize(), I realized that there is one scenario where DAX would not do the right thing when the kernel is not compiled with hugetlb support.
Without hugetlb support, vma_(kernel|mmu)_pagesize() will always return
PAGE_SIZEinstead of using the ->pagesize() result provided by dax-device code.Fix that by moving
vma_kernel_pagesize()to core MM code, where it belongs. I don't think this is stable material, but am not 100% sure.Also, move
vma_mmu_pagesize()while at it. Remove the unnecessaryhugetlb.hinclusion from KVM code.Cross-compiled heavily.
Cc Andrew Morton <[email protected]>Cc Madhavan Srinivasan <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Michael Ellerman <[email protected]>Cc "Christophe Leroy (CS GROUP)" <[email protected]>Cc Muchun Song <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc "Liam R. Howlett" <[email protected]>Quoted 8 lines
Cc Vlastimil Babka <[email protected]>Cc Mike Rapoport <[email protected]>Cc Suren Baghdasaryan <[email protected]>Cc Michal Hocko <[email protected]>Cc Jann Horn <[email protected]>Cc Pedro Falcato <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Dan Williams <[email protected]>
Quoted 4 lines
Although we all love less mail, FYI it seems like this didn't work properly for the patches (no CC's on there).
Did you try git-email --cc-cover?
Yeah I noticed this also :>) Assumed it was a new way of doing things somehow? :P
Quoted 3 lines
--
Pedro
Cheers, Lorenzo
David Hildenbrand (Arm)
maintainerQuoted 36 lines · Lorenzo Stoakes (Oracle)
Quoted 35 lines · Pedro Falcato
Quoted 33 lines · David Hildenbrand (Arm)
Looking into vma_(kernel|mmu)_pagesize(), I realized that there is one scenario where DAX would not do the right thing when the kernel is not compiled with hugetlb support.
Without hugetlb support, vma_(kernel|mmu)_pagesize() will always return
PAGE_SIZEinstead of using the ->pagesize() result provided by dax-device code.Fix that by moving
vma_kernel_pagesize()to core MM code, where it belongs. I don't think this is stable material, but am not 100% sure.Also, move
vma_mmu_pagesize()while at it. Remove the unnecessaryhugetlb.hinclusion from KVM code.Cross-compiled heavily.
Cc Andrew Morton <[email protected]>Cc Madhavan Srinivasan <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Michael Ellerman <[email protected]>Cc "Christophe Leroy (CS GROUP)" <[email protected]>Cc Muchun Song <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc "Liam R. Howlett" <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Mike Rapoport <[email protected]>Cc Suren Baghdasaryan <[email protected]>Cc Michal Hocko <[email protected]>Cc Jann Horn <[email protected]>Cc Pedro Falcato <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Dan Williams <[email protected]>
Quoted 7 lines
Quoted 4 lines
Although we all love less mail, FYI it seems like this didn't work properly for the patches (no CC's on there).
Did you try git-email --cc-cover?
Yeah I noticed this also :>) Assumed it was a new way of doing things somehow? :P
"--cc-cover" is apparently not the git default on my new machine.
"See, I CCed you, I totally did not try to sneak something in. Oh, I messed up my tooling, stupid me ...". :)
Signature · 3 lines
Cheers, David
David Hildenbrand (Arm)
maintainerRe: [PATCH v1 1/4] mm: move vma_kernel_pagesize() from hugetlb to mm.h
In reply to Lorenzo Stoakes (Oracle)Quoted 23 lines · Lorenzo Stoakes (Oracle)
Quoted 22 lines · David Hildenbrand (Arm)
In the past, only hugetlb had special "
vma_kernel_pagesize()" requirements, so it provided its own implementation.In commit
05ea88608d4e("mm, hugetlbfs: introduce ->pagesize() tovm_operations_struct") we generalized that approach by providing avm_ops->pagesize()callback to be used by device-dax.Once device-dax started using that callback in commit
c1d53b92b95c("device-dax: implement ->pagesize() for smaps to report MMUPageSize") it was missed thatCONFIG_DEV_DAXdoes not depend on hugetlb support.So building a kernel with
CONFIG_DEV_DAXbut withoutCONFIG_HUGETLBFSwould not pick up that value.Fix it by moving
vma_kernel_pagesize()tomm.h, providing only a single implementation. While at it, improve the kerneldoc a bit.Ideally, we'd move
vma_mmu_pagesize()as well to the header. However, its__weaksymbol might be overwritten by a PPC variant in hugetlb code. So let's leave it in there for now, as it really only matters for some hugetlb oddities.
Quoted 8 lines
Quoted 5 lines
This was found by code inspection.
Fixes c1d53b92b95c ("device-dax: implement ->pagesize() for smaps to report MMUPageSize")Cc Dan Williams <[email protected]>Signed-off-by David Hildenbrand (Arm) <[email protected]>LGTM, but you need to fix up VMA tests, I attach a patch below to do this. Will this resolved:
Thanks!
I assume that should go into patch #2 instead?
Quoted 2 lines
Reviewed-by Lorenzo Stoakes (Oracle) <[email protected]>
[...]
Quoted 9 lines
--- tools/testing/vma/include/dup.h | 7 +++++++ 1 file changed, 7 insertions(+)tools/testing/vma/include/dup.h +0
-0
tools/testing/vma/include/dup.h static inline void vma_set_file(struct vm_area_struct *vma, struct file *file) · line 1326
Quoted 9 lines
tools/testing/vma/include/dup.h +6
-0@@ -1318,3 +1318,10 @@ static inline void vma_set_file(struct vm_area_struct *vma, struct file *file)swap (vma->vm_file, file);fput (file); } + +static inline unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) +{ +if (unlikely (vma->vm_ops && vma->vm_ops->pagesize)) +return vma->vm_ops->pagesize (vma); +return PAGE_SIZE ;
Should we just KIS and use PAGE_SIZE for the test?
Signature · 3 lines
Cheers, David
David Hildenbrand (Arm)
maintainerRe: [PATCH v1 3/4] KVM: remove hugetlb.h inclusion
In reply to Lorenzo Stoakes (Oracle)Quoted 7 lines · Lorenzo Stoakes (Oracle)
Quoted 4 lines · David Hildenbrand (Arm)
hugetlb.his no longer required now that we movedvma_kernel_pagesize()tomm.h.Signed-off-by David Hildenbrand (Arm) <[email protected]>Aww this is the tiniest cutest patch evah!
It's a very smol patch! :)
Signature · 3 lines
Cheers, David
Quoted 40 lines · David Hildenbrand (Arm)
Looking into vma_(kernel|mmu)_pagesize(), I realized that there is one scenario where DAX would not do the right thing when the kernel is not compiled with hugetlb support.
Without hugetlb support, vma_(kernel|mmu)_pagesize() will always return
PAGE_SIZEinstead of using the ->pagesize() result provided by dax-device code.Fix that by moving
vma_kernel_pagesize()to core MM code, where it belongs. I don't think this is stable material, but am not 100% sure.Also, move
vma_mmu_pagesize()while at it. Remove the unnecessaryhugetlb.hinclusion from KVM code.Cross-compiled heavily.
Cc Andrew Morton <[email protected]>Cc Madhavan Srinivasan <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Michael Ellerman <[email protected]>Cc "Christophe Leroy (CS GROUP)" <[email protected]>Cc Muchun Song <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc "Liam R. Howlett" <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Mike Rapoport <[email protected]>Cc Suren Baghdasaryan <[email protected]>Cc Michal Hocko <[email protected]>Cc Jann Horn <[email protected]>Cc Pedro Falcato <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Dan Williams <[email protected]>David Hildenbrand (Arm) (4):
mm: movevma_kernel_pagesize()from hugetlb tomm.h
mm: movevma_mmu_pagesize()from hugetlb tovma.c
KVM: removehugetlb.hinclusion
KVM: PPC: removehugetlb.hinclusion
Quoted 7 lines
arch/powerpc/kvm/book3s_hv.c | 1 - include/linux/hugetlb.h | 14 -------------- include/linux/mm.h | 22 ++++++++++++++++++++++ mm/hugetlb.c | 28 ---------------------------- mm/vma.c | 21 +++++++++++++++++++++ virt/kvm/kvm_main.c | 1 - 6 files changed, 43 insertions(+), 44 deletions(-)
For the series:
Quoted 4 lines
base-commit:
f75825cdfc4c5477cffcfd2cafa4e5ce5aa67f13Signature · 1 line
2.43.0
Signature · 2 lines
Sincerely yours, Mike.
Lorenzo Stoakes (Oracle)
maintainerRe: [PATCH v1 1/4] mm: move vma_kernel_pagesize() from hugetlb to mm.h
In reply to David Hildenbrand (Arm)Quoted 47 lines · David Hildenbrand (Arm)
Quoted 23 lines · Lorenzo Stoakes (Oracle)
Quoted 22 lines · David Hildenbrand (Arm)
In the past, only hugetlb had special "
vma_kernel_pagesize()" requirements, so it provided its own implementation.In commit
05ea88608d4e("mm, hugetlbfs: introduce ->pagesize() tovm_operations_struct") we generalized that approach by providing avm_ops->pagesize()callback to be used by device-dax.Once device-dax started using that callback in commit
c1d53b92b95c("device-dax: implement ->pagesize() for smaps to report MMUPageSize") it was missed thatCONFIG_DEV_DAXdoes not depend on hugetlb support.So building a kernel with
CONFIG_DEV_DAXbut withoutCONFIG_HUGETLBFSwould not pick up that value.Fix it by moving
vma_kernel_pagesize()tomm.h, providing only a single implementation. While at it, improve the kerneldoc a bit.Ideally, we'd move
vma_mmu_pagesize()as well to the header. However, its__weaksymbol might be overwritten by a PPC variant in hugetlb code. So let's leave it in there for now, as it really only matters for some hugetlb oddities.Quoted 8 lines
Quoted 5 lines
This was found by code inspection.
Fixes c1d53b92b95c ("device-dax: implement ->pagesize() for smaps to report MMUPageSize")Cc Dan Williams <[email protected]>Signed-off-by David Hildenbrand (Arm) <[email protected]>LGTM, but you need to fix up VMA tests, I attach a patch below to do this. Will this resolved:
Thanks!
I assume that should go into patch #2 instead?
Quoted 2 lines
Reviewed-by Lorenzo Stoakes (Oracle) <[email protected]>[...]
Quoted 4 lines
--- tools/testing/vma/include/dup.h | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 16 lines
Quoted 5 lines
tools/testing/vma/include/dup.h +0
-0tools/testing/vma/include/dup.h static inline void vma_set_file(struct vm_area_struct *vma, struct file *file) · line 1326
Quoted 9 lines
tools/testing/vma/include/dup.h +6
-0@@ -1318,3 +1318,10 @@ static inline void vma_set_file(struct vm_area_struct *vma, struct file *file)swap (vma->vm_file, file);fput (file); } + +static inline unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) +{ +if (unlikely (vma->vm_ops && vma->vm_ops->pagesize)) +return vma->vm_ops->pagesize (vma); +return PAGE_SIZE ;Should we just KIS and use
PAGE_SIZEfor the test?
Yeah that's fine, but then should go in tools/testing/vma/include/custom.h :>)
I tidied things up there to make it easier to understand WTH is going on with the headers used by VMA tests.
Quoted 5 lines
--
Cheers,David
Thanks, Lorenzo
Lorenzo Stoakes (Oracle)
maintainerQuoted 42 lines · David Hildenbrand (Arm)
Quoted 41 lines · Lorenzo Stoakes (Oracle)
Quoted 39 lines · Pedro Falcato
Quoted 25 lines · David Hildenbrand (Arm)
Looking into vma_(kernel|mmu)_pagesize(), I realized that there is one scenario where DAX would not do the right thing when the kernel is not compiled with hugetlb support.
Without hugetlb support, vma_(kernel|mmu)_pagesize() will always return
PAGE_SIZEinstead of using the ->pagesize() result provided by dax-device code.Fix that by moving
vma_kernel_pagesize()to core MM code, where it belongs. I don't think this is stable material, but am not 100% sure.Also, move
vma_mmu_pagesize()while at it. Remove the unnecessaryhugetlb.hinclusion from KVM code.Cross-compiled heavily.
Cc Andrew Morton <[email protected]>Cc Madhavan Srinivasan <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Michael Ellerman <[email protected]>Cc "Christophe Leroy (CS GROUP)" <[email protected]>Cc Muchun Song <[email protected]>Cc Oscar Salvador <[email protected]>Cc Lorenzo Stoakes <[email protected]>Cc "Liam R. Howlett" <[email protected]>Quoted 8 lines
Cc Vlastimil Babka <[email protected]>Cc Mike Rapoport <[email protected]>Cc Suren Baghdasaryan <[email protected]>Cc Michal Hocko <[email protected]>Cc Jann Horn <[email protected]>Cc Pedro Falcato <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Dan Williams <[email protected]>Although we all love less mail, FYI it seems like this didn't work properly for the patches (no CC's on there).
Did you try git-email --cc-cover?
Quoted 7 lines
Quoted 2 lines
Yeah I noticed this also :>) Assumed it was a new way of doing things somehow? :P
"--cc-cover" is apparently not the git default on my new machine.
"See, I CCed you, I totally did not try to sneak something in. Oh, I messed up my tooling, stupid me ...". :)
;)
Wasn't aware of that option actually, handy!
Quoted 5 lines
--
Cheers,David
Cheers, Lorenzo
Lorenzo Stoakes (Oracle)
maintainerRe: [PATCH v1 1/4] mm: move vma_kernel_pagesize() from hugetlb to mm.h
In reply to David Hildenbrand (Arm)Quoted 30 lines · David Hildenbrand (Arm)
Quoted 29 lines · Lorenzo Stoakes (Oracle)
Quoted 27 lines · David Hildenbrand (Arm)
In the past, only hugetlb had special "
vma_kernel_pagesize()" requirements, so it provided its own implementation.In commit
05ea88608d4e("mm, hugetlbfs: introduce ->pagesize() tovm_operations_struct") we generalized that approach by providing avm_ops->pagesize()callback to be used by device-dax.Once device-dax started using that callback in commit
c1d53b92b95c("device-dax: implement ->pagesize() for smaps to report MMUPageSize") it was missed thatCONFIG_DEV_DAXdoes not depend on hugetlb support.So building a kernel with
CONFIG_DEV_DAXbut withoutCONFIG_HUGETLBFSwould not pick up that value.Fix it by moving
vma_kernel_pagesize()tomm.h, providing only a single implementation. While at it, improve the kerneldoc a bit.Ideally, we'd move
vma_mmu_pagesize()as well to the header. However, its__weaksymbol might be overwritten by a PPC variant in hugetlb code. So let's leave it in there for now, as it really only matters for some hugetlb oddities.This was found by code inspection.
Fixes c1d53b92b95c ("device-dax: implement ->pagesize() for smaps to report MMUPageSize")Cc Dan Williams <[email protected]>Signed-off-by David Hildenbrand (Arm) <[email protected]>
Quoted 6 lines
Quoted 2 lines
LGTM, but you need to fix up VMA tests, I attach a patch below to do this. Will this resolved:
Thanks!
I assume that should go into patch #2 instead?
(Sorry missed this on first reply)
It doesn't matter too much from compilation point of view but thought it made more sense as this is where you pull vma_kernel_pagesize() in? But I'm fine with either!
Cheers, Lorenzo
David Hildenbrand (Arm)
maintainerRe: [PATCH v1 1/4] mm: move vma_kernel_pagesize() from hugetlb to mm.h
In reply to Lorenzo Stoakes (Oracle)Quoted 37 lines · Lorenzo Stoakes (Oracle)
Quoted 19 lines · David Hildenbrand (Arm)
Quoted 3 lines · Lorenzo Stoakes (Oracle)
LGTM, but you need to fix up VMA tests, I attach a patch below to do this. Will this resolved:
Thanks!
I assume that should go into patch #2 instead?
Quoted 2 lines
Reviewed-by Lorenzo Stoakes (Oracle) <[email protected]>[...]
Quoted 4 lines
--- tools/testing/vma/include/dup.h | 7 +++++++ 1 file changed, 7 insertions(+)Quoted 16 lines
Quoted 5 lines
tools/testing/vma/include/dup.h +0
-0tools/testing/vma/include/dup.h static inline void vma_set_file(struct vm_area_struct *vma, struct file *file) · line 1326
Quoted 9 lines
tools/testing/vma/include/dup.h +6
-0@@ -1318,3 +1318,10 @@ static inline void vma_set_file(struct vm_area_struct *vma, struct file *file)swap (vma->vm_file, file);fput (file); } + +static inline unsigned long vma_kernel_pagesize (struct vm_area_struct *vma) +{ +if (unlikely (vma->vm_ops && vma->vm_ops->pagesize)) +return vma->vm_ops->pagesize (vma); +return PAGE_SIZE ;Should we just KIS and use
PAGE_SIZEfor the test?
Quoted 1 line
Yeah that's fine, but then should go in
tools/testing/vma/include/custom.h:>)
I'll place it in there, then, thanks.
Signature · 3 lines
Cheers, David
David Hildenbrand (Arm)
maintainerQuoted 6 lines · Lorenzo Stoakes (Oracle)
Quoted 5 lines · David Hildenbrand (Arm)
Quoted 3 lines · Lorenzo Stoakes (Oracle)
Yeah I noticed this also :>) Assumed it was a new way of doing things somehow? :P
Quoted 8 lines
Quoted 4 lines
"--cc-cover" is apparently not the git default on my new machine.
"See, I CCed you, I totally did not try to sneak something in. Oh, I messed up my tooling, stupid me ...". :)
;)
Wasn't aware of that option actually, handy!
On my old setup I had a script that would, in addition, also CC anybody CC'ed on individual patches on the cover letter. Was quite useful for larger series where you don't want to spam people with unrelated patches.
Still have to set that back up.
Signature · 3 lines
Cheers, David
Vlastimil Babka
reviewerQuoted 12 lines · David Hildenbrand (Arm)
Quoted 11 lines · Lorenzo Stoakes (Oracle)
Quoted 9 lines · David Hildenbrand (Arm)
Quoted 3 lines · Lorenzo Stoakes (Oracle)
Yeah I noticed this also :>) Assumed it was a new way of doing things somehow? :P
"--cc-cover" is apparently not the git default on my new machine.
"See, I CCed you, I totally did not try to sneak something in. Oh, I messed up my tooling, stupid me ...". :)
Quoted 7 lines
Quoted 3 lines
;)
Wasn't aware of that option actually, handy!
On my old setup I had a script that would, in addition, also CC anybody CC'ed on individual patches on the cover letter. Was quite useful for larger series where you don't want to spam people with unrelated patches.
I had such a script too.
Quoted 1 line
Still have to set that back up.
But now "b4 send" does that for me automatically. And I don't need to do a "git format-patch" beforehand. It also does the equivalent of "--cc-cover".