erofs and zonefs are using vma_desc_test_any() twice to check whether all
of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add
vma_desc_test_all() to test all flags and update erofs and zonefs to use
it.
While we're here, update the helper function comments to be more
consistent.
Also add the same to the VMA test headers.
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
---
fs/erofs/data.c | 3 +--
fs/zonefs/file.c | 3 +--
include/linux/mm.h | 24 ++++++++++++++++++++----
tools/testing/vma/include/dup.h | 9 +++++++++
4 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 6774d9b5ee82..b33dd4d8710e 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -473,8 +473,7 @@ static int erofs_file_mmap_prepare(struct vm_area_desc *desc)
if (!IS_DAX(file_inode(desc->file)))
return generic_file_readonly_mmap_prepare(desc);
- if (vma_desc_test_any(desc, VMA_SHARED_BIT) &&
- vma_desc_test_any(desc, VMA_MAYWRITE_BIT))
+ if (vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT))
return -EINVAL;
desc->vm_ops = &erofs_dax_vm_ops;
diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c
index 9f9273ecf71a..5ada33f70bb4 100644
--- a/fs/zonefs/file.c
+++ b/fs/zonefs/file.c
@@ -333,8 +333,7 @@ static int zonefs_file_mmap_prepare(struct vm_area_desc *desc)
* ordering between msync() and page cache writeback.
*/
if (zonefs_inode_is_seq(file_inode(file)) &&
- vma_desc_test_any(desc, VMA_SHARED_BIT) &&
- vma_desc_test_any(desc, VMA_MAYWRITE_BIT))
+ vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT))
return -EINVAL;
file_accessed(file);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index db738a567637..9a052eedcdf4 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1178,7 +1178,7 @@ static inline void vma_set_flags_mask(struct vm_area_struct *vma,
#define vma_set_flags(vma, ...) \
vma_set_flags_mask(vma, mk_vma_flags(__VA_ARGS__))
-/* Helper to test all VMA flags in a VMA descriptor. */
+/* Helper to test any VMA flags in a VMA descriptor. */
static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc,
vma_flags_t flags)
{
@@ -1186,8 +1186,8 @@ static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc,
}
/*
- * Helper macro for testing VMA flags for an input pointer to a struct
- * vm_area_desc object describing a proposed VMA, e.g.:
+ * Helper macro for testing whether any VMA flags are set in a VMA descriptor,
+ * e.g.:
*
* if (vma_desc_test_any(desc, VMA_IO_BIT, VMA_PFNMAP_BIT,
* VMA_DONTEXPAND_BIT, VMA_DONTDUMP_BIT)) { ... }
@@ -1195,6 +1195,22 @@ static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc,
#define vma_desc_test_any(desc, ...) \
vma_desc_test_any_mask(desc, mk_vma_flags(__VA_ARGS__))
+/* Helper to test all VMA flags in a VMA descriptor. */
+static inline bool vma_desc_test_all_mask(const struct vm_area_desc *desc,
+ vma_flags_t flags)
+{
+ return vma_flags_test_all_mask(&desc->vma_flags, flags);
+}
+
+/*
+ * Helper macro for testing whether ALL VMA flags are set in a VMA descriptor,
+ * e.g.:
+ *
+ * if (vma_desc_test_all(desc, VMA_READ_BIT, VMA_MAYREAD_BIT)) { ... }
+ */
+#define vma_desc_test_all(desc, ...) \
+ vma_desc_test_all_mask(desc, mk_vma_flags(__VA_ARGS__))
+
/* Helper to set all VMA flags in a VMA descriptor. */
static inline void vma_desc_set_flags_mask(struct vm_area_desc *desc,
vma_flags_t flags)
@@ -1207,7 +1223,7 @@ static inline void vma_desc_set_flags_mask(struct vm_area_desc *desc,
* vm_area_desc object describing a proposed VMA, e.g.:
*
* vma_desc_set_flags(desc, VMA_IO_BIT, VMA_PFNMAP_BIT, VMA_DONTEXPAND_BIT,
- * VMA_DONTDUMP_BIT);
+ * VMA_DONTDUMP_BIT);
*/
#define vma_desc_set_flags(desc, ...) \
vma_desc_set_flags_mask(desc, mk_vma_flags(__VA_ARGS__))
diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h
index c46b523e428d..59788bc14d75 100644
--- a/tools/testing/vma/include/dup.h
+++ b/tools/testing/vma/include/dup.h
@@ -922,6 +922,15 @@ static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc,
#define vma_desc_test_any(desc, ...) \
vma_desc_test_any_mask(desc, mk_vma_flags(__VA_ARGS__))
+static inline bool vma_desc_test_all_mask(const struct vm_area_desc *desc,
+ vma_flags_t flags)
+{
+ return vma_flags_test_all_mask(&desc->vma_flags, flags);
+}
+
+#define vma_desc_test_all(desc, ...) \
+ vma_desc_test_all_mask(desc, mk_vma_flags(__VA_ARGS__))
+
static inline void vma_desc_set_flags_mask(struct vm_area_desc *desc,
vma_flags_t flags)
{
--
2.53.0
On Thu, Mar 05, 2026 at 10:50:15AM +0000, Lorenzo Stoakes (Oracle) wrote: > erofs and zonefs are using vma_desc_test_any() twice to check whether all > of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add > vma_desc_test_all() to test all flags and update erofs and zonefs to use > it. > > While we're here, update the helper function comments to be more > consistent. > > Also add the same to the VMA test headers. > > Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org> Reviewed-by: Pedro Falcato <pfalcato@suse.de> -- Pedro
On 3/5/26 11:50, Lorenzo Stoakes (Oracle) wrote: > erofs and zonefs are using vma_desc_test_any() twice to check whether all > of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add > vma_desc_test_all() to test all flags and update erofs and zonefs to use > it. > > While we're here, update the helper function comments to be more > consistent. > > Also add the same to the VMA test headers. > > Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org> > --- Nothing jumped at me Acked-by: David Hildenbrand (Arm) <david@kernel.org> -- Cheers, David
On 3/5/26 11:50, Lorenzo Stoakes (Oracle) wrote:
> erofs and zonefs are using vma_desc_test_any() twice to check whether all
> of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add
> vma_desc_test_all() to test all flags and update erofs and zonefs to use
> it.
>
> While we're here, update the helper function comments to be more
> consistent.
>
> Also add the same to the VMA test headers.
>
> Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
I thought I saw David review all of the series and so focused on other
stuff, didn't notice he skipped this one :)
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> ---
> fs/erofs/data.c | 3 +--
> fs/zonefs/file.c | 3 +--
> include/linux/mm.h | 24 ++++++++++++++++++++----
> tools/testing/vma/include/dup.h | 9 +++++++++
> 4 files changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 6774d9b5ee82..b33dd4d8710e 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -473,8 +473,7 @@ static int erofs_file_mmap_prepare(struct vm_area_desc *desc)
> if (!IS_DAX(file_inode(desc->file)))
> return generic_file_readonly_mmap_prepare(desc);
>
> - if (vma_desc_test_any(desc, VMA_SHARED_BIT) &&
> - vma_desc_test_any(desc, VMA_MAYWRITE_BIT))
> + if (vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT))
> return -EINVAL;
>
> desc->vm_ops = &erofs_dax_vm_ops;
> diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c
> index 9f9273ecf71a..5ada33f70bb4 100644
> --- a/fs/zonefs/file.c
> +++ b/fs/zonefs/file.c
> @@ -333,8 +333,7 @@ static int zonefs_file_mmap_prepare(struct vm_area_desc *desc)
> * ordering between msync() and page cache writeback.
> */
> if (zonefs_inode_is_seq(file_inode(file)) &&
> - vma_desc_test_any(desc, VMA_SHARED_BIT) &&
> - vma_desc_test_any(desc, VMA_MAYWRITE_BIT))
> + vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT))
> return -EINVAL;
>
> file_accessed(file);
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index db738a567637..9a052eedcdf4 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1178,7 +1178,7 @@ static inline void vma_set_flags_mask(struct vm_area_struct *vma,
> #define vma_set_flags(vma, ...) \
> vma_set_flags_mask(vma, mk_vma_flags(__VA_ARGS__))
>
> -/* Helper to test all VMA flags in a VMA descriptor. */
> +/* Helper to test any VMA flags in a VMA descriptor. */
> static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc,
> vma_flags_t flags)
> {
> @@ -1186,8 +1186,8 @@ static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc,
> }
>
> /*
> - * Helper macro for testing VMA flags for an input pointer to a struct
> - * vm_area_desc object describing a proposed VMA, e.g.:
> + * Helper macro for testing whether any VMA flags are set in a VMA descriptor,
> + * e.g.:
> *
> * if (vma_desc_test_any(desc, VMA_IO_BIT, VMA_PFNMAP_BIT,
> * VMA_DONTEXPAND_BIT, VMA_DONTDUMP_BIT)) { ... }
> @@ -1195,6 +1195,22 @@ static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc,
> #define vma_desc_test_any(desc, ...) \
> vma_desc_test_any_mask(desc, mk_vma_flags(__VA_ARGS__))
>
> +/* Helper to test all VMA flags in a VMA descriptor. */
> +static inline bool vma_desc_test_all_mask(const struct vm_area_desc *desc,
> + vma_flags_t flags)
> +{
> + return vma_flags_test_all_mask(&desc->vma_flags, flags);
> +}
> +
> +/*
> + * Helper macro for testing whether ALL VMA flags are set in a VMA descriptor,
> + * e.g.:
> + *
> + * if (vma_desc_test_all(desc, VMA_READ_BIT, VMA_MAYREAD_BIT)) { ... }
> + */
> +#define vma_desc_test_all(desc, ...) \
> + vma_desc_test_all_mask(desc, mk_vma_flags(__VA_ARGS__))
> +
> /* Helper to set all VMA flags in a VMA descriptor. */
> static inline void vma_desc_set_flags_mask(struct vm_area_desc *desc,
> vma_flags_t flags)
> @@ -1207,7 +1223,7 @@ static inline void vma_desc_set_flags_mask(struct vm_area_desc *desc,
> * vm_area_desc object describing a proposed VMA, e.g.:
> *
> * vma_desc_set_flags(desc, VMA_IO_BIT, VMA_PFNMAP_BIT, VMA_DONTEXPAND_BIT,
> - * VMA_DONTDUMP_BIT);
> + * VMA_DONTDUMP_BIT);
> */
> #define vma_desc_set_flags(desc, ...) \
> vma_desc_set_flags_mask(desc, mk_vma_flags(__VA_ARGS__))
> diff --git a/tools/testing/vma/include/dup.h b/tools/testing/vma/include/dup.h
> index c46b523e428d..59788bc14d75 100644
> --- a/tools/testing/vma/include/dup.h
> +++ b/tools/testing/vma/include/dup.h
> @@ -922,6 +922,15 @@ static inline bool vma_desc_test_any_mask(const struct vm_area_desc *desc,
> #define vma_desc_test_any(desc, ...) \
> vma_desc_test_any_mask(desc, mk_vma_flags(__VA_ARGS__))
>
> +static inline bool vma_desc_test_all_mask(const struct vm_area_desc *desc,
> + vma_flags_t flags)
> +{
> + return vma_flags_test_all_mask(&desc->vma_flags, flags);
> +}
> +
> +#define vma_desc_test_all(desc, ...) \
> + vma_desc_test_all_mask(desc, mk_vma_flags(__VA_ARGS__))
> +
> static inline void vma_desc_set_flags_mask(struct vm_area_desc *desc,
> vma_flags_t flags)
> {
On 3/25/26 08:31, Vlastimil Babka (SUSE) wrote: > On 3/5/26 11:50, Lorenzo Stoakes (Oracle) wrote: >> erofs and zonefs are using vma_desc_test_any() twice to check whether all >> of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add >> vma_desc_test_all() to test all flags and update erofs and zonefs to use >> it. >> >> While we're here, update the helper function comments to be more >> consistent. >> >> Also add the same to the VMA test headers. >> >> Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org> > > I thought I saw David review all of the series and so focused on other > stuff, didn't notice he skipped this one :) I think I skipped it because it looked too mechanical when scanning and I was like "ofc I trust Lorenzo on that one blindly". So I missed to reply. Tag provided now if it helps. -- Cheers, David
On Wed, Mar 25, 2026 at 09:58:53AM +0100, David Hildenbrand (Arm) wrote: > On 3/25/26 08:31, Vlastimil Babka (SUSE) wrote: > > On 3/5/26 11:50, Lorenzo Stoakes (Oracle) wrote: > >> erofs and zonefs are using vma_desc_test_any() twice to check whether all > >> of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add > >> vma_desc_test_all() to test all flags and update erofs and zonefs to use > >> it. > >> > >> While we're here, update the helper function comments to be more > >> consistent. > >> > >> Also add the same to the VMA test headers. > >> > >> Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org> > > > > I thought I saw David review all of the series and so focused on other > > stuff, didn't notice he skipped this one :) > > I think I skipped it because it looked too mechanical when scanning and > I was like "ofc I trust Lorenzo on that one blindly". So I missed to reply. > > Tag provided now if it helps. Thanks guys! Appreciated.
On Thu, 5 Mar 2026 10:50:15 +0000 "Lorenzo Stoakes (Oracle)" <ljs@kernel.org> wrote: > erofs and zonefs are using vma_desc_test_any() twice to check whether all > of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add > vma_desc_test_all() to test all flags and update erofs and zonefs to use > it. > > While we're here, update the helper function comments to be more > consistent. > > Also add the same to the VMA test headers. fwiw, we have no review tags on this one.
On Tue, Mar 24, 2026 at 04:12:12PM -0700, Andrew Morton wrote: > On Thu, 5 Mar 2026 10:50:15 +0000 "Lorenzo Stoakes (Oracle)" <ljs@kernel.org> wrote: > > > erofs and zonefs are using vma_desc_test_any() twice to check whether all > > of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add > > vma_desc_test_all() to test all flags and update erofs and zonefs to use > > it. > > > > While we're here, update the helper function comments to be more > > consistent. > > > > Also add the same to the VMA test headers. > > fwiw, we have no review tags on this one. Based on the discussion we had about this previously I was under the impression if submitted by a maintainer that wasn't required? I'll nag people, but I'm a bit surprised if this is why you haven't moved this to mm-stable, given how trivially obviously correct this patch is. Lorenzo
On Wed, 25 Mar 2026 07:08:22 +0000 "Lorenzo Stoakes (Oracle)" <ljs@kernel.org> wrote: > On Tue, Mar 24, 2026 at 04:12:12PM -0700, Andrew Morton wrote: > > On Thu, 5 Mar 2026 10:50:15 +0000 "Lorenzo Stoakes (Oracle)" <ljs@kernel.org> wrote: > > > > > erofs and zonefs are using vma_desc_test_any() twice to check whether all > > > of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add > > > vma_desc_test_all() to test all flags and update erofs and zonefs to use > > > it. > > > > > > While we're here, update the helper function comments to be more > > > consistent. > > > > > > Also add the same to the VMA test headers. > > > > fwiw, we have no review tags on this one. > > Based on the discussion we had about this previously I was under the impression > if submitted by a maintainer that wasn't required? Well, it's a gray area. Obviously it's better if people's stuff is checked by co-maintainers or by others. I'm not inclined to make a fuss about it though (hence "fwiw"). Quite a lot of unreviewed maintainer-authored material ends up going upstream and I don't think that's causing much harm. In a lot of cases this is pretty much unavoidable because the patch comes from a sole maintainer (SJ, Sergey, Ulad, Liam come to mind). But when the author has co-maintainers, perhaps those people could step up. > I'll nag people, but I'm a bit surprised if this is why you haven't moved this > to mm-stable, given how trivially obviously correct this patch is. https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/pc/devel-series shows my expected merging order. It looks like this one will be in the next batch ->mm-stable.
On Wed, Mar 25, 2026 at 07:30:54AM -0700, Andrew Morton wrote: > On Wed, 25 Mar 2026 07:08:22 +0000 "Lorenzo Stoakes (Oracle)" <ljs@kernel.org> wrote: > > > On Tue, Mar 24, 2026 at 04:12:12PM -0700, Andrew Morton wrote: > > > On Thu, 5 Mar 2026 10:50:15 +0000 "Lorenzo Stoakes (Oracle)" <ljs@kernel.org> wrote: > > > > > > > erofs and zonefs are using vma_desc_test_any() twice to check whether all > > > > of VMA_SHARED_BIT and VMA_MAYWRITE_BIT are set, this is silly, so add > > > > vma_desc_test_all() to test all flags and update erofs and zonefs to use > > > > it. > > > > > > > > While we're here, update the helper function comments to be more > > > > consistent. > > > > > > > > Also add the same to the VMA test headers. > > > > > > fwiw, we have no review tags on this one. > > > > Based on the discussion we had about this previously I was under the impression > > if submitted by a maintainer that wasn't required? > > Well, it's a gray area. Obviously it's better if people's stuff is > checked by co-maintainers or by others. OK that contradicts the previous conversation we had where you had to convince me that this was ok (which I ended up agreeing with), rather than being a grey area. We had quite a long conversation about maintainers are in a trusted role so a co-maintainer would have called it out it was wrong and etc. But sure it'd be nice to get review, obviously I agree with that. > > I'm not inclined to make a fuss about it though (hence "fwiw"). Quite > a lot of unreviewed maintainer-authored material ends up going upstream > and I don't think that's causing much harm. I think you need to be a lot clearer in communicating these things while the process remains undocumented. In this case for instance, I took that to mean that you required review, the 'fwiw' doesn't really make it clear that this was optional, especially given this patch is so trivial. > > In a lot of cases this is pretty much unavoidable because the patch > comes from a sole maintainer (SJ, Sergey, Ulad, Liam come to mind). > But when the author has co-maintainers, perhaps those people could step > up. Right. > > > I'll nag people, but I'm a bit surprised if this is why you haven't moved this > > to mm-stable, given how trivially obviously correct this patch is. > > https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/pc/devel-series > shows my expected merging order. It looks like this one will be in the > next batch ->mm-stable. > I'll definietly need some decoding of that to understand where each batch is? To me it reads as a bunch of inscrutible #'s and file names... Thanks, Lorenzo
© 2016 - 2026 Red Hat, Inc.