From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: "Lorenzo Stoakes (Oracle)" <ljs@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>, Gao Xiang <xiang@kernel.org>,
Chao Yu <chao@kernel.org>, Yue Hu <zbestahu@gmail.com>,
Jeffle Xu <jefflexu@linux.alibaba.com>,
Sandeep Dhavale <dhavale@google.com>,
Hongbo Li <lihongbo22@huawei.com>,
Chunhai Guo <guochunhai@vivo.com>,
Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
David Hildenbrand <david@kernel.org>,
Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
Tony Luck <tony.luck@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Dave Martin <Dave.Martin@arm.com>,
James Morse <james.morse@arm.com>,
Babu Moger <babu.moger@amd.com>,
Damien Le Moal <dlemoal@kernel.org>,
Naohiro Aota <naohiro.aota@wdc.com>,
Johannes Thumshirn <jth@kernel.org>,
Matthew Wilcox <willy@infradead.org>, Jan Kara <jack@suse.cz>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Hugh Dickins <hughd@google.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Jann Horn <jannh@google.com>, Pedro Falcato <pfalcato@suse.de>,
Jason Gunthorpe <jgg@ziepe.ca>,
linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev,
linux-cxl@vger.kernel.org, linux-erofs@lists.ozlabs.org,
linux-mm@kvack.org, ntfs3@lists.linux.dev,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/6] mm: add vma_desc_test_all() and use it
Date: Wed, 25 Mar 2026 08:31:09 +0100 [thread overview]
Message-ID: <d0111a86-7fc9-4e2f-b652-9ecbb894ada5@kernel.org> (raw)
In-Reply-To: <568c8f8d6a84ff64014f997517cba7a629f7eed6.1772704455.git.ljs@kernel.org>
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)
> {
next prev parent reply other threads:[~2026-03-25 7:31 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 10:50 [PATCH 0/6] mm: vma flag tweaks Lorenzo Stoakes (Oracle)
2026-03-05 10:50 ` [PATCH 1/6] mm: rename VMA flag helpers to be more readable Lorenzo Stoakes (Oracle)
2026-03-25 8:55 ` David Hildenbrand (Arm)
2026-03-25 14:51 ` Pedro Falcato
2026-03-25 14:53 ` Lorenzo Stoakes (Oracle)
2026-03-05 10:50 ` [PATCH 2/6] mm: add vma_desc_test_all() and use it Lorenzo Stoakes (Oracle)
2026-03-24 23:12 ` Andrew Morton
2026-03-25 7:08 ` Lorenzo Stoakes (Oracle)
2026-03-25 14:30 ` Andrew Morton
2026-03-25 16:20 ` Lorenzo Stoakes (Oracle)
2026-03-25 7:31 ` Vlastimil Babka (SUSE) [this message]
2026-03-25 8:58 ` David Hildenbrand (Arm)
2026-03-25 11:02 ` Lorenzo Stoakes (Oracle)
2026-03-25 8:56 ` David Hildenbrand (Arm)
2026-03-25 14:52 ` Pedro Falcato
2026-03-05 10:50 ` [PATCH 3/6] mm: always inline __mk_vma_flags() and invoked functions Lorenzo Stoakes (Oracle)
2026-03-05 14:48 ` David Hildenbrand (Arm)
2026-03-25 14:54 ` Pedro Falcato
2026-03-25 14:58 ` Lorenzo Stoakes (Oracle)
2026-03-25 16:09 ` Andrew Morton
2026-03-25 16:23 ` Lorenzo Stoakes (Oracle)
2026-03-25 18:27 ` Andrew Morton
2026-03-25 18:44 ` Lorenzo Stoakes (Oracle)
2026-03-25 19:11 ` Andrew Morton
2026-03-05 10:50 ` [PATCH 4/6] mm: reintroduce vma_flags_test() as a singular flag test Lorenzo Stoakes (Oracle)
2026-03-05 13:49 ` David Hildenbrand (Arm)
2026-03-25 14:57 ` Pedro Falcato
2026-03-25 15:02 ` Lorenzo Stoakes (Oracle)
2026-03-05 10:50 ` [PATCH 5/6] mm: reintroduce vma_desc_test() " Lorenzo Stoakes (Oracle)
2026-03-05 13:49 ` David Hildenbrand (Arm)
2026-03-25 14:58 ` Pedro Falcato
2026-03-05 10:50 ` [PATCH 6/6] tools/testing/vma: add test for vma_flags_test(), vma_desc_test() Lorenzo Stoakes (Oracle)
2026-03-05 13:52 ` David Hildenbrand (Arm)
2026-03-05 15:01 ` Lorenzo Stoakes (Oracle)
2026-03-05 15:42 ` David Hildenbrand (Arm)
2026-03-25 8:57 ` David Hildenbrand (Arm)
2026-03-25 15:00 ` Pedro Falcato
2026-03-06 1:28 ` [PATCH 0/6] mm: vma flag tweaks Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d0111a86-7fc9-4e2f-b652-9ecbb894ada5@kernel.org \
--to=vbabka@kernel.org \
--cc=Dave.Martin@arm.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=arnd@arndb.de \
--cc=babu.moger@amd.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=chao@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=david@kernel.org \
--cc=dhavale@google.com \
--cc=dlemoal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=guochunhai@vivo.com \
--cc=hughd@google.com \
--cc=jack@suse.cz \
--cc=james.morse@arm.com \
--cc=jannh@google.com \
--cc=jefflexu@linux.alibaba.com \
--cc=jgg@ziepe.ca \
--cc=jth@kernel.org \
--cc=lihongbo22@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=naohiro.aota@wdc.com \
--cc=ntfs3@lists.linux.dev \
--cc=nvdimm@lists.linux.dev \
--cc=osalvador@suse.de \
--cc=pfalcato@suse.de \
--cc=reinette.chatre@intel.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=tony.luck@intel.com \
--cc=vishal.l.verma@intel.com \
--cc=willy@infradead.org \
--cc=xiang@kernel.org \
--cc=zbestahu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox