[PATCH 0/3] use vm_flags_t consistently

Lorenzo Stoakes posted 3 patches 3 months, 3 weeks ago
arch/arm/mm/fault.c                        |   2 +-
arch/arm64/include/asm/mman.h              |  10 +-
arch/arm64/mm/fault.c                      |   2 +-
arch/arm64/mm/mmap.c                       |   2 +-
arch/arm64/mm/mmu.c                        |   2 +-
arch/powerpc/include/asm/book3s/64/pkeys.h |   3 +-
arch/powerpc/include/asm/mman.h            |   2 +-
arch/powerpc/include/asm/pkeys.h           |   4 +-
arch/powerpc/kvm/book3s_hv_uvmem.c         |   2 +-
arch/sparc/include/asm/mman.h              |   4 +-
arch/sparc/mm/init_64.c                    |   2 +-
arch/x86/kernel/cpu/sgx/encl.c             |   8 +-
arch/x86/kernel/cpu/sgx/encl.h             |   2 +-
arch/x86/mm/pgprot.c                       |   2 +-
fs/exec.c                                  |   2 +-
fs/userfaultfd.c                           |   2 +-
include/linux/coredump.h                   |   2 +-
include/linux/huge_mm.h                    |  12 +-
include/linux/khugepaged.h                 |   4 +-
include/linux/ksm.h                        |   4 +-
include/linux/memfd.h                      |   4 +-
include/linux/mm.h                         |  10 +-
include/linux/mm_types.h                   |   2 +-
include/linux/mman.h                       |   4 +-
include/linux/pgtable.h                    |   2 +-
include/linux/rmap.h                       |   4 +-
include/linux/userfaultfd_k.h              |   4 +-
include/trace/events/fs_dax.h              |   6 +-
mm/debug.c                                 |   2 +-
mm/execmem.c                               |   8 +-
mm/filemap.c                               |   2 +-
mm/gup.c                                   |   2 +-
mm/huge_memory.c                           |   2 +-
mm/hugetlb.c                               |   4 +-
mm/internal.h                              |   4 +-
mm/khugepaged.c                            |   4 +-
mm/ksm.c                                   |   2 +-
mm/madvise.c                               |   4 +-
mm/mapping_dirty_helpers.c                 |   2 +-
mm/memfd.c                                 |   8 +-
mm/memory.c                                |   4 +-
mm/mmap.c                                  |  16 +-
mm/mprotect.c                              |   8 +-
mm/mremap.c                                |   2 +-
mm/nommu.c                                 |  12 +-
mm/rmap.c                                  |   4 +-
mm/shmem.c                                 |   6 +-
mm/userfaultfd.c                           |  14 +-
mm/vma.c                                   |  78 +++---
mm/vma.h                                   |  16 +-
mm/vmscan.c                                |   4 +-
tools/testing/vma/vma.c                    | 266 ++++++++++-----------
tools/testing/vma/vma_internal.h           |  12 +-
53 files changed, 298 insertions(+), 297 deletions(-)
[PATCH 0/3] use vm_flags_t consistently
Posted by Lorenzo Stoakes 3 months, 3 weeks ago
The VMA flags field vma->vm_flags is of type vm_flags_t. Right now this is
exactly equivalent to unsigned long, but it should not be assumed to be.

Much code that references vma->vm_flags already correctly uses vm_flags_t,
but a fairly large chunk of code simply uses unsigned long and assumes that
the two are equivalent.

This series corrects that and has us use vm_flags_t consistently.

This series is motivated by the desire to, in a future series, adjust
vm_flags_t to be a u64 regardless of whether the kernel is 32-bit or 64-bit
in order to deal with the VMA flag exhaustion issue and avoid all the
various problems that arise from it (being unable to use certain features
in 32-bit, being unable to add new flags except for 64-bit, etc.)

This is therefore a critical first step towards that goal. At any rate,
using the correct type is of value regardless.

We additionally take the opportunity to refer to VMA flags as vm_flags
where possible to make clear what we're referring to.

Overall, this series does not introduce any functional change.

