Re: [PATCH v2 08/13] mm: update shmem_[kernel]_file_*() functions to use vma_flags_t

Lorenzo Stoakes
2026-01-23T12:27:57Z

On Thu, Jan 22, 2026 at 11:46:52PM -0800, Darrick J. Wong wrote:
> On Thu, Jan 22, 2026 at 04:06:17PM +0000, Lorenzo Stoakes wrote:
> > In order to be able to use only vma_flags_t in vm_area_desc we must adjust
> > shmem file setup functions to operate in terms of vma_flags_t rather than
> > vm_flags_t.
> >
> > This patch makes this change and updates all callers to use the new
> > functions.
> >
> > No functional changes intended.
> >
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> > ---
> > arch/x86/kernel/cpu/sgx/ioctl.c | 2 +-
> > drivers/gpu/drm/drm_gem.c | 5 +-
> > drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 2 +-
> > drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 3 +-
> > drivers/gpu/drm/i915/gt/shmem_utils.c | 3 +-
> > drivers/gpu/drm/ttm/tests/ttm_tt_test.c | 2 +-
> > drivers/gpu/drm/ttm/ttm_backup.c | 3 +-
> > drivers/gpu/drm/ttm/ttm_tt.c | 2 +-
> > fs/xfs/scrub/xfile.c | 3 +-
> > fs/xfs/xfs_buf_mem.c | 2 +-
> > include/linux/shmem_fs.h | 8 ++-
> > ipc/shm.c | 6 +--
> > mm/memfd.c | 2 +-
> > mm/memfd_luo.c | 2 +-
> > mm/shmem.c | 59 +++++++++++++----------
> > security/keys/big_key.c | 2 +-
> > 16 files changed, 57 insertions(+), 49 deletions(-)
> >
>
> <snip to xfs>
>
> > diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c
> > index c753c79df203..fe0584a39f16 100644
> > --- a/fs/xfs/scrub/xfile.c
> > +++ b/fs/xfs/scrub/xfile.c
> > @@ -61,7 +61,8 @@ xfile_create(
> > if (!xf)
> > return -ENOMEM;
> >
> > - xf->file = shmem_kernel_file_setup(description, isize, VM_NORESERVE);
> > + xf->file = shmem_kernel_file_setup(description, isize,
> > + mk_vma_flags(VMA_NORESERVE_BIT));
>
> Seems fine, macro sorcery aside...

Thanks.

>
> > if (IS_ERR(xf->file)) {
> > error = PTR_ERR(xf->file);
> > goto out_xfile;
> > diff --git a/fs/xfs/xfs_buf_mem.c b/fs/xfs/xfs_buf_mem.c
> > index dcbfa274e06d..fd6f0a5bc0ea 100644
> > --- a/fs/xfs/xfs_buf_mem.c
> > +++ b/fs/xfs/xfs_buf_mem.c
> > @@ -62,7 +62,7 @@ xmbuf_alloc(
> > if (!btp)
> > return -ENOMEM;
> >
> > - file = shmem_kernel_file_setup(descr, 0, 0);
> > + file = shmem_kernel_file_setup(descr, 0, EMPTY_VMA_FLAGS);
>
> ...but does mk_vma_flags() produce the same result?

Doing a quick fs/xfs/xfs_buf_mem.s build suggests so:

Before:

movq %rax, %rbx
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq shmem_kernel_file_setup

After:

movq %rax, %rbx
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq shmem_kernel_file_setup

Quick google to remind myself of x86-64 sysv calling convention and RDI, RSI,
RDX = param 1,2,3, presumably top 32-bits of registers already cleared and so
params 2, 3 being 0 is correct.

So yeah mk_vma_flags() would work too, I guess EMPTY_VMA_FLAGS is more
semantically nice.

But actually could be nice to define EMPTY_VMA_FLAGS that way rather than the
empty initialiser I use now... :) Still no delta anyway afaict.

>
> --D
>
> > if (IS_ERR(file)) {
> > error = PTR_ERR(file);
> > goto out_free_btp;

Cheers, Lorenzo