[PATCH v5 03/15] mm/vma: remove unused function, make internal functions static

Lorenzo Stoakes posted 15 patches 1 month, 3 weeks ago
[PATCH v5 03/15] mm/vma: remove unused function, make internal functions static
Posted by Lorenzo Stoakes 1 month, 3 weeks ago
unlink_file_vma() is not used by anything, so remove it.

vma_link() and vma_link_file() are only used within mm/vma.c, so make them
static.

Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 mm/vma.c | 21 ++-------------------
 mm/vma.h |  6 ------
 2 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/mm/vma.c b/mm/vma.c
index 9127eaeea93f..004958a085cb 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -1754,24 +1754,7 @@ void unlink_file_vma_batch_final(struct unlink_vma_file_batch *vb)
 		unlink_file_vma_batch_process(vb);
 }
 
-/*
- * Unlink a file-based vm structure from its interval tree, to hide
- * vma from rmap and vmtruncate before freeing its page tables.
- */
-void unlink_file_vma(struct vm_area_struct *vma)
-{
-	struct file *file = vma->vm_file;
-
-	if (file) {
-		struct address_space *mapping = file->f_mapping;
-
-		i_mmap_lock_write(mapping);
-		__remove_shared_vm_struct(vma, mapping);
-		i_mmap_unlock_write(mapping);
-	}
-}
-
-void vma_link_file(struct vm_area_struct *vma)
+static void vma_link_file(struct vm_area_struct *vma)
 {
 	struct file *file = vma->vm_file;
 	struct address_space *mapping;
@@ -1784,7 +1767,7 @@ void vma_link_file(struct vm_area_struct *vma)
 	}
 }
 
-int vma_link(struct mm_struct *mm, struct vm_area_struct *vma)
+static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma)
 {
 	VMA_ITERATOR(vmi, mm, 0);
 
diff --git a/mm/vma.h b/mm/vma.h
index 9183fe549009..e912d42c428a 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -312,12 +312,6 @@ void unlink_file_vma_batch_final(struct unlink_vma_file_batch *vb);
 void unlink_file_vma_batch_add(struct unlink_vma_file_batch *vb,
 			       struct vm_area_struct *vma);
 
-void unlink_file_vma(struct vm_area_struct *vma);
-
-void vma_link_file(struct vm_area_struct *vma);
-
-int vma_link(struct mm_struct *mm, struct vm_area_struct *vma);
-
 struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
 	unsigned long addr, unsigned long len, pgoff_t pgoff,
 	bool *need_rmap_locks);
-- 
2.51.0
Re: [PATCH v5 03/15] mm/vma: remove unused function, make internal functions static
Posted by Jason Gunthorpe 1 month, 3 weeks ago
On Mon, Oct 20, 2025 at 01:11:20PM +0100, Lorenzo Stoakes wrote:
> unlink_file_vma() is not used by anything, so remove it.
> 
> vma_link() and vma_link_file() are only used within mm/vma.c, so make them
> static.
> 
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> ---
>  mm/vma.c | 21 ++-------------------
>  mm/vma.h |  6 ------
>  2 files changed, 2 insertions(+), 25 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason