[PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c

David Hildenbrand (Arm) posted 4 patches 1 month ago
There is a newer version of this series
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(-)
[PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Posted by David Hildenbrand (Arm) 1 month ago
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.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Jann Horn <jannh@google.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Dan Williams <dan.j.williams@intel.com>

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
-- 
2.43.0
Re: [PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Posted by Mike Rapoport 1 month ago
On Fri, Mar 06, 2026 at 11:15:56AM +0100, David Hildenbrand (Arm) wrote:
> 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.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
> Cc: Muchun Song <muchun.song@linux.dev>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Lorenzo Stoakes <ljs@kernel.org>
> Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
> Cc: Vlastimil Babka <vbabka@kernel.org>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Jann Horn <jannh@google.com>
> Cc: Pedro Falcato <pfalcato@suse.de>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> 
> 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(-)

For the series:
 
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> base-commit: f75825cdfc4c5477cffcfd2cafa4e5ce5aa67f13
> -- 
> 2.43.0
> 

-- 
Sincerely yours,
Mike.
Re: [PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Posted by Pedro Falcato 1 month ago
On Fri, Mar 06, 2026 at 11:15:56AM +0100, David Hildenbrand (Arm) wrote:
> 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.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
> Cc: Muchun Song <muchun.song@linux.dev>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Lorenzo Stoakes <ljs@kernel.org>
> Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
> Cc: Vlastimil Babka <vbabka@kernel.org>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Jann Horn <jannh@google.com>
> Cc: Pedro Falcato <pfalcato@suse.de>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Dan Williams <dan.j.williams@intel.com>

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?

-- 
Pedro
Re: [PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Posted by Lorenzo Stoakes (Oracle) 1 month ago
On Fri, Mar 06, 2026 at 11:13:41AM +0000, Pedro Falcato wrote:
> On Fri, Mar 06, 2026 at 11:15:56AM +0100, David Hildenbrand (Arm) wrote:
> > 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.
> >
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> > Cc: Nicholas Piggin <npiggin@gmail.com>
> > Cc: Michael Ellerman <mpe@ellerman.id.au>
> > Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
> > Cc: Muchun Song <muchun.song@linux.dev>
> > Cc: Oscar Salvador <osalvador@suse.de>
> > Cc: Lorenzo Stoakes <ljs@kernel.org>
> > Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
> > Cc: Vlastimil Babka <vbabka@kernel.org>
> > Cc: Mike Rapoport <rppt@kernel.org>
> > Cc: Suren Baghdasaryan <surenb@google.com>
> > Cc: Michal Hocko <mhocko@suse.com>
> > Cc: Jann Horn <jannh@google.com>
> > Cc: Pedro Falcato <pfalcato@suse.de>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
>
> 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

>
> --
> Pedro

Cheers, Lorenzo
Re: [PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Posted by David Hildenbrand (Arm) 1 month ago
On 3/6/26 12:19, Lorenzo Stoakes (Oracle) wrote:
> On Fri, Mar 06, 2026 at 11:13:41AM +0000, Pedro Falcato wrote:
>> On Fri, Mar 06, 2026 at 11:15:56AM +0100, David Hildenbrand (Arm) wrote:
>>> 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.
>>>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
>>> Cc: Nicholas Piggin <npiggin@gmail.com>
>>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>>> Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
>>> Cc: Muchun Song <muchun.song@linux.dev>
>>> Cc: Oscar Salvador <osalvador@suse.de>
>>> Cc: Lorenzo Stoakes <ljs@kernel.org>
>>> Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
>>> Cc: Vlastimil Babka <vbabka@kernel.org>
>>> Cc: Mike Rapoport <rppt@kernel.org>
>>> Cc: Suren Baghdasaryan <surenb@google.com>
>>> Cc: Michal Hocko <mhocko@suse.com>
>>> Cc: Jann Horn <jannh@google.com>
>>> Cc: Pedro Falcato <pfalcato@suse.de>
>>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>>> Cc: Dan Williams <dan.j.williams@intel.com>
>>
>> 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 ...". :)

-- 
Cheers,

David
Re: [PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Posted by Lorenzo Stoakes (Oracle) 1 month ago
On Fri, Mar 06, 2026 at 02:12:50PM +0100, David Hildenbrand (Arm) wrote:
> On 3/6/26 12:19, Lorenzo Stoakes (Oracle) wrote:
> > On Fri, Mar 06, 2026 at 11:13:41AM +0000, Pedro Falcato wrote:
> >> On Fri, Mar 06, 2026 at 11:15:56AM +0100, David Hildenbrand (Arm) wrote:
> >>> 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.
> >>>
> >>> Cc: Andrew Morton <akpm@linux-foundation.org>
> >>> Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
> >>> Cc: Nicholas Piggin <npiggin@gmail.com>
> >>> Cc: Michael Ellerman <mpe@ellerman.id.au>
> >>> Cc: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
> >>> Cc: Muchun Song <muchun.song@linux.dev>
> >>> Cc: Oscar Salvador <osalvador@suse.de>
> >>> Cc: Lorenzo Stoakes <ljs@kernel.org>
> >>> Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
> >>> Cc: Vlastimil Babka <vbabka@kernel.org>
> >>> Cc: Mike Rapoport <rppt@kernel.org>
> >>> Cc: Suren Baghdasaryan <surenb@google.com>
> >>> Cc: Michal Hocko <mhocko@suse.com>
> >>> Cc: Jann Horn <jannh@google.com>
> >>> Cc: Pedro Falcato <pfalcato@suse.de>
> >>> Cc: Paolo Bonzini <pbonzini@redhat.com>
> >>> Cc: Dan Williams <dan.j.williams@intel.com>
> >>
> >> 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 ...". :)

;)

Wasn't aware of that option actually, handy!

>
> --
> Cheers,
>
> David

Cheers, Lorenzo
Re: [PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Posted by David Hildenbrand (Arm) 1 month ago
On 3/9/26 14:42, Lorenzo Stoakes (Oracle) wrote:
> On Fri, Mar 06, 2026 at 02:12:50PM +0100, David Hildenbrand (Arm) wrote:
>> On 3/6/26 12:19, Lorenzo Stoakes (Oracle) wrote:
>>>
>>> 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!

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.

-- 
Cheers,

David
Re: [PATCH v1 0/4] mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c
Posted by Vlastimil Babka 1 month ago
On 3/9/26 16:07, David Hildenbrand (Arm) wrote:
> On 3/9/26 14:42, Lorenzo Stoakes (Oracle) wrote:
>> On Fri, Mar 06, 2026 at 02:12:50PM +0100, David Hildenbrand (Arm) wrote:
>>> On 3/6/26 12:19, Lorenzo Stoakes (Oracle) wrote:
>>>>
>>>> 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!
> 
> 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.

> 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".