From nobody Sat Apr 4 04:33:36 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 06E2037B008; Fri, 20 Mar 2026 22:40:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774046426; cv=none; b=ANwP8rHIWelxD/JxGS2uAUxjmcD7dpo0EMdyso8RE2YMJ16QLIiqDQm53agB+SiKt7p80S6hN+XHUyivj7eoV3DUsPTEM4U2VTTkp6RmPXelHMCI0xGJcmmJb32OI3z92ulTWSX8KP4r+kTH2ZUYT5wCU09Ip9Xm+K9Mkkqq3k4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774046426; c=relaxed/simple; bh=5B0UudB5t6IvoUSjas4gSsitxv5wljP/xv5/LMRSwMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=njpI+uR4fdBuKZ1m4+twCRk7NFA76GfSSmGV12zh6njZ7MZhB8uMrkqlPJAEqCO0pdrfv/UeU/zhzRzyu4GXxQukX2Muo6KAEziTe+L5HWgAyvMxeVrWrRrids9hpGJEYFZygGyxDR4vt4/DYq20vvaV9c6klhkZ5bYwovcRVHo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KUQ4yJnN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KUQ4yJnN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDF76C2BCB0; Fri, 20 Mar 2026 22:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774046423; bh=5B0UudB5t6IvoUSjas4gSsitxv5wljP/xv5/LMRSwMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KUQ4yJnN/WuHnEHkwKNXjPL29+3niu71Tepf6T8MO4WkDdogsFLE72V8PeJFDVlF4 Bgq2IUCnGX2DqjqxgG9VU/AJ9tvaRvZoXCJ/edOpA2ecyHNMPx/827tzdtxUxlno1b kB/jx2f29BxgqysOfNJm2thngFQSBiZldAHGABhZEbYYZtllNjGAzqunIUk7syMpWE q4F2EYNQ3xjEpxq+z70oW/TZyTdZnIe3eNlH70hr0fh7kvql3+XaNSIzX6J9joDX/J Wo7adkEJHy2wBoh1A0sfY4bHYjqE6KjPrlgSkBE1+cXFhZzg9cVq3BIUNXtQCYbYf7 VMR8sVXp9E6aw== From: "Lorenzo Stoakes (Oracle)" To: Andrew Morton Cc: Jonathan Corbet , Clemens Ladisch , Arnd Bergmann , Greg Kroah-Hartman , "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Bodo Stroesser , "Martin K . Petersen" , David Howells , Marc Dionne , Alexander Viro , Christian Brauner , Jan Kara , David Hildenbrand , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, linux-staging@lists.linux.dev, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Ryan Roberts Subject: [PATCH v4 06/21] mm/vma: remove superfluous map->hold_file_rmap_lock Date: Fri, 20 Mar 2026 22:39:32 +0000 Message-ID: <42c3fbb701e361a17193ecda0d2dabcc326288a5.1774045440.git.ljs@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We don't need to reference this field, it's confusing as it duplicates mmap_action->hide_from_rmap_until_complete, so thread the mmap_action through to __mmap_new_vma() instead and use the same field consistently. Signed-off-by: Lorenzo Stoakes (Oracle) Acked-by: Vlastimil Babka (SUSE) --- mm/vma.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index 3fc5fe4f1a7c..6105f54cea61 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -38,8 +38,6 @@ struct mmap_state { =20 /* Determine if we can check KSM flags early in mmap() logic. */ bool check_ksm_early :1; - /* If we map new, hold the file rmap lock on mapping. */ - bool hold_file_rmap_lock :1; /* If .mmap_prepare changed the file, we don't need to pin. */ bool file_doesnt_need_get :1; }; @@ -2531,10 +2529,12 @@ static int __mmap_new_file_vma(struct mmap_state *m= ap, * * @map: Mapping state. * @vmap: Output pointer for the new VMA. + * @action: Any mmap_prepare action that is still to complete. * * Returns: Zero on success, or an error. */ -static int __mmap_new_vma(struct mmap_state *map, struct vm_area_struct **= vmap) +static int __mmap_new_vma(struct mmap_state *map, struct vm_area_struct **= vmap, + struct mmap_action *action) { struct vma_iterator *vmi =3D map->vmi; int error =3D 0; @@ -2583,7 +2583,7 @@ static int __mmap_new_vma(struct mmap_state *map, str= uct vm_area_struct **vmap) vma_start_write(vma); vma_iter_store_new(vmi, vma); map->mm->map_count++; - vma_link_file(vma, map->hold_file_rmap_lock); + vma_link_file(vma, action->hide_from_rmap_until_complete); =20 /* * vma_merge_new_range() calls khugepaged_enter_vma() too, the below @@ -2650,8 +2650,6 @@ static int call_action_prepare(struct mmap_state *map, if (err) return err; =20 - if (desc->action.hide_from_rmap_until_complete) - map->hold_file_rmap_lock =3D true; return 0; } =20 @@ -2741,7 +2739,7 @@ static int call_action_complete(struct mmap_state *ma= p, err =3D mmap_action_complete(vma, action); =20 /* If we held the file rmap we need to release it. */ - if (map->hold_file_rmap_lock) { + if (action->hide_from_rmap_until_complete) { struct file *file =3D vma->vm_file; =20 i_mmap_unlock_write(file->f_mapping); @@ -2795,7 +2793,7 @@ static unsigned long __mmap_region(struct file *file,= unsigned long addr, =20 /* ...but if we can't, allocate a new VMA. */ if (!vma) { - error =3D __mmap_new_vma(&map, &vma); + error =3D __mmap_new_vma(&map, &vma, &desc.action); if (error) goto unacct_error; allocated_new =3D true; --=20 2.53.0