From af584eafef467054f5fcde38dd01dd05d7e2bba4 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 23 Feb 2021 10:49:13 -0500 Subject: [PATCH] mm: Move vma_mas_store()/vma_mas_erase() to internal header. These are used in nommu case as well Signed-off-by: Liam R. Howlett --- mm/internal.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ mm/mmap.c | 43 ------------------------------------------- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index c4cf64fe40d7..c00c8423789e 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -332,6 +332,50 @@ static inline bool is_data_mapping(vm_flags_t flags) return (flags & (VM_WRITE | VM_SHARED | VM_STACK)) == VM_WRITE; } +/* Maple tree operations using VMAs */ +/* + * vma_mas_store() - Store a VMA in the maple tree. + * @vma: The vm_area_struct + * @mas: The maple state + * + * Efficient way to store a VMA in the maple tree when the @mas has already + * walked to the correct location. + * + * Note: the end address is inclusive in the maple tree. + */ +static inline int vma_mas_store(struct vm_area_struct *vma, struct ma_state *mas) +{ + int ret; + + mas->index = vma->vm_start; + mas->last = vma->vm_end - 1; + mas_lock(mas); + ret = mas_store_gfp(mas, vma, GFP_KERNEL); + mas_unlock(mas); + return ret; +} + +/* + * vma_mas_remove() - Remove a VMA from the maple tree. + * @vma: The vm_area_struct + * @mas: The maple state + * + * Efficient way to remove a VMA from the maple tree when the @mas has already + * been established and points to the correct location. + * Note: the end address is inclusive in the maple tree. + */ +static inline int vma_mas_remove(struct vm_area_struct *vma, struct ma_state *mas) +{ + int ret; + + mas->index = vma->vm_start; + mas->last = vma->vm_end - 1; + mas_lock(mas); + ret = mas_store_gfp(mas, NULL, GFP_KERNEL); + mas_unlock(mas); + return ret; +} + /* mm/util.c */ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma, struct vm_area_struct *prev); diff --git a/mm/mmap.c b/mm/mmap.c index 52762e1a9787..5387a1ced776 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -442,49 +442,6 @@ static void __vma_link_file(struct vm_area_struct *vma) } } -/* - * vma_mas_store() - Store a VMA in the maple tree. - * @vma: The vm_area_struct - * @mas: The maple state - * - * Efficient way to store a VMA in the maple tree when the @mas has already - * walked to the correct location. - * - * Note: the end address is inclusive in the maple tree. - */ -static inline int vma_mas_store(struct vm_area_struct *vma, struct ma_state *mas) -{ - int ret; - - mas->index = vma->vm_start; - mas->last = vma->vm_end - 1; - mas_lock(mas); - ret = mas_store_gfp(mas, vma, GFP_KERNEL); - mas_unlock(mas); - return ret; -} - -/* - * vma_mas_remove() - Remove a VMA from the maple tree. - * @vma: The vm_area_struct - * @mas: The maple state - * - * Efficient way to remove a VMA from the maple tree when the @mas has already - * been established and points to the correct location. - * Note: the end address is inclusive in the maple tree. - */ -static inline int vma_mas_remove(struct vm_area_struct *vma, struct ma_state *mas) -{ - int ret; - - mas->index = vma->vm_start; - mas->last = vma->vm_end - 1; - mas_lock(mas); - ret = mas_store_gfp(mas, NULL, GFP_KERNEL); - mas_unlock(mas); - return ret; -} - /* * vma_mt_szero() - Set a given range to zero. Used when modifying a * vm_area_struct start or end. -- 2.50.1