From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E62330D418; Thu, 2 Jul 2026 15:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783007189; cv=none; b=lhgWt0ElBXUzkuRRT7a/Gp+tDlKbGxldmsuA5efs1VZi88v8cqsJDZYMJ+PzeC0wLbiKhR9xwpGq5XE0TwDKDhGrKRAbA9ABQRqBMnprwIBWK9ud7stnmCikriqfKwRTIRykeRjgxXkoiObNWQI6w7qZHHvuXtq1rAHOUH97ulM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783007189; c=relaxed/simple; bh=n6TViXQecv0qYP6YJzh2c/hbMHYTe5g2OXuQRHGgZyM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OyAvgG3zWGjVMNmjNVxpuD0kDySo70YyOSdtAn4H+7+C58SdiiUTqPN5sQ9QAOqLQ2fDHlm4xI2Yr7PduF8se6RakWLH95MsQqpxImpHeiZdkP7KQRGkWT2o4mXZWmIfOX/ZyJFvX1w0VlwgDwfDFElcomuqXU7EAxO7GnUDHOs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mynx6GD6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mynx6GD6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90EC61F000E9; Thu, 2 Jul 2026 15:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783007187; bh=jvE9wSqWBUCbGMsJG9svgBUezevNvrm1MrcHHSCChso=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Mynx6GD6LkebsGmUnF9MjOYGoc5t/kjVRBAa3y4hDMiI7/vl1tQdkpNYaMYBglDKt PpjOhV7WkyGWbA6148JfY40EHSUewPFem4EcHLSNtrDL52P+m6uRZFhhXV+p8drDP5 krlXhtnXXcRAzWJ2KFYq3Hh8rhTgMNWOvfDO5ubcScHxjko5fhA5/oYXfBSBTm3FYZ q91+d//PbttUXOxvDyYYUNz2FFsT7LJ6pIAF99pcS/rpWlpmF6qsZCGqK6q0R7Cu6u A7jMMvK5AtByO3p0pYtd9gulxJxBI42o3AQ7j7VXEvArqPbpGQYUH4EuymRAwVZamK 6IrFtw9w61Ysg== Date: Thu, 2 Jul 2026 16:46:04 +0100 From: Lorenzo Stoakes To: Lance Yang Cc: 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, ziy@nvidia.com, 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 Message-ID: References: <1e7d834c887b6a65627d730addcff13d458c6268.1782760670.git.ljs@kernel.org> <20260702131233.59026-1-lance.yang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260702131233.59026-1-lance.yang@linux.dev> 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 > >--- > [...] > >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! 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. > > [...] Thanks, Lorenzo