[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 10/13] mm/vma: convert miscellaneous uses of VMA flags in core mm
- To: "Lorenzo Stoakes" <ljs@xxxxxxxxxx>, "Lance Yang" <lance.yang@xxxxxxxxx>
- From: "Zi Yan" <ziy@xxxxxxxxxx>
- Date: Wed, 08 Jul 2026 21:52:19 -0400
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dgmsIUewvtgaZUDi1JMSdecE8z2jvCAGnPZP1YDwjOg=; b=EXjke7CUW/5f2iy9OKEz+jRG+TSwpfDGSg6WGGUk9Vv3AIBSt+R1rJ491htqPK22SCzoELEZtKwtScCFKbv6vZRo3e46NKL55QbyDm5h0b4rWYwEZLDvCNNrEUiJF/f3fJoMInWjUHAUWU8Z//NjBp5XKDUDcmlKR9FPrDSRW2RRdcid5IFcwH3iQSYiMlOMvHsWldJmTLcbONJ+8xFYEU52rraucOZAZruZZ5ZTUur0e7jWJGCRYBcjMP+uZyQyVnBnPhHNYQZLVgdH5eE8UUkgNlXUgt/SpoZK8317cPBoE8MyvFg+yT/aXufoxROR1782IGKLwoqABs4UvBCfzg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Cjp8xPN3RUM5OddQSmxigJbi+D9CHmDgyVuA6D5RiiyGfSw/+x0Edd5zsYREEB8jTwNClG4TMOFxdQkfssfaENZIDPOsstqQTsORb4jr/HAXH/H9F3tfRR2fUKsdI45VNGFSIYyhUEV/XwHEDaRDLBjd24U8KB9vaPFU0VMP8ImgM6Bi8tlaXJM0+cILzXUpGKeu4eiD/lmsEFunmkHLmOpaHhfprjFp5xgumUf+vi7rdAgxKiA4dMtyvnPFQwQg7CtSVZvbUmLYruJWRBTXZKwn5rXQO3yludzWmBBPZHVgwWnKdIc+wARLvkdbBGbqQY1mQa0+nshUc+Q3vFl92g==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=temperror header.s=selector2 header.d=Nvidia.com header.i="@Nvidia.com"
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com;
- Cc: <akpm@xxxxxxxxxxxxxxxxxxxx>, <tsbogend@xxxxxxxxxxxxxxxx>, <maddy@xxxxxxxxxxxxx>, <mpe@xxxxxxxxxxxxxx>, <maarten.lankhorst@xxxxxxxxxxxxxxx>, <mripard@xxxxxxxxxx>, <tzimmermann@xxxxxxx>, <airlied@xxxxxxxxx>, <simona@xxxxxxxx>, <l.stach@xxxxxxxxxxxxxx>, <inki.dae@xxxxxxxxxxx>, <sw0312.kim@xxxxxxxxxxx>, <kyungmin.park@xxxxxxxxxxx>, <krzk@xxxxxxxxxx>, <peter.griffin@xxxxxxxxxx>, <jani.nikula@xxxxxxxxxxxxxxx>, <joonas.lahtinen@xxxxxxxxxxxxxxx>, <rodrigo.vivi@xxxxxxxxx>, <tursulin@xxxxxxxxxxx>, <robin.clark@xxxxxxxxxxxxxxxx>, <lumag@xxxxxxxxxx>, <lyude@xxxxxxxxxx>, <dakr@xxxxxxxxxx>, <tomi.valkeinen@xxxxxxxxxxxxxxxx>, <hjc@xxxxxxxxxxxxxx>, <heiko@xxxxxxxxx>, <andy.yan@xxxxxxxxxxxxxx>, <thierry.reding@xxxxxxxxxx>, <mperttunen@xxxxxxxxxx>, <jonathanh@xxxxxxxxxx>, <kraxel@xxxxxxxxxx>, <dmitry.osipenko@xxxxxxxxxxxxx>, <zack.rusin@xxxxxxxxxxxx>, <matthew.brost@xxxxxxxxx>, <thomas.hellstrom@xxxxxxxxxxxxxxx>, <oleksandr_andrushchenko@xxxxxxxx>, <deller@xxxxxx>, <bcrl@xxxxxxxxx>, <viro@xxxxxxxxxxxxxxxxxx>, <brauner@xxxxxxxxxx>, <muchun.song@xxxxxxxxx>, <osalvador@xxxxxxx>, <david@xxxxxxxxxx>, <baolin.wang@xxxxxxxxxxxxxxxxx>, <liam@xxxxxxxxxxxxx>, <npache@xxxxxxxxxx>, <ryan.roberts@xxxxxxx>, <dev.jain@xxxxxxx>, <baohua@xxxxxxxxxx>, <hughd@xxxxxxxxxx>, <vbabka@xxxxxxxxxx>, <rppt@xxxxxxxxxx>, <surenb@xxxxxxxxxx>, <mhocko@xxxxxxxx>, <jannh@xxxxxxxxxx>, <pfalcato@xxxxxxx>, <kees@xxxxxxxxxx>, <perex@xxxxxxxx>, <tiwai@xxxxxxxx>, <linux-mips@xxxxxxxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>, <linuxppc-dev@xxxxxxxxxxxxxxxx>, <dri-devel@xxxxxxxxxxxxxxxxxxxxx>, <etnaviv@xxxxxxxxxxxxxxxxxxxxx>, <linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>, <linux-samsung-soc@xxxxxxxxxxxxxxx>, <intel-gfx@xxxxxxxxxxxxxxxxxxxxx>, <linux-arm-msm@xxxxxxxxxxxxxxx>, <freedreno@xxxxxxxxxxxxxxxxxxxxx>, <nouveau@xxxxxxxxxxxxxxxxxxxxx>, <linux-rockchip@xxxxxxxxxxxxxxxxxxx>, <linux-tegra@xxxxxxxxxxxxxxx>, <virtualization@xxxxxxxxxxxxxxx>, <intel-xe@xxxxxxxxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <linux-fbdev@xxxxxxxxxxxxxxx>, <linux-aio@xxxxxxxxx>, <linux-fsdevel@xxxxxxxxxxxxxxx>, <linux-mm@xxxxxxxxx>, <linux-sound@xxxxxxxxxxxxxxx>
- Delivery-date: Thu, 09 Jul 2026 01:52:48 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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@xxxxxxxxxx>
>> >---
>> [...]
>> >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()?
vma_flags gets VMA_SOFTDIRTY_BIT just above vma->flags, why do we need a
check after that?
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 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@xxxxxxxxxx>
--
Best Regards,
Yan, Zi
|