Skip to content

mm: vma flag tweaks

Lorenzo Stoakes (Oracle) linux-cxl linux-erofs linux-fsdevel linux-mm lkml ntfs3 nvdimm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 31 repliesIn review 5 of 6 applied

Patches in v1 5 of 6 applied

#Subject and filesSizeRepliesApplied
1/6mm: rename VMA flag helpers to be more readabledrivers/char/mem.c drivers/dax/device.c fs/erofs/data.c +13 more+72 -703 repliesApplied
2/6mm: add vma_desc_test_all() and use itfs/erofs/data.c fs/zonefs/file.c include/linux/mm.h +1 more+31 -89 repliesApplied
3/6mm: always inline __mk_vma_flags() and invoked functionsinclude/linux/mm.h include/linux/mm_types.h tools/testing/vma/include/custom.h +1 more+12 -88 repliesApplied
4/6mm: reintroduce vma_flags_test() as a singular flag testinclude/linux/mm.h mm/hugetlb.c mm/shmem.c +1 more+26 -53 repliesApplied
5/6mm: reintroduce vma_desc_test() as a singular flag testdrivers/char/mem.c fs/hugetlbfs/inode.c fs/ntfs3/file.c +5 more+29 -122 repliesApplied
6/6tools/testing/vma: add test for vma_flags_test(), vma_desc_test()tools/testing/vma/tests/vma.c+36 -05 replies

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchDavid Hildenbrand (Arm)Vlastimil Babka (SUSE)Pedro Falcato
1/6A-b R-b
2/6A-b R-b R-b
3/6A-b R-b
4/6A-b R-b
5/6A-b R-b
6/6A-b A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/6] mm: vma flag tweaks

The ongoing work around introducing non-system word VMA flags has introduced a number of helper functions and macros to make life easier when working with these flags and to make conversions from the legacy use of VM_xxx flags more straightforward.

This series improves these to reduce confusion as to what they do and to improve consistency and readability.

Firstly the series renames vma_flags_test() to vma_flags_test_any() to make it abundantly clear that this function tests whether any of the flags are set (as opposed to vma_flags_test_all()).

It then renames vma_desc_test_flags() to vma_desc_test_any() for the same reason. Note that we drop the 'flags' suffix here, as vma_desc_test_any_flags() would be cumbersome and 'test' implies a flag test.

Similarly, we rename vma_test_all_flags() to vma_test_all() for consistency.

Next, we have a couple of instances (erofs, zonefs) where we are now testing for vma_desc_test_any(desc, VMA_SHARED_BIT) && vma_desc_test_any(desc, VMA_MAYWRITE_BIT).

This is silly, so this series introduces vma_desc_test_all() so these callers can instead invoke vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT).

We then observe that quite a few instances of vma_flags_test_any() and vma_desc_test_any() are in fact only testing against a single flag.

Using the _any() variant here is just confusing - 'any' of single item reads strangely and is liable to cause confusion.

So in these instances the series reintroduces vma_flags_test() and vma_desc_test() as helpers which test against a single flag.

The fact that vma_flags_t is a struct and that vma_flag_t utilises sparse to avoid confusion with vm_flags_t makes it impossible for a user to misuse these helpers without it getting flagged somewhere.

The series also updates __mk_vma_flags() and functions invoked by it to explicitly mark them always inline to match expectation and to be consistent with other VMA flag helpers.

It also renames vma_flag_set() to vma_flags_set_flag() (a function only used by __mk_vma_flags()) to be consistent with other VMA flag helpers.

Finally it updates the VMA tests for each of these changes, and introduces explicit tests for vma_flags_test() and vma_desc_test() to assert that they behave as expected.

Lorenzo Stoakes (Oracle) (6):
mm: rename VMA flag helpers to be more readable
mm: add vma_desc_test_all() and use it
mm: always inline __mk_vma_flags() and invoked functions
mm: reintroduce vma_flags_test() as a singular flag test
mm: reintroduce vma_desc_test() as a singular flag test tools/testing/vma: add test for vma_flags_test(), vma_desc_test()

 drivers/char/mem.c                 |   2 +-
 drivers/dax/device.c               |   2 +-
 fs/erofs/data.c                    |   3 +-
 fs/hugetlbfs/inode.c               |   2 +-
 fs/ntfs3/file.c                    |   2 +-
 fs/resctrl/pseudo_lock.c           |   2 +-
 fs/zonefs/file.c                   |   3 +-
 include/linux/dax.h                |   4 +-
 include/linux/hugetlb_inline.h     |   2 +-
 include/linux/mm.h                 | 100 +++++++++++++++++++++--------
 include/linux/mm_types.h           |   2 +-
 mm/hugetlb.c                       |  12 ++--
 mm/memory.c                        |   2 +-
 mm/secretmem.c                     |   2 +-
 tools/testing/vma/include/custom.h |   5 +-
 tools/testing/vma/include/dup.h    |  48 ++++++++++----
 tools/testing/vma/tests/vma.c      |  58 +++++++++++++----
 17 files changed, 177 insertions(+), 74 deletions(-)

--
2.53.0