From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 799FBC43602 for ; Thu, 2 Jul 2026 13:50:35 +0000 (UTC) Received: from kara.freedesktop.org (unknown [131.252.210.166]) by gabe.freedesktop.org (Postfix) with ESMTPS id 549AA10F3CC; Thu, 2 Jul 2026 13:50:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="SBk2LGdo"; dkim-atps=neutral Received: from kara.freedesktop.org (localhost [127.0.0.1]) by kara.freedesktop.org (Postfix) with ESMTP id C153946E75; Thu, 2 Jul 2026 13:35:48 +0000 (UTC) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=lists.freedesktop.org; s=20240201; t=1782999348; b=01m72HczLAZoHL5U2qqg7P36pZgGj5EpqyMmyGALz8GbtXssCdsQRENHALfTLwn9LKMW0 o6cEfILuAj3YYVeBdYdWz1LGPj7YYdlIwtUwV2ao7AIgSjCGXYJcsyqN+rz+b4rUCKE0iPV wwPS0qEluCt3pKkCZsdFtGOYkLHYUbUbhVl7HZOMeUBlvgEN6jfU39kvxTKD4LXp73Q2zD+ Pk404bDPcDe+jOQJ4HWfjZaLqG63X3EhZWF1rmIMv6xBEGRfUPf5U8ZChpf+bnAog6jow+/ e7qpan6n4Zht+5mvuoFZKfMn5SUvLVKvwhSzgnoWUZ73eSCm/KJtxdbgWmZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.freedesktop.org; s=20240201; t=1782999348; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=n7JedrMMFsZ3SA9xp8Er9WQ7Q5NWmS7gMbpQ8O+PQSg=; b=UjpDSXBWa3FFYYdyNMLbbwqmgvQfMHX4a82OJLM03QeyGvgszHjsGnp/1RhkjUnAQs1Au CpFVct/41ZsQdo5S7Udery/nNkqt0SlUt+1lWQLUwr291irYY6RndZ3LWf9E5YxaW3+P00I 5YuIE43GYZ6QWjXqPhwvecSael9N/N0kzPN5elbCjlZ3D9AU0HbQnZ+IJRywToDHzraoSmx DKe4p/p90PDsosgQFAMw1G+zB1indExpLR+27m26/gQCa0NqD1OP0y4VJgH2VRYrevO305d eQSEFA4EJC+NRqDrdaXAx+0/N4Kvo9zA6EkUGcjFPbhi+XnRjYGfNuO7a05g== ARC-Authentication-Results: i=1; mail.freedesktop.org; dkim=pass header.d=linux.dev; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=linux.dev policy.dmarc=none Authentication-Results: mail.freedesktop.org; dkim=pass header.d=linux.dev; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=linux.dev policy.dmarc=none Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by kara.freedesktop.org (Postfix) with ESMTPS id F341046E3B for ; Thu, 2 Jul 2026 13:35:44 +0000 (UTC) Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) by gabe.freedesktop.org (Postfix) with ESMTPS id 343DE10F3C3 for ; Thu, 2 Jul 2026 13:50:31 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783000216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n7JedrMMFsZ3SA9xp8Er9WQ7Q5NWmS7gMbpQ8O+PQSg=; b=SBk2LGdo8O2Fh816oQbqXrmhKAQAYAxHqV6r2z//9k66SRzp2XfssdY3VkdvqTHoJEhhne KBLV5b7WimMmbUd67b8UpLhwJTAsCl8UHKUpcr3XwD//YOwU43JswyAPjZ9yhLgdwnTOAg TszqN8wOwdlDLsXMvuRT5nF6gC9LQmA= From: Lance Yang To: ljs@kernel.org Subject: Re: [PATCH 13/13] mm/mremap: convert mremap code to use vma_flags_t Date: Thu, 2 Jul 2026 21:49:47 +0800 Message-Id: <20260702134947.25189-1-lance.yang@linux.dev> In-Reply-To: <380f761d35a3faa4370f8b3f92e3d4af3d4c7110.1782760670.git.ljs@kernel.org> References: <380f761d35a3faa4370f8b3f92e3d4af3d4c7110.1782760670.git.ljs@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Message-ID-Hash: MCYEXXDSRMPLYEVNR5AMDGYHERRNTAB5 X-Message-ID-Hash: MCYEXXDSRMPLYEVNR5AMDGYHERRNTAB5 X-MailFrom: lance.yang@linux.dev X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header 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, 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, 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, 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, lance.yang@linux.dev, 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 X-Mailman-Version: 3.3.8 Precedence: list List-Id: Nouveau development list Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Mon, Jun 29, 2026 at 08:25:36PM +0100, Lorenzo Stoakes wrote: >Replace use of the legacy vm_flags_t flags with vma_flags_t values >throughout the mremap logic. > >Additionally update comments to reflect the changes to be consistent. > >No functional change intended. > >Signed-off-by: Lorenzo Stoakes >--- The vm_flags_set() cases below spell out vma_start_write(), but the vm_flags_clear() cases don't? Thanks, Lance > mm/mremap.c | 38 ++++++++++++++++++++------------------ > 1 file changed, 20 insertions(+), 18 deletions(-) > >diff --git a/mm/mremap.c b/mm/mremap.c >index 079a0ba0c4a7..0ea43302b7ed 100644 >--- a/mm/mremap.c >+++ b/mm/mremap.c >@@ -68,7 +68,7 @@ struct vma_remap_struct { > bool populate_expand; /* mlock()'d expanded, must populate. */ > enum mremap_type remap_type; /* expand, shrink, etc. */ > bool mmap_locked; /* Is mm currently write-locked? */ >- unsigned long charged; /* If VM_ACCOUNT, # pages to account. */ >+ unsigned long charged; /* If VMA_ACCOUNT_BIT, # pgs to account */ > bool vmi_needs_invalidate; /* Is the VMA iterator invalidated? */ > }; > >@@ -954,7 +954,7 @@ static unsigned long vrm_set_new_addr(struct vma_remap_struct *vrm) > > if (vrm->flags & MREMAP_FIXED) > map_flags |= MAP_FIXED; >- if (vma->vm_flags & VM_MAYSHARE) >+ if (vma_test(vma, VMA_MAYSHARE_BIT)) > map_flags |= MAP_SHARED; > > res = get_unmapped_area(vma->vm_file, new_addr, vrm->new_len, pgoff, >@@ -976,7 +976,7 @@ static bool vrm_calc_charge(struct vma_remap_struct *vrm) > { > unsigned long charged; > >- if (!(vrm->vma->vm_flags & VM_ACCOUNT)) >+ if (!vma_test(vrm->vma, VMA_ACCOUNT_BIT)) > return true; > > /* >@@ -1003,7 +1003,7 @@ static bool vrm_calc_charge(struct vma_remap_struct *vrm) > */ > static void vrm_uncharge(struct vma_remap_struct *vrm) > { >- if (!(vrm->vma->vm_flags & VM_ACCOUNT)) >+ if (!vma_test(vrm->vma, VMA_ACCOUNT_BIT)) > return; > > vm_unacct_memory(vrm->charged); >@@ -1023,7 +1023,7 @@ static void vrm_stat_account(struct vma_remap_struct *vrm, > struct vm_area_struct *vma = vrm->vma; > > vm_stat_account(mm, vma->vm_flags, pages); >- if (vma->vm_flags & VM_LOCKED) >+ if (vma_test(vma, VMA_LOCKED_BIT)) > mm->locked_vm += pages; > } > >@@ -1167,7 +1167,7 @@ static void unmap_source_vma(struct vma_remap_struct *vrm) > * arose, in which case we _do_ wish to unmap the _new_ VMA, which means > * we actually _do_ want it be unaccounted. > */ >- bool accountable_move = (vma->vm_flags & VM_ACCOUNT) && >+ bool accountable_move = vma_test(vma, VMA_ACCOUNT_BIT) && > !(vrm->flags & MREMAP_DONTUNMAP); > > /* >@@ -1186,7 +1186,7 @@ static void unmap_source_vma(struct vma_remap_struct *vrm) > * portions of the original VMA that remain. > */ > if (accountable_move) { >- vm_flags_clear(vma, VM_ACCOUNT); >+ vma_clear_flags(vma, VMA_ACCOUNT_BIT); > /* We are about to split vma, so store the start/end. */ > vm_start = vma->vm_start; > vm_end = vma->vm_end; >@@ -1211,8 +1211,8 @@ static void unmap_source_vma(struct vma_remap_struct *vrm) > * | | > * |-------------| > * >- * Having cleared VM_ACCOUNT from the whole VMA, after we unmap above >- * we'll end up with: >+ * Having cleared VMA_ACCOUNT_BIT from the whole VMA, after we unmap >+ * above we'll end up with: > * > * addr end > * | | >@@ -1232,13 +1232,15 @@ static void unmap_source_vma(struct vma_remap_struct *vrm) > if (vm_start < addr) { > struct vm_area_struct *prev = vma_prev(&vmi); > >- vm_flags_set(prev, VM_ACCOUNT); /* Acquires VMA lock. */ >+ vma_start_write(prev); >+ vma_set_flags(prev, VMA_ACCOUNT_BIT); > } > > if (vm_end > end) { > struct vm_area_struct *next = vma_next(&vmi); > >- vm_flags_set(next, VM_ACCOUNT); /* Acquires VMA lock. */ >+ vma_start_write(next); >+ vma_set_flags(next, VMA_ACCOUNT_BIT); > } > } > } >@@ -1321,8 +1323,8 @@ static void dontunmap_complete(struct vma_remap_struct *vrm, > unsigned long old_start = vrm->vma->vm_start; > unsigned long old_end = vrm->vma->vm_end; > >- /* We always clear VM_LOCKED[ONFAULT] on the old VMA. */ >- vm_flags_clear(vrm->vma, VM_LOCKED_MASK); >+ /* We always clear VMA_LOCKED[ONFAULT]_BIT on the old VMA. */ >+ vma_clear_flags_mask(vrm->vma, VMA_LOCKED_MASK); > > /* > * anon_vma links of the old vma is no longer needed after its page >@@ -1758,14 +1760,14 @@ static int check_prep_vma(struct vma_remap_struct *vrm) > * based on the original. There are no known use cases for this > * behavior. As a result, fail such attempts. > */ >- if (!old_len && !(vma->vm_flags & (VM_SHARED | VM_MAYSHARE))) { >+ if (!old_len && !vma_test_any(vma, VMA_SHARED_BIT, VMA_MAYSHARE_BIT)) { > pr_warn_once("%s (%d): attempted to duplicate a private mapping with mremap. This is not supported.\n", > current->comm, current->pid); > return -EINVAL; > } > > if ((vrm->flags & MREMAP_DONTUNMAP) && >- (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP))) >+ vma_test_any(vma, VMA_DONTEXPAND_BIT, VMA_PFNMAP_BIT)) > return -EINVAL; > > /* >@@ -1795,7 +1797,7 @@ static int check_prep_vma(struct vma_remap_struct *vrm) > return 0; > > /* We are expanding and the VMA is mlock()'d so we need to populate. */ >- if (vma->vm_flags & VM_LOCKED) >+ if (vma_test(vma, VMA_LOCKED_BIT)) > vrm->populate_expand = true; > > /* Need to be careful about a growing mapping */ >@@ -1803,10 +1805,10 @@ static int check_prep_vma(struct vma_remap_struct *vrm) > if (pgoff + (new_len >> PAGE_SHIFT) < pgoff) > return -EINVAL; > >- if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP)) >+ if (vma_test_any(vma, VMA_DONTEXPAND_BIT, VMA_PFNMAP_BIT)) > return -EFAULT; > >- if (!mlock_future_ok(mm, vma->vm_flags & VM_LOCKED, vrm->delta)) >+ if (!mlock_future_ok(mm, vma_test(vma, VMA_LOCKED_BIT), vrm->delta)) > return -EAGAIN; > > if (!may_expand_vm(mm, &vma->flags, vrm->delta >> PAGE_SHIFT)) >-- >2.54.0 > >