Lorenzo Stoakes (3):
  mm: change vm_get_page_prot() to accept vm_flags_t argument
  mm: update core kernel code to use vm_flags_t consistently
  mm: update architecture and driver code to use vm_flags_t

 arch/arm/mm/fault.c                        |   2 +-
 arch/arm64/include/asm/mman.h              |  10 +-
 arch/arm64/mm/fault.c                      |   2 +-
 arch/arm64/mm/mmap.c                       |   2 +-
 arch/arm64/mm/mmu.c                        |   2 +-
 arch/powerpc/include/asm/book3s/64/pkeys.h |   3 +-
 arch/powerpc/include/asm/mman.h            |   2 +-
 arch/powerpc/include/asm/pkeys.h           |   4 +-
 arch/powerpc/kvm/book3s_hv_uvmem.c         |   2 +-
 arch/sparc/include/asm/mman.h              |   4 +-
 arch/sparc/mm/init_64.c                    |   2 +-
 arch/x86/kernel/cpu/sgx/encl.c             |   8 +-
 arch/x86/kernel/cpu/sgx/encl.h             |   2 +-
 arch/x86/mm/pgprot.c                       |   2 +-
 fs/exec.c                                  |   2 +-
 fs/userfaultfd.c                           |   2 +-
 include/linux/coredump.h                   |   2 +-
 include/linux/huge_mm.h                    |  12 +-
 include/linux/khugepaged.h                 |   4 +-
 include/linux/ksm.h                        |   4 +-
 include/linux/memfd.h                      |   4 +-
 include/linux/mm.h                         |  10 +-
 include/linux/mm_types.h                   |   2 +-
 include/linux/mman.h                       |   4 +-
 include/linux/pgtable.h                    |   2 +-
 include/linux/rmap.h                       |   4 +-
 include/linux/userfaultfd_k.h              |   4 +-
 include/trace/events/fs_dax.h              |   6 +-
 mm/debug.c                                 |   2 +-
 mm/execmem.c                               |   8 +-
 mm/filemap.c                               |   2 +-
 mm/gup.c                                   |   2 +-
 mm/huge_memory.c                           |   2 +-
 mm/hugetlb.c                               |   4 +-
 mm/internal.h                              |   4 +-
 mm/khugepaged.c                            |   4 +-
 mm/ksm.c                                   |   2 +-
 mm/madvise.c                               |   4 +-
 mm/mapping_dirty_helpers.c                 |   2 +-
 mm/memfd.c                                 |   8 +-
 mm/memory.c                                |   4 +-
 mm/mmap.c                                  |  16 +-
 mm/mprotect.c                              |   8 +-
 mm/mremap.c                                |   2 +-
 mm/nommu.c                                 |  12 +-
 mm/rmap.c                                  |   4 +-
 mm/shmem.c                                 |   6 +-
 mm/userfaultfd.c                           |  14 +-
 mm/vma.c                                   |  78 +++---
 mm/vma.h                                   |  16 +-
 mm/vmscan.c                                |   4 +-
 tools/testing/vma/vma.c                    | 266 ++++++++++-----------
 tools/testing/vma/vma_internal.h           |  12 +-
 53 files changed, 298 insertions(+), 297 deletions(-)

--
2.49.0
Re: [PATCH 0/3] use vm_flags_t consistently
Posted by Anshuman Khandual 3 months, 2 weeks ago
On 19/06/25 1:12 AM, Lorenzo Stoakes wrote:
> The VMA flags field vma->vm_flags is of type vm_flags_t. Right now this is
> exactly equivalent to unsigned long, but it should not be assumed to be.
> 
> Much code that references vma->vm_flags already correctly uses vm_flags_t,
> but a fairly large chunk of code simply uses unsigned long and assumes that
> the two are equivalent.
> 
> This series corrects that and has us use vm_flags_t consistently.
> 
> This series is motivated by the desire to, in a future series, adjust
> vm_flags_t to be a u64 regardless of whether the kernel is 32-bit or 64-bit
> in order to deal with the VMA flag exhaustion issue and avoid all the
> various problems that arise from it (being unable to use certain features
> in 32-bit, being unable to add new flags except for 64-bit, etc.)
> 
> This is therefore a critical first step towards that goal. At any rate,
> using the correct type is of value regardless.
> 
> We additionally take the opportunity to refer to VMA flags as vm_flags
> where possible to make clear what we're referring to.
> 
> Overall, this series does not introduce any functional change.
> 
> Lorenzo Stoakes (3):
>   mm: change vm_get_page_prot() to accept vm_flags_t argument
>   mm: update core kernel code to use vm_flags_t consistently
>   mm: update architecture and driver code to use vm_flags_t

Hello Lorenzo,

Just wondering which tree-branch this series applies ? Tried all the usual
ones but could not apply the series cleanly.

v6.16-rc3
next-20250624
mm-stable
mm-unstable

b4 am cover.1750274467.git.lorenzo.stoakes@oracle.com
git am ./20250618_lorenzo_stoakes_use_vm_flags_t_consistently.mbx

- Anshuman
Re: [PATCH 0/3] use vm_flags_t consistently
Posted by Andrew Morton 3 months, 2 weeks ago
On Wed, 25 Jun 2025 08:25:35 +0530 Anshuman Khandual <anshuman.khandual@arm.com> wrote:

> ust wondering which tree-branch this series applies ? Tried all the usual
> ones but could not apply the series cleanly.
> 
> v6.16-rc3
> next-20250624
> mm-stable
> mm-unstable

It's now in mm-unstable if that helps.
Re: [PATCH 0/3] use vm_flags_t consistently
Posted by Lorenzo Stoakes 3 months, 2 weeks ago
On Tue, Jun 24, 2025 at 09:50:50PM -0700, Andrew Morton wrote:
> On Wed, 25 Jun 2025 08:25:35 +0530 Anshuman Khandual <anshuman.khandual@arm.com> wrote:
>
> > ust wondering which tree-branch this series applies ? Tried all the usual
> > ones but could not apply the series cleanly.
> >
> > v6.16-rc3
> > next-20250624
> > mm-stable
> > mm-unstable
>
> It's now in mm-unstable if that helps.

Thanks Andrew!

