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 49DD53B811F for ; Fri, 7 Aug 2026 02:00:59 +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=1786068063; cv=none; b=ehDAOlt5ahyjEq1jEcHdA/E6SQ4CCYHkIWro45iEiE7FJlps8mtsqKWhRIk2Bc/O7p9E2IG+HWnMrgHd61pF10WD6Xz6BHRvOFYuZ1n/xrW+J7Tpa+X4mTA1HJwlv+RfnUG+KkuKFSDvDYuRlOF7LdVN6So8pRmJB5un5Ek9AVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786068063; c=relaxed/simple; bh=nVogyNWSEc497QTSuYuzimT91bra/O9YB3ZEbycnPVY=; h=Date:To:From:Subject:Message-Id; b=tbgVWVLl90+4R56rSlkteYQ8L7KsUgvSdR2SMYabWFU/DFVuRY6rZ69M2yrzn6C7yII4VnTcQd6X54OnOffkvGRXr4wNNA2/0YY0ZNPKCgvUTRuYWMVrLiGQfUelIdMrKXDuTdfjPVPkVW667tZNQzoEajii3btC0l2TuPnVGdE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=nOBQ7mCE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="nOBQ7mCE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACA071F00A3F; Fri, 7 Aug 2026 02:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1786068058; bh=xEzv1lDm7T2uHwhy8QeTgHUhOzswvMzt7EGBf8/ECHE=; h=Date:To:From:Subject; b=nOBQ7mCERk4Fdhk5cRx2AD5ePsH1yS/mey90GAboVILnlC1Kp8Mg/KjLbabrMR5nd gHAusruYFFFJp5U4OqHVMzWpmXmxIip2TE2gjGt6+CCY//XMj8EOV6QSP955EQDovQ zsUm9tk8D6t8TFS4b+GGzHdIGyLBS+jKrcATPngc= Date: Thu, 06 Aug 2026 19:00:58 -0700 To: mm-commits@vger.kernel.org,ziy@nvidia.com,vbabka@kernel.org,tzimmermann@suse.de,surenb@google.com,rppt@kernel.org,pfalcato@suse.de,osalvador@suse.de,npache@redhat.com,muchun.song@linux.dev,lance.yang@linux.dev,jannh@google.com,jani.nikula@intel.com,jack@suse.cz,dev.jain@arm.com,david@kernel.org,brauner@kernel.org,baolin.wang@linux.alibaba.com,baohua@kernel.org,airlied@gmail.com,ljs@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] mm-mremap-convert-mremap-code-to-use-vma_flags_t.patch removed from -mm tree Message-Id: <20260807020058.ACA071F00A3F@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The quilt patch titled Subject: mm/mremap: convert mremap code to use vma_flags_t has been removed from the -mm tree. Its filename was mm-mremap-convert-mremap-code-to-use-vma_flags_t.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Lorenzo Stoakes Subject: mm/mremap: convert mremap code to use vma_flags_t Date: Sat, 11 Jul 2026 19:45:10 +0100 Replace use of the legacy vm_flags_t flags with vma_flags_t values throughout the mremap logic. Note that, in replacing vm_flags_clear() (which takes the VMA write lock) with vma_clear_flags() and vma_clear_flags_mask() (which do not) respectively in unmap_source_vma() and dontunmap_complete(), we do not add a VMA write lock to account for htis. This is because, in both cases, move_vma() is their calling function and this has already acquired the VMA write lock on vrm->vma whose VMA flags are being cleared. In the case of vma_set_flags() in unmap_source_vma() we do need to do this - as prev and next were not necessarily write locked at this point. Additionally update comments to reflect the changes to be consistent. No functional change intended. Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-13-0fa2357d5431@kernel.org Signed-off-by: Lorenzo Stoakes Reviewed-by: Zi Yan Reviewed-by: Vlastimil Babka (SUSE) Cc: Baolin Wang Cc: Barry Song Cc: Christian Brauner Cc: Dave Airlie Cc: David Hildenbrand Cc: Dev Jain Cc: Jani Nikula Cc: Jan Kara Cc: Jann Horn Cc: Lance Yang Cc: Mike Rapoport Cc: Muchun Song Cc: Nico Pache Cc: Oscar Salvador Cc: Pedro Falcato Cc: Suren Baghdasaryan Cc: Thomas Zimmermann Signed-off-by: Andrew Morton --- mm/mremap.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) --- a/mm/mremap.c~mm-mremap-convert-mremap-code-to-use-vma_flags_t +++ a/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? */ }; @@ -963,7 +963,7 @@ static unsigned long vrm_set_new_addr(st 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, @@ -985,7 +985,7 @@ static bool vrm_calc_charge(struct vma_r { unsigned long charged; - if (!(vrm->vma->vm_flags & VM_ACCOUNT)) + if (!vma_test(vrm->vma, VMA_ACCOUNT_BIT)) return true; /* @@ -1012,7 +1012,7 @@ static bool vrm_calc_charge(struct vma_r */ 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); @@ -1032,7 +1032,7 @@ static void vrm_stat_account(struct vma_ 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; } @@ -1176,7 +1176,7 @@ static void unmap_source_vma(struct vma_ * 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); /* @@ -1195,7 +1195,7 @@ static void unmap_source_vma(struct vma_ * 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; @@ -1220,8 +1220,8 @@ static void unmap_source_vma(struct vma_ * | | * |-------------| * - * 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 * | | @@ -1241,13 +1241,15 @@ static void unmap_source_vma(struct vma_ 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); } } } @@ -1330,8 +1332,8 @@ static void dontunmap_complete(struct vm 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 @@ -1767,14 +1769,14 @@ static int check_prep_vma(struct vma_rem * 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; /* @@ -1804,7 +1806,7 @@ static int check_prep_vma(struct vma_rem 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 */ @@ -1812,10 +1814,10 @@ static int check_prep_vma(struct vma_rem 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)) _ Patches currently in -mm which might be from ljs@kernel.org are x86-mm-pat-acquire-init_mm-write-lock-on-collapse-to-avoid-uaf.patch x86-mm-pat-acquire-init_mm-read-lock-on-attribute-change-to-avoid-uaf.patch x86-mm-pat-allocate-split-page-tables-as-kernel-page-tables.patch mm-vma-introduce-vma-anon-page-offset-field-and-add-helpers.patch mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping.patch mm-introduce-linear_anon_page_index.patch mm-abstract-vma_address-and-introduce-vma_anon_address.patch mm-update-print_bad_page_map-to-show-anon-index-if-appropriate.patch mm-introduce-and-use-vma_filebacked_address.patch mm-vma-fix-self-merge-check-in-copy_vma.patch tools-testing-vma-add-tests-for-copy_vma-self-merge.patch mm-propagate-vma-anonymous-page-offset-on-map-remap-split-merge.patch mm-rmap-track-whether-the-page-vma-mapped-pgoff-is-anonymous.patch mm-clean-up-vma_address_end.patch mm-huge_memory-update-remove_migration_pmd-to-accept-a-folio.patch mm-migrate-calculate-large-folio-page-index-using-pfn.patch mm-rmap-use-anon-pgoff-to-track-map_private-file-backed-anon-folios.patch tools-testing-vma-expand-vma-merge-tests-to-assert-anon-pgoff.patch tools-testing-selftests-mm-test-anonymous-page-offset-merge-behaviour.patch mm-vma-only-permit-map_private-dev-zero-to-be-mapped-anonymous.patch mm-vma-make-map_private-mapped-dev-zero-mappings-truly-anonymous.patch tools-testing-vma-add-test-to-assert-map_private-dev-zero-is-anon.patch tools-testing-selftests-mm-add-map_private-dev-zero-merge-tests.patch mm-add-some-missing-includes-to-mm-local-headers.patch