From b055fe316a27514249a24d7f3ec83ffcae14b503 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Mon, 25 Jan 2021 14:33:44 -0500 Subject: [PATCH] mm: Move maple tree operators from mmap to internal.h header. Prepare for nommu changes Signed-off-by: Liam R. Howlett --- mm/internal.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ mm/mmap.c | 62 -------------------------------------------------- 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index aaf382dbee14..af9fcd219191 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -618,4 +618,67 @@ struct migration_target_control { gfp_t gfp_mask; }; + +/* + * 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) +{ + mas->index = vma->vm_start; + mas->last = vma->vm_end - 1; + return mas_store_gfp(mas, vma, GFP_KERNEL); +} + +/* + * 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) +{ + mas->index = vma->vm_start; + mas->last = vma->vm_end - 1; + return mas_store_gfp(mas, NULL, GFP_KERNEL); +} + +/* + * vma_mt_szero() - Set a given range to zero. Used when modifying a + * vm_area_struct start or end. + * + * @mm: The struct_mm + * @start: The start address to zero + * @end: The end address to zero. + */ +static inline void vma_mt_szero(struct mm_struct *mm, unsigned long start, + unsigned long end) +{ + trace_vma_mt_szero(mm, start, end); + mtree_store_range(&mm->mm_mt, start, end - 1, NULL, GFP_KERNEL); +} + +/* + * vma_mt_store() - Store a given vm_area_struct in the maple tree. + * + * @mm: The struct_mm + * @vma: The vm_area_struct to store in the maple tree. + */ +static inline void vma_mt_store(struct mm_struct *mm, struct vm_area_struct *vma) +{ + trace_vma_mt_store(mm, vma); + mtree_store_range(&mm->mm_mt, vma->vm_start, vma->vm_end - 1, vma, + GFP_KERNEL); +} + + #endif /* __MM_INTERNAL_H */ diff --git a/mm/mmap.c b/mm/mmap.c index b7f6e27411ad..c1e68091a05c 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -430,68 +430,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) -{ - mas->index = vma->vm_start; - mas->last = vma->vm_end - 1; - return mas_store_gfp(mas, vma, GFP_KERNEL); -} - -/* - * 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) -{ - mas->index = vma->vm_start; - mas->last = vma->vm_end - 1; - return mas_store_gfp(mas, NULL, GFP_KERNEL); -} - -/* - * vma_mt_szero() - Set a given range to zero. Used when modifying a - * vm_area_struct start or end. - * - * @mm: The struct_mm - * @start: The start address to zero - * @end: The end address to zero. - */ -static inline void vma_mt_szero(struct mm_struct *mm, unsigned long start, - unsigned long end) -{ - trace_vma_mt_szero(mm, start, end); - mtree_store_range(&mm->mm_mt, start, end - 1, NULL, GFP_KERNEL); -} - -/* - * vma_mt_store() - Store a given vm_area_struct in the maple tree. - * - * @mm: The struct_mm - * @vma: The vm_area_struct to store in the maple tree. - */ -static inline void vma_mt_store(struct mm_struct *mm, struct vm_area_struct *vma) -{ - trace_vma_mt_store(mm, vma); - mtree_store_range(&mm->mm_mt, vma->vm_start, vma->vm_end - 1, vma, - GFP_KERNEL); -} - - static void vma_mas_link(struct mm_struct *mm, struct vm_area_struct *vma, struct ma_state *mas) { -- 2.50.1