From: Lorenzo Stoakes <ljs@kernel.org>
To: Zi Yan <ziy@nvidia.com>
Cc: Lance Yang <lance.yang@linux.dev>,
akpm@linux-foundation.org, tsbogend@alpha.franken.de,
maddy@linux.ibm.com, mpe@ellerman.id.au,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
l.stach@pengutronix.de, inki.dae@samsung.com,
sw0312.kim@samsung.com, kyungmin.park@samsung.com,
krzk@kernel.org, peter.griffin@linaro.org,
jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com, tursulin@ursulin.net,
robin.clark@oss.qualcomm.com, lumag@kernel.org,
lyude@redhat.com, dakr@kernel.org,
tomi.valkeinen@ideasonboard.com, hjc@rock-chips.com,
heiko@sntech.de, andy.yan@rock-chips.com,
thierry.reding@kernel.org, mperttunen@nvidia.com,
jonathanh@nvidia.com, kraxel@redhat.com,
dmitry.osipenko@collabora.com, zack.rusin@broadcom.com,
matthew.brost@intel.com, thomas.hellstrom@linux.intel.com,
oleksandr_andrushchenko@epam.com, deller@gmx.de, bcrl@kvack.org,
viro@zeniv.linux.org.uk, brauner@kernel.org,
muchun.song@linux.dev, osalvador@suse.de, david@kernel.org,
baolin.wang@linux.alibaba.com, liam@infradead.org,
npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com,
baohua@kernel.org, hughd@google.com, vbabka@kernel.org,
rppt@kernel.org, surenb@google.com, mhocko@suse.com,
jannh@google.com, pfalcato@suse.de, kees@kernel.org,
perex@perex.cz, tiwai@suse.com, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org,
intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
freedreno@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-rockchip@lists.infradead.org, linux-tegra@vger.kernel.org,
virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org,
xen-devel@lists.xenproject.org, linux-fbdev@vger.kernel.org,
linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, linux-sound@vger.kernel.org
Subject: Re: [PATCH 10/13] mm/vma: convert miscellaneous uses of VMA flags in core mm
Date: Sat, 11 Jul 2026 17:23:19 +0100 [thread overview]
Message-ID: <alJqjo_MZCFWj3Wt@lucifer> (raw)
In-Reply-To: <DJTNXVOWGWJ4.3MDNLPMY0Y3RF@nvidia.com>
On Wed, Jul 08, 2026 at 09:52:19PM -0400, Zi Yan wrote:
> On Thu Jul 2, 2026 at 11:46 AM EDT, Lorenzo Stoakes wrote:
> > On Thu, Jul 02, 2026 at 09:12:33PM +0800, Lance Yang wrote:
> >>
> >> On Mon, Jun 29, 2026 at 08:25:33PM +0100, Lorenzo Stoakes wrote:
> >> >Update various uses of legacy flags in vma.c and mmap.c to the new
> >> >vma_flags_t type, updating comments alongside them to be consistent.
> >> >
> >> >Also update __install_special_mapping() to rearrange things slightly to
> >> >accommodate the changes.
> >> >
> >> >Signed-off-by: Lorenzo Stoakes <ljs@kernel.org>
> >> >---
> >> [...]
> >> >diff --git a/mm/vma.c b/mm/vma.c
> >> >index b81c05e67a61..ab2ef0f04420 100644
> >> >--- a/mm/vma.c
> >> >+++ b/mm/vma.c
> >> >@@ -3417,23 +3417,27 @@ struct vm_area_struct *__install_special_mapping(
> >> > vm_flags_t vm_flags, void *priv,
> >> > const struct vm_operations_struct *ops)
> >> > {
> >> >- int ret;
> >> >+ vma_flags_t vma_flags = legacy_to_vma_flags(vm_flags);
> >> > struct vm_area_struct *vma;
> >> >+ int ret;
> >> >
> >> > vma = vm_area_alloc(mm);
> >> >- if (unlikely(vma == NULL))
> >> >+ if (unlikely(!vma))
> >> > return ERR_PTR(-ENOMEM);
> >> >
> >> >- vma_set_range(vma, addr, addr + len, 0);
> >> >- vm_flags |= vma_flags_to_legacy(mm->def_vma_flags) | VM_DONTEXPAND;
> >> >+ vma_flags_set_mask(&vma_flags, mm->def_vma_flags);
> >> >+ vma_flags_set(&vma_flags, VMA_DONTEXPAND_BIT);
> >> > if (pgtable_supports_soft_dirty())
> >> >- vm_flags |= VM_SOFTDIRTY;
> >> >- vm_flags_init(vma, vm_flags & ~VM_LOCKED_MASK);
> >> >+ vma_flags_set(&vma_flags, VMA_SOFTDIRTY_BIT);
> >> >+ vma_flags_clear_mask(&vma_flags, VMA_LOCKED_MASK);
> >> >+ vma->flags = vma_flags;
> >>
> >> Maybe worth a vma_flags_init() helper here to mirror vm_flags_init()?
> >> With this open-coded, we lose the soft-dirty WARN_ON_ONCE sanity check.
> >>
> >> Might be nicer to keep that check in one place ;)
> >
> > I really hate all the VMA flag accessors, they conflate things horribly - we
> > should be explicitly taking VMA write locks when we need to (and often killable
> > ones actually) not assuming that a VMA flags accessor does (they should at most
> > assert).
> >
> > This case is even more terribly egregious - you are setting flags at an
> > arbitrary time, why are we asserting something about softdirty?
> >
> > You may update them as part of initialisation, maybe not. It's far from a
> > guarantee and feels like a lazy place to put it.
> >
> > BUT obviously it's an oversight not to open code that here, so I'll update the
> > patch to do that!
>
> What do you want to open code here? softdirty WARN_ON_ONCE()?
As you can tell I said this reflexively without checking the code :)
>
> vma_flags gets VMA_SOFTDIRTY_BIT just above vma->flags, why do we need a
> check after that?
And yeah it's completely unnecessary, indeed.
>
> BTW, if you think the check is needed, patch 9 will need to be updated,
> since the same pattern appears in create_init_stack_vma().
I'll check to see if it's valid there.
For me it just feels like the most silly place to put that check, a VMA flags
update should update VMA flags not start randomly asserting silly things :)
>
> >
> > I want VMA flags to be a clean stateless thing, other than the flags
> > themselves. Implicit, unrelated, asserts or lock acquisitions in general should
> > be done separately IMO.
> >
>
> Anyway,
>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
Thanks!
>
> --
> Best Regards,
> Yan, Zi
>
Cheers, Lorenzo
next prev parent reply other threads:[~2026-07-11 16:23 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 19:25 [PATCH 00/13] convert more vm_flags_t users to vma_flags_t Lorenzo Stoakes
2026-06-29 19:25 ` [PATCH 01/13] mm: introduce vma_flags_can_grow() and vma_can_grow() Lorenzo Stoakes
2026-06-29 20:26 ` Zi Yan
2026-06-30 7:38 ` Lorenzo Stoakes
2026-06-30 15:09 ` Zi Yan
2026-07-02 7:27 ` Lance Yang
2026-07-03 15:19 ` Zi Yan
2026-06-29 19:25 ` [PATCH 02/13] mm/vma: update do_mmap() to use vma_flags_t Lorenzo Stoakes
2026-07-02 11:15 ` Lance Yang
2026-07-02 14:16 ` Lorenzo Stoakes
2026-07-02 15:08 ` Lance Yang
2026-07-07 2:10 ` Zi Yan
2026-07-07 10:15 ` Lorenzo Stoakes
2026-06-29 19:25 ` [PATCH 03/13] mm: convert __get_unmapped_area() " Lorenzo Stoakes
2026-07-02 11:37 ` Lance Yang
2026-07-07 2:28 ` Zi Yan
2026-07-07 10:16 ` Lorenzo Stoakes
2026-06-29 19:25 ` [PATCH 04/13] mm: update generic_get_unmapped_area[_topdown]() " Lorenzo Stoakes
2026-07-02 11:41 ` Lance Yang
2026-07-07 2:29 ` Zi Yan
2026-06-29 19:25 ` [PATCH 05/13] mm: prefer mm->def_vma_flags in mm logic Lorenzo Stoakes
2026-07-02 12:10 ` Lance Yang
2026-07-02 15:24 ` Lorenzo Stoakes
2026-07-08 2:06 ` Zi Yan
2026-06-29 19:25 ` [PATCH 06/13] mm/vma: convert vm_pgprot_modify() to use vma_flags_t and rename Lorenzo Stoakes
2026-07-02 12:21 ` Lance Yang
2026-07-02 15:29 ` Lorenzo Stoakes
2026-07-08 2:30 ` Zi Yan
2026-06-29 19:25 ` [PATCH 07/13] mm/vma: rename vma_get_page_prot to vma_flags_to_page_prot Lorenzo Stoakes
2026-07-02 12:25 ` Lance Yang
2026-07-08 2:31 ` Zi Yan
2026-06-29 19:25 ` [PATCH 08/13] mm: introduce vma_get_page_prot() and use it Lorenzo Stoakes
2026-06-30 7:57 ` Thomas Zimmermann
2026-06-30 10:23 ` Jani Nikula
2026-07-02 12:38 ` Lance Yang
2026-07-02 15:40 ` Lorenzo Stoakes
2026-07-08 2:36 ` Zi Yan
2026-06-29 19:25 ` [PATCH 09/13] mm/vma: update create_init_stack_vma() to use vma_flags_t Lorenzo Stoakes
2026-07-02 12:50 ` Lance Yang
2026-07-09 1:42 ` Zi Yan
2026-06-29 19:25 ` [PATCH 10/13] mm/vma: convert miscellaneous uses of VMA flags in core mm Lorenzo Stoakes
2026-07-02 13:12 ` Lance Yang
2026-07-02 15:46 ` Lorenzo Stoakes
2026-07-09 1:52 ` Zi Yan
2026-07-11 16:23 ` Lorenzo Stoakes [this message]
2026-07-11 16:44 ` Lorenzo Stoakes
2026-06-29 19:25 ` [PATCH 11/13] mm/mlock: convert mlock code to use vma_flags_t Lorenzo Stoakes
2026-07-02 13:21 ` Lance Yang
2026-07-02 15:47 ` Lorenzo Stoakes
2026-07-09 2:01 ` Zi Yan
2026-07-11 16:52 ` Lorenzo Stoakes
2026-06-29 19:25 ` [PATCH 12/13] mm/mprotect: convert mprotect " Lorenzo Stoakes
2026-07-01 16:09 ` Lance Yang
2026-07-02 15:53 ` Lorenzo Stoakes
2026-07-09 2:16 ` Zi Yan
2026-07-11 17:04 ` Lorenzo Stoakes
2026-06-29 19:25 ` [PATCH 13/13] mm/mremap: convert mremap " Lorenzo Stoakes
2026-07-02 13:49 ` Lance Yang
2026-07-02 16:07 ` Lorenzo Stoakes
2026-07-02 16:17 ` Lance Yang
2026-07-02 16:31 ` Lorenzo Stoakes
2026-07-09 2:28 ` Zi Yan
2026-07-11 17:09 ` Lorenzo Stoakes
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=alJqjo_MZCFWj3Wt@lucifer \
--to=ljs@kernel.org \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andy.yan@rock-chips.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bcrl@kvack.org \
--cc=brauner@kernel.org \
--cc=dakr@kernel.org \
--cc=david@kernel.org \
--cc=deller@gmx.de \
--cc=dev.jain@arm.com \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=etnaviv@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=hjc@rock-chips.com \
--cc=hughd@google.com \
--cc=inki.dae@samsung.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jannh@google.com \
--cc=jonathanh@nvidia.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kees@kernel.org \
--cc=kraxel@redhat.com \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=l.stach@pengutronix.de \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-aio@kvack.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lumag@kernel.org \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=maddy@linux.ibm.com \
--cc=matthew.brost@intel.com \
--cc=mhocko@suse.com \
--cc=mpe@ellerman.id.au \
--cc=mperttunen@nvidia.com \
--cc=mripard@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nouveau@lists.freedesktop.org \
--cc=npache@redhat.com \
--cc=oleksandr_andrushchenko@epam.com \
--cc=osalvador@suse.de \
--cc=perex@perex.cz \
--cc=peter.griffin@linaro.org \
--cc=pfalcato@suse.de \
--cc=robin.clark@oss.qualcomm.com \
--cc=rodrigo.vivi@intel.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=simona@ffwll.ch \
--cc=surenb@google.com \
--cc=sw0312.kim@samsung.com \
--cc=thierry.reding@kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tiwai@suse.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=tsbogend@alpha.franken.de \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
--cc=vbabka@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=virtualization@lists.linux.dev \
--cc=xen-devel@lists.xenproject.org \
--cc=zack.rusin@broadcom.com \
--cc=ziy@nvidia.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