Just FYI Ashuman - it was applied against the new and shiny (TM) mm-new branch,
maybe we didn't publicise this well enough...

This is the absolute tippy tip of mm development and so may be broken in hideous
ways, but it's what new work should be rebased on.

Then if accepted + stable things trickle to mm-unstable for -next testing (we're
trying to avoid breaking -next too much) and then later mm-stable if all's good
for send ->Linus.

Cheers, Lorenzo
Re: [PATCH 0/3] use vm_flags_t consistently
Posted by Mike Rapoport 3 months, 3 weeks ago
On Wed, Jun 18, 2025 at 08:42:51PM +0100, Lorenzo Stoakes wrote:
> The VMA flags field vma->vm_flags is of type vm_flags_t. Right now this is
> exactly equivalent to unsigned long, but it should not be assumed to be.
> 
> Much code that references vma->vm_flags already correctly uses vm_flags_t,
> but a fairly large chunk of code simply uses unsigned long and assumes that
> the two are equivalent.
> 
> This series corrects that and has us use vm_flags_t consistently.
> 
> This series is motivated by the desire to, in a future series, adjust
> vm_flags_t to be a u64 regardless of whether the kernel is 32-bit or 64-bit
> in order to deal with the VMA flag exhaustion issue and avoid all the
> various problems that arise from it (being unable to use certain features
> in 32-bit, being unable to add new flags except for 64-bit, etc.)
> 
> This is therefore a critical first step towards that goal. At any rate,
> using the correct type is of value regardless.
> 
> We additionally take the opportunity to refer to VMA flags as vm_flags
> where possible to make clear what we're referring to.
> 
> Overall, this series does not introduce any functional change.
> 
> Lorenzo Stoakes (3):
>   mm: change vm_get_page_prot() to accept vm_flags_t argument
>   mm: update core kernel code to use vm_flags_t consistently
>   mm: update architecture and driver code to use vm_flags_t

For the series

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
 
>  arch/arm/mm/fault.c                        |   2 +-
>  arch/arm64/include/asm/mman.h              |  10 +-
>  arch/arm64/mm/fault.c                      |   2 +-
>  arch/arm64/mm/mmap.c                       |   2 +-
>  arch/arm64/mm/mmu.c                        |   2 +-
>  arch/powerpc/include/asm/book3s/64/pkeys.h |   3 +-
>  arch/powerpc/include/asm/mman.h            |   2 +-
>  arch/powerpc/include/asm/pkeys.h           |   4 +-
>  arch/powerpc/kvm/book3s_hv_uvmem.c         |   2 +-
>  arch/sparc/include/asm/mman.h              |   4 +-
>  arch/sparc/mm/init_64.c                    |   2 +-
>  arch/x86/kernel/cpu/sgx/encl.c             |   8 +-
>  arch/x86/kernel/cpu/sgx/encl.h             |   2 +-
>  arch/x86/mm/pgprot.c                       |   2 +-
>  fs/exec.c                                  |   2 +-
>  fs/userfaultfd.c                           |   2 +-
>  include/linux/coredump.h                   |   2 +-
>  include/linux/huge_mm.h                    |  12 +-
>  include/linux/khugepaged.h                 |   4 +-
>  include/linux/ksm.h                        |   4 +-
>  include/linux/memfd.h                      |   4 +-
>  include/linux/mm.h                         |  10 +-
>  include/linux/mm_types.h                   |   2 +-
>  include/linux/mman.h                       |   4 +-
>  include/linux/pgtable.h                    |   2 +-
>  include/linux/rmap.h                       |   4 +-
>  include/linux/userfaultfd_k.h              |   4 +-
>  include/trace/events/fs_dax.h              |   6 +-
>  mm/debug.c                                 |   2 +-
>  mm/execmem.c                               |   8 +-
>  mm/filemap.c                               |   2 +-
>  mm/gup.c                                   |   2 +-
>  mm/huge_memory.c                           |   2 +-
>  mm/hugetlb.c                               |   4 +-
>  mm/internal.h                              |   4 +-
>  mm/khugepaged.c                            |   4 +-
>  mm/ksm.c                                   |   2 +-
>  mm/madvise.c                               |   4 +-
>  mm/mapping_dirty_helpers.c                 |   2 +-
>  mm/memfd.c                                 |   8 +-
>  mm/memory.c                                |   4 +-
>  mm/mmap.c                                  |  16 +-
>  mm/mprotect.c                              |   8 +-
>  mm/mremap.c                                |   2 +-
>  mm/nommu.c                                 |  12 +-
>  mm/rmap.c                                  |   4 +-
>  mm/shmem.c                                 |   6 +-
>  mm/userfaultfd.c                           |  14 +-
>  mm/vma.c                                   |  78 +++---
>  mm/vma.h                                   |  16 +-
>  mm/vmscan.c                                |   4 +-
>  tools/testing/vma/vma.c                    | 266 ++++++++++-----------
>  tools/testing/vma/vma_internal.h           |  12 +-
>  53 files changed, 298 insertions(+), 297 deletions(-)
> 
> --
> 2.49.0

-- 
Sincerely yours,
Mike.